It is currently 20 Oct 2018 09:44

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: External Interrupt
PostPosted: 07 Mar 2018 08:56 
Offline

Joined: 07 Mar 2018 08:37
Posts: 2
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 https://www.youtube.com/watch?v=uKwD3JuRWeA. In my code I changed to PB3.
But Something wrong.

This is my small code.
May anyone can detect the problem?



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

}
}


Top
 Profile  
 
 Post subject: Re: External Interrupt
PostPosted: 12 Mar 2018 09:50 
Offline
mikroElektronika team
User avatar

Joined: 25 Jan 2008 09:56
Posts: 10017
Hi,

I believe I have answered you on the other post regarding the same issue.

Regards,
Filip.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: