this is a re-hash of this topic, it seems like on my MCU the fix from there (that is upstream) was not enough.
Disabling the timer before updating its registers fixes the bug again for me:
Code: Select all
diff --git a/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c b/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c
index f7c449edb..d6433a3b1 100644
--- a/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c
+++ b/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c
@@ -1121,6 +1121,7 @@ void gpt_lld_stop_timer(GPTDriver *gptp) {
*/
void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval) {
+ gptp->tim->CR1 = STM32_TIM_CR1_UDIS;
gptp->tim->ARR = (uint32_t)(interval - 1U); /* Time constant. */
gptp->tim->EGR = STM32_TIM_EGR_UG; /* Update event. */
gptp->tim->SR = 0; /* Clear pending IRQs. */