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

Ole Reinhardt ole.reinhardt at embedded-it.de
Mon Aug 27 00:27:39 CEST 2012


Hi all,

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

Especially when using NutDelay() NutMicroDelay may be called with large
delays.

One way to solve the problem is to use 64bit integers as intermediate
results in the delayloop calculations. Beside of beeing not very
efficient it brings big (linker) problems when using 64bit divisions.
See my former post

http://old.nabble.com/Strange-newlib-syscall-dependencies---linker-problems-when-using-64bit-integers-td33275220.html



So I decided to modify as less as possible and to just change the
comments:

We should not give parameter values > 10ms to NutMicroDelay.

As NutDelay calls NutMicroDelay(), I modified NutDelay so that
NutMicroDelay is called in a loop and waits for 1ms each time.


I don't like this solution very much but I don't see something better
for the moment.

Any ideas are wellcome.

Best regards,

Ole

-- 

Thermotemp GmbH, Embedded-IT

Embedded Hard-/ Software and Open Source Development, 
Integration and Consulting

http://www.embedded-it.de

Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen - 
tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97

Hauptsitz - Hademarscher Weg 7 - 13503 Berlin
Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002
Geschäftsführer: Jörg Friedrichs, Ole Reinhardt
Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280 




More information about the En-Nut-Discussion mailing list