Wrong tick-timing with STOP0 mode #19
-
Hi! I already tried to change configLPTIM_ENABLE_PRECISION and configTICK_USES_LSI. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
So the OS is working completely as expected but the HAL delay (which to my knowledge should not be used with FreeRTOS defines and best not combined with an OS anyway) breaks? |
Beta Was this translation helpful? Give feedback.
-
There are two different system ticks. The FreeRTOS tick and the HAL tick. They are independent and concurrent. If you are using lptimTick.c, the FreeRTOS tick is provided by an LPTIM timer. If you are not using lptimTick.c, the FreeRTOS tick is provided by the SysTick timer. The FreeRTOS tick rate is set by The HAL tick is provided by a timer of your choice. In CubeMX, see Pinout & Configuration -> System Core -> SYS -> Timebase Source. The HAL configures the selected timer to provide a 1000 Hz tick rate. When you call It appears the issue you are facing is the HAL tick changes its frequency after you use stop mode. That's not surprising. Waking from stop causes the system clock configuration to change. In the case of STM32G4, the HSI16 is selected. Your software is responsible to restore the desired clock configuration after waking from stop mode, and your software is (apparently) not doing that. See ulp.c for an example of restoring the clock configuration after stop mode. Note that file is specific to STM32L4. |
Beta Was this translation helpful? Give feedback.
There are two different system ticks. The FreeRTOS tick and the HAL tick. They are independent and concurrent.
If you are using lptimTick.c, the FreeRTOS tick is provided by an LPTIM timer. If you are not using lptimTick.c, the FreeRTOS tick is provided by the SysTick timer. The FreeRTOS tick rate is set by
configTICK_RATE_HZ
.The HAL tick is provided by a timer of your choice. In CubeMX, see Pinout & Configuration -> System Core -> SYS -> Timebase Source. The HAL configures the selected timer to provide a 1000 Hz tick rate.
When you call
HAL_Delay()
, you are delaying based on the HAL tick. These delays are busy-wait delays -- not OS friendly and not power friendly. When you callosDelay()
…