Solved
failing to generate a random number using stm32f4xx_rng
Posted on November 10, 2016 at 17:34
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.
int
main(
void
)
{
HAL_Init();
system_init();
if
(HAL_RNG_Init(&hRNG1) != HAL_OK)
{
DEBUG_PRINT(
''Random Number generation failed\r''
);
}
if
(HAL_RNG_GenerateRandomNumber(&hRNG1,code_)==HAL_OK)
{
DEBUG_PRINT(
''RNG initiated\r''
);
}
else
{
DEBUG_PRINT(
''RNG failed\r''
);
}
DEBUG_PRINT(
''%''
PRIu32
''\r''
,code_[0]);
}
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
#no-hablo-hal #stm32f407-random-number-generate