2022-10-06 07:31 AM
the function MX_RNG_Init fails
HAL_RNG_Init returns t.o.:
while (HAL_IS_BIT_SET(hrng->Instance->CR, RNG_CR_CONDRST))
{
if ((HAL_GetTick() - tickstart) > RNG_TIMEOUT_VALUE)
{
/* New check to avoid false timeout detection in case of preemption */
if (HAL_IS_BIT_SET(hrng->Instance->CR, RNG_CR_CONDRST))
{
hrng->State = HAL_RNG_STATE_READY;
hrng->ErrorCode = HAL_RNG_ERROR_TIMEOUT;
return HAL_ERROR;
}
}
}
Solved! Go to Solution.
2022-10-06 09:14 AM
Try other examples..
STM32Cube_FW_H7_V1.10.0\Projects\STM32H735G-DK\Examples\RNG\RNG_MultiRNG\Src\stm32h7xx_hal_msp.c
/**
* @brief RNG MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* @param hrng: RNG handle pointer
* @retval None
*/
void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
RCC_OscInitStruct.PLL.PLLState= RCC_PLL_NONE;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct))
{
/* Initialization Error */
while(1);
}
/*Select HSI48 output as RNG clock source */
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RNG;
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_HSI48;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct))
{
/* Initialization Error */
while(1);
}
/* RNG Peripheral clock enable */
__HAL_RCC_RNG_CLK_ENABLE();
}
2022-10-06 07:35 AM
Does it need a PLL/CLK running? Are all the registers in the RND, HASH, CRYP zero? Do the clock enables stick low?
2022-10-06 07:52 AM
I am using the code genereted by cubemx:
int main(void)
{
HAL_Init() ;
SystemClock_Config() ;
PeriphCommonClock_Config() ;
....
MX_RNG_Init() ;
...
I think that pll and clock are running
The funnction HAL_RNG_MspInit enables HSI48, so also this clock should be ok
Beginning:
after msp init:
here the error:
2022-10-06 09:14 AM
Try other examples..
STM32Cube_FW_H7_V1.10.0\Projects\STM32H735G-DK\Examples\RNG\RNG_MultiRNG\Src\stm32h7xx_hal_msp.c
/**
* @brief RNG MSP Initialization
* This function configures the hardware resources used in this example:
* - Peripheral's clock enable
* @param hrng: RNG handle pointer
* @retval None
*/
void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
RCC_OscInitStruct.PLL.PLLState= RCC_PLL_NONE;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct))
{
/* Initialization Error */
while(1);
}
/*Select HSI48 output as RNG clock source */
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RNG;
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_HSI48;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct))
{
/* Initialization Error */
while(1);
}
/* RNG Peripheral clock enable */
__HAL_RCC_RNG_CLK_ENABLE();
}