AnsweredAssumed Answered

failing to generate a random number using stm32f4xx_rng

Question asked by Hamid.Raiyan on Nov 10, 2016
Latest reply on Nov 14, 2016 by Hamid.Raiyan
Hi all,

I am using an stm32f4 micro to generate a random number.
I am using the RNG Driver from the stm32cubef4 library. I followed the examples but the micro is generating the same number over and over again.
here is a code snippet.


01.int main(void)
02.{
03.    HAL_Init();
04.    system_init();
05.    if(HAL_RNG_Init(&hRNG1) != HAL_OK)
06.    {
07.        DEBUG_PRINT("Random Number generation failed\r");
08.    }
09.    if(HAL_RNG_GenerateRandomNumber(&hRNG1,code_)==HAL_OK)
10.    {
11.            DEBUG_PRINT("RNG initiated\r");
12.    }
13.    else
14.    {
15.            DEBUG_PRINT("RNG failed\r");
16.    }
17.    DEBUG_PRINT("%" PRIu32 "\r",code_[0]);
18.}


Does anybody have a clue on what am missing. I am using the DEBUG_PRINT function to get the random value through the serial port.
Best Regards
Raiyan

Outcomes