cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 eternal interrupt not work without for loop delay.

parth kothiya
Senior

eternal interrupt routine works with some delay if i remove delay then it not work what is the reason how can i solve this?

*code work with some for loop delay.

void EXTI3_IRQHandler(void)
{
	/* USER CODE BEGIN EXTI3_IRQn 0 */
 
	for (int z = 0; z < 500; ++z);
 
	__HAL_TIM_SET_COMPARE(&htim3,TIM_CHANNEL_1,1000);
	auto_adjust_fd = FIRING_DELAY_MAX;
	HAL_NVIC_DisableIRQ(EXTI9_5_IRQn);
	
        /* USER CODE END EXTI3_IRQn 0 */
	HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3);
	/* USER CODE BEGIN EXTI3_IRQn 1 */
 
	/* USER CODE END EXTI3_IRQn 1 */
}

*code not work without for loop

void EXTI3_IRQHandler(void)
{
	/* USER CODE BEGIN EXTI3_IRQn 0 */
	__HAL_TIM_SET_COMPARE(&htim3,TIM_CHANNEL_1,1000);
	auto_adjust_fd = FIRING_DELAY_MAX;
	HAL_NVIC_DisableIRQ(EXTI9_5_IRQn);
	
	/* USER CODE END EXTI3_IRQn 0 */
	HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3);
	/* USER CODE BEGIN EXTI3_IRQn 1 */
 
	/* USER CODE END EXTI3_IRQn 1 */
}

4 REPLIES 4
JoniS
Senior

What do you expect it to do? And what does it it do? What does trigger the interrupt? When the interrupt is configured to happen?(rising, falling or both edges?)

It's pretty much impossible to trouble shoot with the information you did give.​

S.Ma
Principal

both are probably not best.

Are you connecting a push button there?

When you press, you will get trampoline style burst of pulses.

Search for debouncing. Key pressed doesn't need EXTI unless leaving low power mode.

Then, are you generating the EXTI on both edge or single edge?

To filter out false positive, you should check the pin level to double confirm.

And you should clear the EXTI pending PR flag before disabling interrupt. (the HAL does it normally within the handler)

So check the sequence and possibly ruggetize it.

my interrupt comming from mechanical relay.

i want run my code without delay how can i do it?

i want to run my code without for loop.

interupt is comming from mechanical relay