random number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-15 6:42 AM
Hi,
I use STM32F107. I have to generate a random number. I don't see how to do it :\ Anybody for help ? #random-number #rng- Labels:
-
Cryptography
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-15 7:04 AM
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?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-15 7:54 AM
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-06-07 5:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-06-07 6:51 AM
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. 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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-06-07 7:33 AM
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
Erik- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-06-08 2:01 AM
http://en.wikipedia.org/wiki/List_of_random_number_generators
I like these:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-06-08 8:09 AM
and, again we see the male cow manure of calling pseudorandom random
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-06-08 11:15 AM
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-12-15 9:12 PM
This code uses hardware on the stm32f103 to generate true random numbers without having to add any new hardware: http://www.gniibe.org/memo/development/gnuk/rng/pqrng
