Closed jlswbs closed 6 years ago
rand() http://www.cplusplus.com/reference/cstdlib/rand/ is a pseudorandom number generator, and will produce the same sequence by design.
There is no Arduino API for true random numbers, but the STM32 API is pretty short:
//Initialize once:
__HAL_RCC_RNG_CLK_ENABLE();
RNG_HandleTypeDef handle = {0};
handle.Instance = RNG;
HAL_RNG_Init(&handle);
//Get:
uint32_t random = HAL_RNG_GetRandomNumber(&handle )
Many thanks code working great.
STM32F7 TRNG not working rand() or random() produce same sequence after reset