STM32 GPT common IRQ callback problem Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
alexblack
Posts: 211
Joined: Mon Sep 24, 2012 3:52 pm
Location: Donetsk
Been thanked: 16 times
Contact:

STM32 GPT common IRQ callback problem  Topic is solved

Postby alexblack » Thu Jan 16, 2020 6:31 pm

Hi.
I using ChiobiOS from stable_19.1.x branch and STM32F303 MCU.
I was found the problem: the callback for gpt is called several times for GPT with common IRQ Vectors. For example, GPTD1 and GPTD16 has common irq at VectorA4:
File ../os/hal/ports/STM32/STM32F303xx/stm32_isr.c

Code: Select all

...
243 /**
244  * @brief   TIM1-UP, TIM16 interrupt handler.
245  *
246  * @isr
247  */
248 OSAL_IRQ_HANDLER(VectorA4) {
249
250   OSAL_IRQ_PROLOGUE();
251
252 #if HAL_USE_GPT
253 #if STM32_GPT_USE_TIM1
254   gpt_lld_serve_interrupt(&GPTD1);
255 #endif
256 #if STM32_GPT_USE_TIM16
257   gpt_lld_serve_interrupt(&GPTD16);
258 #endif
259 #endif
260 #if HAL_USE_ICU
261 #if STM32_ICU_USE_TIM1
262   icu_lld_serve_interrupt(&ICUD1);
263 #endif
264 #endif
265 #if HAL_USE_PWM
266 #if STM32_PWM_USE_TIM1
267   pwm_lld_serve_interrupt(&PWMD1);
268 #endif
269 #if STM32_PWM_USE_TIM16
270   pwm_lld_serve_interrupt(&PWMD16);
271 #endif
272 #endif
273
274   OSAL_IRQ_EPILOGUE();
275 }
...

I am using both GPTD1 and GPTD16 in my project. I setup GPTD1 in GPT_ONESHOT mode and wait for the callback. It is called first time in line 254 and second time in line 257.
Code for the gpt_lld_serve_interrupt is (file ../os/hal/ports/STM32/LLD/TIMv1/hal_gpt_lld.c):

Code: Select all

...
1117 /**
1118  * @brief   Shared IRQ handler.
1119  *
1120  * @param[in] gptp      pointer to a @p GPTDriver object
1121  *
1122  * @notapi
1123  */
1124 void gpt_lld_serve_interrupt(GPTDriver *gptp) {
1125
1126   gptp->tim->SR = 0;
1127   if (gptp->state == GPT_ONESHOT) {
1128     gptp->state = GPT_READY;                /* Back in GPT_READY state.     */
1129     gpt_lld_stop_timer(gptp);               /* Timer automatically stopped. */
1130   }
1131   gptp->config->callback(gptp);
1132 }
...

Callback is called in line 1131 without any condition.
It seems this problem is actual not only for GPT but ICU and PWM drivers too and not only for TIM1/TIM16.

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

Re: STM32 GPT common IRQ callback problem

Postby Giovanni » Thu Jan 16, 2020 7:01 pm

Hi,

Moving to bug reports.

Giovanni

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

Re: STM32 GPT common IRQ callback problem

Postby Giovanni » Fri Jan 17, 2020 9:58 am

Fixed (in trunk) as bug #1067.

Will backport later.

Giovanni

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

Re: STM32 GPT common IRQ callback problem

Postby Giovanni » Sat Jan 18, 2020 11:15 am

Backported to 19.1 and 18.2.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 0 guests