[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Trouble with division

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Trouble with division
Date: Sat, 14 Jun 2003 20:28:39 +0200 (MET DST)

In article <address@hidden> you write:


That's probably your problem.  Make this SIGNAL(SIG_OVERFLOW0).

SIGNAL() is not interruptible, INTERRUPT() is.

>The problem is: The divsion seems to ge wrong when I divide by any number 
>that is not a power of 2 (as in the above example). If I change the 33 to 
>32 or any other power of 2, the result is just like expected.

Division by a power of 2 is magnitudes faster than division by an
arbitrary number.  I guess your timer is running at a fast speed, so
the interrupt handler is interrupted again.

Of course, while SIGNAL() will prevent this from happen, you'll lose
interrupts.  Consider using something else than an expensive division,
or run it at a lower tick rate.
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]