2018-03-07 12:15 AM
Hi,
I am trying to use external interrupt. I connect the PB3 to external output and I want to detect ricing voltage.I Using microcontroller STM32L476RG on Nucleo-L476RG.Moreover,
I found the example that explained how use external interrupts on
. In my code I changed to PB3.
But Something wrong.This is my small code.
May anyone can detect the problem?I using Microcfor ARM Compiler.
static int SlowSpeedFlag = 0;
void external_interrupt() iv IVT_INT_EXTI3 ics ICS_AUTO
{ if((EXTI_PR1 & PR3) != 0) //Check if PE11 has trigger the interrupt { EXTI_PR1 |= PR3; SlowSpeedFlag = 1; }}//-----------------------------------------------------------------------------------//void main() { GPIO_Digital_Output(&GPIOA_BASE, _GPIO_PINMASK_5); //Led2 on Nucleo Board GPIOA_ODR = 0; GPIO_Digital_Input(&GPIOC_IDR, _GPIO_PINMASK_13); //Button On Nucleo Board GPIOC_ODR = 0; EnableInterrupts(); //Enable global interrupt //RCC_AHB2ENR.B1 = 1; GPIOBEN_bit = 1; GPIO_Config(&GPIOB_BASE,_GPIO_PINMASK_3, _GPIO_CFG_MODE_INPUT | _GPIO_CFG_PULL_DOWN); NVIC_IntEnable(IVT_INT_EXTI3); //Enable NVIC interface //RCC_AHB2ENR.B0 = 1; SYSCFGEN_bit = 1; //SYSCFG_EXTICR1.B2 = 1; EXTI02_bit = 1; //SYSCFG_EXTICR1.B1 = 0; EXTI01_bit = 0; //SYSCFG_EXTICR1.B0 = 0; EXTI00_bit = 0;EXTI_RTSR1.TR3 = 1; //Rising trigger enabled (for Event and Interrupt) for input line
EXTI_IMR1.MR3 = 1; //Interrupt request from Line x is not masked EXTI_EMR1.B3 = 1; //Event request from line x is not masked while(1) { if(SlowSpeedFlag == 0) Delay_ms(500); else Delay_ms(100); //if button pressed, the speed of led blinking will changed if(IDR13_GPIOC_IDR_bit == 0) { if(SlowSpeedFlag == 0) SlowSpeedFlag = 1; else if(SlowSpeedFlag == 1) SlowSpeedFlag = 0; while(IDR13_GPIOC_IDR_bit==0); }GPIOA_ODR.B5 = !GPIOA_ODR.B5; //Togle Led2 on Nucleo Board
}
}#interrput2018-03-07 02:41 AM
Read out in debugger, and check/post the relevant GPIO/SYSCFG/EXTI registers.
Try if you've set correctly the interrupt, by triggering the EXTI by writing to respective bit of EXTI_SWIER1.
JW
2018-03-07 03:38 AM
I using Microcfor ARM Compiler.
You mean
MicroC for ARM -
this:
https://www.mikroe.com/mikroc-arm
?What does all this mean:
void external_interrupt() iv IVT_INT_EXTI3 ics ICS_AUTO
Are you sure that's correct?