[En-Nut-Discussion] NutMicroDelay tends to integer overflows

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Mon Aug 27 13:15:33 CEST 2012


>>>>> "Ole" == Ole Reinhardt <ole.reinhardt at embedded-it.de> writes:

    Ole> Hi all, The calculations in NutMicroDelay tends to overflow on
    Ole> systems with fast CPU if it is called with delay times of > a few
    Ole> milliseconds.

The wording should be:
tends to overflow on systems with fast non-Cortex CPU

With the systick approach on a STM32F4 running at 168 MHz with 1000 Hz
systick, overflow will happen after 2^31/167999 = 12.887 seconds, that is
more than 3 hours. Anything calling a blocking delay for that long seems
insane...

I even think that the use if NutDelay should be considered harmfull beside
some every special cases. Is there e.g. a reson you use NutDelay in your
lpc17xx_emac.c driver and not NutSleep?

Bye
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------



More information about the En-Nut-Discussion mailing list