Hi,
Im very new in embedded coding. I would like to generate a random number. Im using CCStudio and coding in C. Can I use the tipical rand() function ? Which library do i need. or where could i find information about this?
Thanks
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
Im very new in embedded coding. I would like to generate a random number. Im using CCStudio and coding in C. Can I use the tipical rand() function ? Which library do i need. or where could i find information about this?
Thanks
Thanks for posting this. I am sure other forum users will find it helpful.
If you need something faster, but not quite as random, you can use a LFSR (linear feedback shift register). Wikipedia has some C code that ports pretty much directly to the DSP.
If you need something more truly random (but much slower), you can sample a noisy signal with the ADC and take the lower order bits. This could be a way to seed your random number generator too.