10 years, 4 months ago.

Run RTOS thread every 0.5ms

I have a control function that needs to run every 0.5ms, but the shortest a Thread can wait on the official RTOS library is 1ms. What's the best way to accomplish this? Can Tickers co-exist peacefully with the RTOS? Could I use a Ticker to signal a Thread? Any advise would be appreciated, thanks!

Question relating to:

1 Answer

10 years, 4 months ago.

Tickers can co-exist with RTOS. You do need to take into account that Ticker functions are called in interrupt context, and there are some limitations of what is allowed to be done in interrupt context in RTOS.

Signaling a thread using a Ticker should work.

Ok, I tried signalling a Thread with a Ticker, but I found the faster I set the Ticker to run, the less Threads I could create before the system locked up. Any idea as to why this would be happening? All of the Threads were just toggling LEDs at this point, so there's negligible memory usage.

EDIT: I can confirm toggling the LED every 0.5ms WITH the Ticker works with 8 threads going though...

posted by Neil Thiessen 15 Nov 2013