2022-04-27 05: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.
2024-08-21 05:40 AM - edited 2024-08-21 05:43 AM
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.