cancel
Showing results for 
Search instead for 
Did you mean: 

my stm nucleo external interrupt button keeps getting inside the handler

mnabi.4
Associate

main.c

#include "Board_LED.h"
#include "stm32f401xe.h"
void PIN_CONFG();
void PIN_EN();
void clear();
 
 
	
 
int main(void){
	LED_Initialize();
	PIN_CONFG(13);
	PIN_EN(13);
	
	LED_On(0);
	while(1){
		
		
	}
	
	return 0 ;
}
void delay(void){
int i ; 
for(i=0;i<5000000;i++){
 
}	
}
 
void EXTI15_10_IRQHandler(void){
	clear(13);
	LED_On(0);
	delay();
	LED_Off(0);
	delay();
	
}
 
 

my interrupt functions

#include "stm32f401xe.h"
 
 
 
void PIN_CONFG (uint16_t pin){
EXTI ->FTSR |= (1<<pin);	
	
	
}
 
void PIN_EN (uint16_t pin){
EXTI ->IMR |= (1<<pin);	
NVIC_EnableIRQ(40);
}
void clear (uint16_t pin){
if (EXTI->PR & (1<<pin)){
 
EXTI->PR |=(1<<pin);
}	
	
 
 
}

3 REPLIES 3
Uwe Bonnes
Principal III

Argh: delay(); inside an interrupt handler! Learn the basics! And formulate a clear question.

mnabi.4
Associate

that was for debugging sorry for posting it in this shape :"

the pending register bit keeps getting one without me pushing the button and doesn't clear

ignore the delay function please i have the problem with or without it

Piranha
Chief II

EXTI15_10_IRQHandler() is interrupt routine for EXTI interrupts 10-15. Maybe You are enabling some other of them also? Look at EXTI->PR register (before clearing) for which of these interrupts are actually triggered.