Skip to main content
jagauthier
Associate III
August 20, 2021
Question

HAL_Delay and interrupts?

Hello,

If I am using an external interrupt on a GPIO pin HAL_Delay() in my program's main() does not work.

 while (1)
 {
	 serprintf("Before HAL Delay");
	 HAL_Delay(500);
	 serprintf("After HAL Delay");
 
 }

 "After HAL Delay" never happens. I've read a few threads that indicate that you should not use HAL_Delay() in the interrupt function, which is fine. I am not doing that.

If I disable the interrupt, the main loop works as expected.

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
August 20, 2021

>>If I disable the interrupt, the main loop works as expected.

Suggests that the EXTI IRQ handler doesn't satisfactorily clear the interrupting state, and it continuously re-enters.

Or something else going on in your unspecified STM32 system more generally.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
jagauthier
Associate III
August 20, 2021
void EXTI4_IRQHandler(void)
{
 /* USER CODE BEGIN EXTI4_IRQn 0 */
 VL53L3CX_SimpleRanging_Int();
 /* USER CODE END EXTI4_IRQn 0 */
 HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_4);
 /* USER CODE BEGIN EXTI4_IRQn 1 */
 
 /* USER CODE END EXTI4_IRQn 1 */
}

Should I be doing more than the this? This function is generated code from CubeMX.

Tesla DeLorean
Guru
August 20, 2021

It's all very superficial.

Perhaps have a count so you can see how often it passes. If it enters several hundred thousand times a second then nothing else will likely run.

The tail-chaining methods will basically block execution of foreground code. You basically get an "interrupt storm", and saturate the processor.

You should check the reporting in the NVIC/EXTI to ensure nothing is pending as you leave.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..