cancel
Showing results for 
Search instead for 
Did you mean: 

STM32N6 Inference LL_ATON_OSAL_WFE delaying PWM/timers

neil1106
Associate II

In the Cube AI documentation (stneuralart_api_and_stack.html) there is this code block 

/* Wait for next event */
if (ll_aton_rt_ret == LL_ATON_RT_WFE)
{ /*** subject to change to fit also user code requirements ***/
   LL_ATON_OSAL_WFE();
}

to wait for an event while an epoch is running. I looked into what WFE means and it turns out that it puts the CPU in a low power state and crucially gates all the clocks. The effect of this is that the 4 timers I have running generating PWMs all start getting delayed. I can see on the scope the period increasing up to 4-5x.

Is there another way to wait for the epoch to finish without going into a low power state? I am not currently using an RTOS but will switch to one later.

1 ACCEPTED SOLUTION

Accepted Solutions
David SIORPAES
ST Employee

Hello,

Seems like the timer(s) you are using for PWM generation are disabled when entering in low power mode. This is default behavior. 

You can avoid this using __HAL_RCC_xxx_CLK_SLEEP_ENABLE macros, e.g.: for TIM2:

 

__HAL_RCC_TIM2_CLK_SLEEP_ENABLE()

 

 

If not concerned about power consumption, you can substitute LL_ATON_OSAL_WFE() with a __NOP() to avoid entering low power altogether.

Hope this helps,

David

 

View solution in original post

2 REPLIES 2
David SIORPAES
ST Employee

Hello,

Seems like the timer(s) you are using for PWM generation are disabled when entering in low power mode. This is default behavior. 

You can avoid this using __HAL_RCC_xxx_CLK_SLEEP_ENABLE macros, e.g.: for TIM2:

 

__HAL_RCC_TIM2_CLK_SLEEP_ENABLE()

 

 

If not concerned about power consumption, you can substitute LL_ATON_OSAL_WFE() with a __NOP() to avoid entering low power altogether.

Hope this helps,

David

 

neil1106
Associate II

Thanks that is exactly what I needed, enabling the clocks in sleep. The whole device is battery powered but the clocks are driving the CCD camera which runs constantly.