cancel
Showing results for 
Search instead for 
Did you mean: 

Genrating a random number with st7

christianhoermann9
Associate II
Posted on June 12, 2003 at 08:09

Genrating a random number with st7

3 REPLIES 3
christianhoermann9
Associate II
Posted on June 06, 2003 at 08:04

In order to realise an authentification algorithm in our software we need to generate a random number. Unfortunately it is very hard to find solutions for this.

So I would like to ask the other users if they can give me some hints (URL, code samples, ...) where I can get informed about this. Also reports about your experiences concerning the generation of random numbers would be helpful.

I would like to thank you in advance for your effort.

cu Starbuck

stephanie
Associate II
Posted on June 11, 2003 at 06:44

You can read a value in the RAM or read the value of a timer counter (free running).

christianhoermann9
Associate II
Posted on June 12, 2003 at 08:09

thank you for the proposals. Unfortunately I did not think that I can use them:

RAM:

Also the RAM Values have certain predefined states by its hardware. Thus I think the values of a certain µC are every time the same.

free running timer:

The problem with a free running timer is that I need the random value almost directly after a reset of the µC. The timing value is more or less predictable - not random.

I found for myself a solution which could be good enough:

Use the 10 bit A/D converter and make as much conversions as the length of the random number in bits. For the random number use just the LSB of every conversion.

The last bit of the A/D conversion should toggle. Before you would be able to use this method you have to check the hardware if the voltage applied to the controller is ''poorly'' enough.

If this random value is not good enough for you, you would be able to use this value as a starting value for a linear congruent generator e.g. after D. Lehmer.