Hello all,

I have had some odd problems with a PR I am attempting to finalize:

cpu/atmega_common: RTT and RTC support
https://github.com/RIOT-OS/RIOT/pull/8842

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

Bigger numbers make them fail!

Here is a snippet of the offending code:

> void __asynch_wait(uint8_t num_cycles) {
>     /* Wait until all busy flags clear */
>     while( ASSR & ((1 << TCN2UB) | (1 << OCR2AUB) | (1 << OCR2BUB)
>                  | (1 << TCR2AUB) | (1 << TCR2BUB)) ) {
> #ifdef MODULE_XTIMER
>         /* Sleep for num_cycles RTC cycles */
>         xtimer_usleep(num_cycles * 35 * US_PER_MS);
> #else
>         /* Suppress unused parameter warning */
>         (void)num_cycles;
> 
>         thread_yield();
> #endif
>     }
> }

Anyone have any ideas on what is going on?

Sincerely,
Matthew
_______________________________________________
devel mailing list
devel@riot-os.org
https://lists.riot-os.org/mailman/listinfo/devel

Reply via email to