How to generate a random number on 9215.

I am trying to generate a random number in the 0-255 range. I am using srand and rand. In order to generate the seed with srand I am using a value taken from the ticks passed since board was on.

If I run my program using JTag it will work correctly. This means that every time I run it, I will get a different number.

In the other hand, when I download the code to the board and run it without JTAG, I am getting the same result on every run. I check the ticks passed and I am using different numbers to create the seed on every run.

Any solution to generate a random number each time?

Thanks,

Hello

There are a couple of things that come to mind, they could also be used in combination.

  1. when calling srand pass it as a parameter the current system time.

  2. There is an undocumented call entitled GetFullEth0Stats. it is located in \bsp\devices\common\ethernet
    aeth.c. YOU pass it a pointer to an ETH_STATS structure (see \h\efe_def.h). An ETH_STATS structure contains all sorts of juicy ethernet statistics. You could call this and add a couple of the statistics together and use that as a param in calling srand.

  3. Pass the system time added to a sum of a couple of the ethernet stats as described above to srand.

see if that/those help.