diff --git a/hal/targets/hal/TARGET_STM/TARGET_STM32L4/entropy_hardware_poll.c b/hal/targets/hal/TARGET_STM/TARGET_STM32L4/entropy_hardware_poll.c index cdae897347..e7a880f44b 100644 --- a/hal/targets/hal/TARGET_STM/TARGET_STM32L4/entropy_hardware_poll.c +++ b/hal/targets/hal/TARGET_STM/TARGET_STM32L4/entropy_hardware_poll.c @@ -48,6 +48,12 @@ int mbedtls_hardware_poll( void *data, unsigned char *output, size_t len, size_t { int ret; ((void) data); + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; + + /*Select PLLQ output as RNG clock source */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RNG; + PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_PLL; + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); /* RNG Peripheral clock enable */ __HAL_RCC_RNG_CLK_ENABLE(); @@ -73,7 +79,6 @@ int mbedtls_hardware_poll( void *data, unsigned char *output, size_t len, size_t /* RNG Peripheral clock disable - assume we're the only users of RNG */ __HAL_RCC_RNG_CLK_DISABLE(); - return( ret ); }