UIF not cleared after #1067 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times
Contact:

UIF not cleared after #1067  Topic is solved

Postby wurstnase » Tue Jan 21, 2020 2:12 pm

Hi,

shouldn't be the UIF cleared in the interrupt?

The patch will remove the

Code: Select all

gptp->tim->SR = 0;

I think at least we need a

Code: Select all

gptp->tim->SR &= ~STM32_TIM_SR_UIF;


Code: Select all

@@ -1122,13 +1122,13 @@ void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval) {
  * @notapi
  */
 void gpt_lld_serve_interrupt(GPTDriver *gptp) {
+  uint32_t sr;
 
-  gptp->tim->SR = 0;
-  if (gptp->state == GPT_ONESHOT) {
-    gptp->state = GPT_READY;                /* Back in GPT_READY state.     */
-    gpt_lld_stop_timer(gptp);               /* Timer automatically stopped. */
+  sr  = gptp->tim->SR;
+  sr &= gptp->tim->DIER & STM32_TIM_DIER_IRQ_MASK;
+  if ((sr & STM32_TIM_SR_UIF) != 0) {
+    _gpt_isr_invoke_cb(gptp);
   }
-  gptp->config->callback(gptp);
 }
\o/ Nico

User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times
Contact:

Re: UIF not cleared after #1067

Postby wurstnase » Tue Jan 21, 2020 2:41 pm

My patch look like this:

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 b9e0a3756..88b7632ea 100644
--- a/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c
+++ b/os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c
@@ -1127,6 +1127,7 @@ void gpt_lld_serve_interrupt(GPTDriver *gptp) {
   sr  = gptp->tim->SR;
   sr &= gptp->tim->DIER & STM32_TIM_DIER_IRQ_MASK;
   if ((sr & STM32_TIM_SR_UIF) != 0) {
+    gptp->tim->SR &= ~STM32_TIM_SR_UIF;
     _gpt_isr_invoke_cb(gptp);
   }
 }
\o/ Nico

User avatar
Giovanni
Site Admin
Posts: 13012
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 745 times
Been thanked: 621 times
Contact:

Re: UIF not cleared after #1067

Postby Giovanni » Tue Jan 21, 2020 3:27 pm

It is the same code used in PWM and ICU but forgot to copy one line...

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 4 guests