Skip to content

Commit

Permalink
Testing and setting the delay to a minimum value needs to occur only
Browse files Browse the repository at this point in the history
if delay is not zero, otherwise the timer is not turned off when it
should be. Move the test and setting back inside the block that is only
executed if delay > 0.
  • Loading branch information
madscifi authored and triffid committed May 15, 2011
1 parent 408718d commit f555887
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions timer.c
Expand Up @@ -135,12 +135,6 @@ void timer_init()
/// specify how long until the step timer should fire /// specify how long until the step timer should fire
void setTimer(uint32_t delay) void setTimer(uint32_t delay)
{ {
// if the delay is too small use a minimum delay so that there is time
// to set everything up before the timer expires.

if (delay < 17 )
delay = 17;

// save interrupt flag // save interrupt flag
uint8_t sreg = SREG; uint8_t sreg = SREG;
uint16_t step_start = 0; uint16_t step_start = 0;
Expand All @@ -154,6 +148,12 @@ void setTimer(uint32_t delay)


if (delay > 0) { if (delay > 0) {


// if the delay is too small use a minimum delay so that there is time
// to set everything up before the timer expires.

if (delay < 17 )
delay = 17;

// Assume all steps belong to one move. Within one move the delay is // Assume all steps belong to one move. Within one move the delay is
// from one step to the next one, which should be more or less the same // from one step to the next one, which should be more or less the same
// as from one step interrupt to the next one. The last step interrupt happend // as from one step interrupt to the next one. The last step interrupt happend
Expand Down

0 comments on commit f555887

Please sign in to comment.