10 years, 8 months ago.

mbed Timer error?

Hi. I have tested this on nucleo F302. Overflow should be at 0x2000 = 8192 milliseconds. Actually the program runs 16 seconds. What is wrong? (Actually the purpose of the prog is testing internal overflow of Timer. This does not matter for my actual question. Don't get confused.)

Question relating to:

1 Answer

10 years, 8 months ago.

read_ms() & 0x2000 will give you 0 for all values from 0 to 0x1fff and then 0x2000 for all values from 0x2000 up to 0x3fff

So your while (LastMillis <= Millis) loop will run until the timer is 0x4000, about 16 seconds.

For the operation you want I'm guessing you need

Millis = t.read_ms() & 0x1FFF;

Excellent. Thanks.

posted by Eduardo de Mier 30 Mar 2015