I don't think they contain a random number generator, so you'll need to
use a pseudo-random generator and seed it from some unpredictable
source. The core cycle counter is somewhat predictable, perhaps you have
some other inputs, or user interactions you can use?

You can save the seed to the flash and then at startup read the saved seed from flash. This way you will have new random numbers after each power off/on.

A very simple and crude RNG is to perform a multiplication and addition, but truncating the high order bits. Not the best but it usually yields a fairly high Chi-square statistic. Not reccomended for gaming equipment.

The original Microsoft 4K Basic circa 1975 used this for the RND() function, except it was floating point.

The F1 series doesn't have hardware RNG. The F2/F4 does have a 32 bit RNG unit.

After a few iterations the seed will overflow, which is what you want. Be sure to multiply by an odd number so the low order bit varies. You can improve on it by extracting bits in the middle of seed for the actual random number, since the low order bit is predictable. Intitalize the seed from some real time event at startup, like the time (to the microsecond) to the first operator button press.
Jack Peacock

my 'standard' means of generating a random number is to have a free running timer and reading it when some external event (keypress, serial byte arraving, ...) happens

my favorite episode re the above (assuming pseudorandom is random) is this

J1708 specifies that, in case of a collision, a random delay is to be inserted before attempting the transmission again. Two J1708 devices used the same so called random routine and kept colliding for a whole weekend before I stopped them.

This way you will have new random numbers after each power off/on.

Yes I have some inputs and I can use the HMI !

But how implement this function in the software? what I need to do it?

The original Microsoft 4K Basic circa 1975 used this for the RND() function, except it was floating point.

The F1 series doesn't have hardware RNG. The F2/F4 does have a 32 bit RNG unit.

uint32 seed

seed = seed + 271828192

seed = seed * 314159

After a few iterations the seed will overflow, which is what you want. Be sure to multiply by an odd number so the low order bit varies. You can improve on it by extracting bits in the middle of seed for the actual random number, since the low order bit is predictable. Intitalize the seed from some real time event at startup, like the time (to the microsecond) to the first operator button press.

Jack Peacock

Erik

http://en.wikipedia.org/wiki/Linear_feedback_shift_register

pseudorandom randomJ1708 specifies that, in case of a collision, a random delay is to be inserted before attempting the transmission again. Two J1708 devices used the same

so calledrandom routine and kept colliding for a whole weekend before I stopped them.