I have a problem with the interrupt callback. The interrupt event is correctly detected but when the code enter into the callback function it excecute just the first line of the code wrot between the curly brackets.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 5:53 AM
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if(GPIO_Pin == LVMS_DETECT_Pin)
{
HAL_GPIO_WritePin(AMS_LED_GPIO_Port, AMS_LED_Pin, GPIO_PIN_SET);
HAL_Delay(2000);
HAL_GPIO_WritePin(AMS_LED_GPIO_Port, AMS_LED_Pin, GPIO_PIN_RESET);
}
}
When the trigger event happent to the LVMS_DETECT_Pin, the code enter into the callback and turn on the LED without turn it off after 2 seconds.
It is not the first time I noticed this behaviour, it jus execute the first line of the code.
I'm working on Nucleo F401RE.
Solved! Go to Solution.
- Labels:
-
GPIO-EXTI
-
Interrupt
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 8:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 6:38 AM
Probably your SysTick interrupt is same/lower priority as your EXTI interrupt, so the code just stalls there during HAL_Delay.
Having a 2s blocking delay in an interrupt isn't a good practice.
In any case, debug your code. Run it, wait for the bad event to happen, hit pause, and see where the code is at.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 7:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 7:10 AM
The goal is to turn on the LED for 2 seconds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 7:11 AM
Looks like exactly what I guessed, right?. Make SysTick priority higher (numerically lower) than the EXTI priority.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 7:37 AM
The Preemption Priority of Time Base: SysTick Timer was setted to 15 (default) meanwhile all the others to 0.
Now I set SysTick Timer Preemption Priority to 0 and the EXTI to 1.
This solved the problem but i noticed that the LED remain turned up for something more than 3 second insted of 2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 7:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 8:22 AM
The pin is normally low (connected to GND) and internally pulled down. To generate the event I connect it to 3V3 and then again to GND.
At the end, is correct to say that the Sys Tick Timer must have always the higher priority with respect of the others interrupt?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 8:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-27 8:37 AM
Thank you.
