This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How do I: Random Numbers, Store Value Permanently with Tiva C ?

Other Parts Discussed in Thread: TM4C123GH6PM

I have a Tiva C TM4C123GXL (TM4C123GH6PM) and would like to display random data during every boot or soft boot.

My problem is that using rand() with time() to produce a random number, it always produces the same result:

int genrand(int min,int max){
	// Generate a random number
	srand(time(NULL));
	return rand()%(max-min)+min;
}

I'm guessing this is because the amount of time that elapses between start up time and when my function is called is always the same.

Is there a better way to generate random numbers? Or could I save elapsed time to EEPROM or flash so that it persists after every soft boot?

Thanks.