I have had some odd problems with a PR I am attempting to finalize:
cpu/atmega_common: RTT and RTC support
When working with the real-time timers, there are a number of times that
you have to wait a few of the slow clock cycles to go by. I am using
xtimer_usleep to sleep the thread temporarily. But! xtimer causes the
code I am using to hang. Debugging it is difficult, because anything
sending debug messages over UART causes the problems to disappear!
I have been editing and running various numbers:
xtimer_usleep(8); 8 and bigger fail
xtimer_usleep(7); 7 and smaller work
Hi Matthew,
My guess is that you are running that function with interrupts
disabled, which blocks the xtimer timeouts. The reason that short
sleeps work in xtimer is that internally that is handled as a spin,
while longer timeouts are handled by setting a hardware timer target.
You can try using xtimer_spin instead of usleep, but chances are your
PR will not be merged if you are using xtimer_spin with long timeouts.
xtimer_spin is a busy wait which should be used only for very short
periods, since it will be obstructing other parts of the system from
running while you are spinning.