cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H735AGI6 RNG non working

mzenn.280
Associate II

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;

   }

  }

 }

1 ACCEPTED SOLUTION

Accepted Solutions

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();
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

Does it need a PLL/CLK running? Are all the registers in the RND, HASH, CRYP zero? Do the clock enables stick low?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mzenn.280
Associate II

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:

0693W00000UnW6TQAV.pngafter msp init:

0693W00000UnW7MQAV.png 

here the error:

0693W00000UnW8ZQAV.png

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();
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..