cancel
Showing results for 
Search instead for 
Did you mean: 

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.

GMart.7
Associate II

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.

10 REPLIES 10
haszom
Associate

Hi,

 

Never use HAL_Delay() in interrupt service routines. It causes halt / reset of uC. ISRs must be as short as possible. Just set a flag, start a timer, then when the timer overflows, clear the flag. Use Timers for delays.