srand() freezes microcontroller process?
I am using a PIC24FJ256GA606 and I am having issues with stdlib's srand(). Can calling srand() somehow cause the microcontroller to freeze?
I have a function that does the following:
1. Use the current timestamp (unsigned int) to call srand.
2. Return rand().
I later found out that I am not supposed to call srand repeatedly because that will reduce the randomness. However, I don't think that should cause the microcontroller to malfunction. For my case, the function returns successfully for the first few tries. However, later on when it calls srand(timestamp), my control's heartbeat LED freezes and my timer interrupt stops triggering.
I also created a new PIC24FJ256GA606 project just to test srand and rand on their own, and they turn out to work fine. At this point, I have a feeling that something else is wrong with my software/hardware, but I can't figure it out. Do you guys know what the cause might be?
Thank you for your time.
post edited by olochua - 2018/08/17 13:39:23