Blinky DEMO: Generate random numbers

Hello everyone,

I’m pretty new in FreeRTOS and I’m currently working on customizing the scheduler in the FreeRTOS Blinky Demo. I’ve successfully implemented a lottery scheduling algorithm to replace the default one. However, I’m facing a challenge with generating random numbers within the scheduler.

As I cannot use time(NULL) inside srand(time(NULL)) for use the rand function from the library time.h due to constraints (Calling prvGetRegistersFromStack() from fault handler), I’m looking for alternative methods to generate random numbers. Does anyone have any suggestions or ideas on how to accomplish this within the Demo I am using?

Your insights and suggestions would be greatly appreciated. Thank you!

Depending on your toolchain including C-library calling time with NULL might be simply a bug. Many MCUs have a RNG (random number generator) HW peripheral you could use.