Author Topic: [SOLVED] STM32G491 EXTI Interrupt takes milliseconds  (Read 883 times)

0 Members and 1 Guest are viewing this topic.

Offline BreakingOhmsLawTopic starter

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: de
  • Certified solder fume addict
[SOLVED] STM32G491 EXTI Interrupt takes milliseconds
« on: November 14, 2024, 07:32:02 pm »
Hi everybody,

I made a board with an STM32G491KEU6, and I am facing a peculiar problem.
The external interrupt on Pin PA1 takes milliseconds (around 400k cycles @144MHz).

To test, I've made a completely empty project, and just configured two pins:
PA0 - EXTO GPIO with a PWM signal going in, rising and falling edge.
PB0 as an output, which also drives a LED.

Now, the only code i have added to the code generated by STM32CubeIDE is the ISR callback for that interrupt. Even the while loop in main() is completely empty.
Code: [Select]
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if(HAL_GPIO_ReadPin(PWM1_IN_GPIO_Port,PWM1_IN_Pin))
HAL_GPIO_WritePin(LED_RUN_GPIO_Port,LED_RUN_Pin, 1);
else
HAL_GPIO_WritePin(LED_RUN_GPIO_Port,LED_RUN_Pin, 0);

}
So basically, all the callback function does, is copy the PWM signal from PA0 to PB0.
If i probe the input and output, i see a delay which is utterly insane. So somehow, the core must be doing something else, because it should be less than 100 cycles. Pushing all registers onto the stack and doing some housekeeping, then call the ISR - that's it.


I'm hoping someone has the experience to know what's going on. I've been pulling my hair out for the last two days.
Things I've tried:
 - Changing the IRQ level. Makes no difference at all.
 - Cleared all other code. As mentioned, this happens even in a completely empty project with just the ISR.

What's going on? Is HAL doing me dirty again?


« Last Edit: November 14, 2024, 09:55:24 pm by BreakingOhmsLaw »
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 547
  • Country: sk
Re: STM32G491 EXTO Interrupt takes milliseconds
« Reply #1 on: November 14, 2024, 08:49:21 pm »
  What is"EXTO"? Did you mean EXTI0?

> should be less than 100 cycles.

Hardly so... because:

> Pushing all registers onto the stack and doing some housekeeping, then call the ISR - that's it.

Not, as you use Cube/HAL, which is rather bloated, and you are also using C and quite likely no optimization. Hundred of cycles under that circumstances is no exception.

400k is way too much, though.
Try just toggling the output pin in a loop, and post what you've observed.

JW
« Last Edit: November 14, 2024, 08:50:59 pm by wek »
 

Offline BreakingOhmsLawTopic starter

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: de
  • Certified solder fume addict
Re: STM32G491 EXTI Interrupt takes milliseconds
« Reply #2 on: November 14, 2024, 09:00:01 pm »
  What is"EXTO"? Did you mean EXTI0?

Typo. Fixed.

Try just toggling the output pin in a loop, and post what you've observed.
This works as expected.

I am suspecting this MCU has ESD damage. I will solder in in a replacement tomorrow.
 

Offline BreakingOhmsLawTopic starter

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: de
  • Certified solder fume addict
Re: STM32G491 EXTI Interrupt takes milliseconds
« Reply #3 on: November 14, 2024, 09:55:06 pm »
[SOLVED]
The MCU input was damaged. I suspect that somehow some charge still went into the input, eventually still triggering the input stage. Just with a big delay.
This had me chasing down the rabbit hole for two days.



 
The following users thanked this post: bingo600, SteveThackery


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf