Random Number Generation

Universal Programmable Converter for CAN FD and CAN
Post Reply
Posts: 1
Joined: Mon 6. Dec 2021, 04:07

Random Number Generation

Post by rworsle » Mon 6. Dec 2021, 04:17

I am looking into implementing random number generation on my PCAN-Router FD hardware. As I understand it, there is no TRNG built into the microcontroller. I do not need it to be a perfect solution, just demonstrably better than PRNG. What is the best way to go about doing this? I have a few ideas:
  • Derive some value from timestamps using the systime module and seed a PRNG.
  • Read noise (or potentially attach some noise) from a digital input pin as a bitstream and use to seed a PRNG.
  • Generate some TRNG value at compile time on my hardware, and use it to seed a PRNG
  • Make some use of the EEPROM in combination with a method above?
Any ideas or help would be much appreciated.

User avatar
Hardware Development
Hardware Development
Posts: 51
Joined: Wed 22. Sep 2010, 21:38

Re: Random Number Generation

Post by G.Bohlen » Tue 7. Dec 2021, 16:15


we have not implemented a TRNG, so we cannot give you an advice that is better than the ideas you already suggested.

I think the source for a seed depends on your system:
If there is no external event, the systime module would always create the same timer value. (time from module start until your algorithm ready the current time)
Another option to create a seed: The module has got a digital input. You could connect a RC-Oscillator to the digital input, and an NTC could be used to change the frequency slightly with the temperature. The firmware reads the digital input to get the required number of bits. Oscillator frequency should be higher than reading speed of the input.

Post Reply