cancel
Showing results for 
Search instead for 
Did you mean: 

RNG does not work after waking up from the stop mode

Evgeny M
Associate II

Hello,

My MCU is STM32L053R8

I use freeRTOS project generated by CubeMX.

The problem is happening only  when I enable tickless sleep. I get only one correct reading, which is probably generated right after MX_RNG_Init. Then after the sleep, I always get `LL_RNG_IsActiveFlag_CECS(RNG) == 1`

I call `LL_RNG_Enable(RNG)` and `LL_RNG_Disable(RNG)` before and after `LL_RNG_ReadRandData32()`

 

It looks like HSI does not start after the sleep. In the documentation I found that it is indeed deactivated if there is no periphery connected which can run in stop mode. But I did not find, how it should be started properly.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

HSI can be enabled with:

__HAL_RCC_HSI_ENABLE();
If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

HSI can be enabled with:

__HAL_RCC_HSI_ENABLE();
If you feel a post has answered your question, please click "Accept as Solution".

@TDK thanks for the hint. It was a bit more complicated. The configuration of PLL has to be also done again:

	// make sure HSI is on
	if (!LL_RCC_HSI_IsReady()) {
		LL_RCC_HSI_Enable();

		while(LL_RCC_HSI_IsReady() != 1)
		{
			
		}
		LL_RCC_HSI_SetCalibTrimming(16);
	}

	if (!LL_RCC_PLL_IsReady()) {
		LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLL_MUL_3, LL_RCC_PLL_DIV_2);
		LL_RCC_PLL_Enable();

		while(LL_RCC_PLL_IsReady() != 1)
		{
			
		}
	}

Now it works, thanks again!