Wednesday, January 31, 2024

Random number generation in STM32F407VET6

 For RNG generation in STM32F407VET6 board follow below steps:

Configuration:

1. In Pinout and configuration, in security > RNG Mode & Configuration, Mode should be activated.

2. With change in point 1, tool will prompt to change clock configuration. Use automatic clock configuration fix given by tool to adjust the clock values.


Manual Code: 

In main.c file, we need to call function to get random number as shown below:

/* USER CODE BEGIN WHILE */


while (1)

{

HAL_RNG_GetRandomNumber(&hrng);

HAL_Delay(200);

/* USER CODE END WHILE */


/* USER CODE BEGIN 3 */

}


Variable hrng is already declared when code was generated. 


RNG result will be as shown in below image:




No comments:

Post a Comment