2025-06-20 9:56 AM
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.
Solved! Go to Solution.
2025-06-25 7:41 AM
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
2025-06-25 7:41 AM
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
2025-06-25 7:50 AM - edited 2025-06-25 7:52 AM
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.