External Interrupt run only one shot

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

hlaingtun
Posts: 1
Joined: Fri Aug 22, 2014 5:00 am

External Interrupt run only one shot

Sun Nov 16, 2014 6:54 am

Hi ...

Is there any missing code for input button in falling edge ?
When i press button , Ineterrupt routine is execute for only one time .After subsequent pressing will not hit IR routine .

 I am using Atmel Studio 6.2 SP1 with IcE debugger wiht Arduino (SAM3x8e).
Do i need reinitialize interrupt  within Interrupt rountine (Pin_Int_Action_Pin11)?

#include <asf.h>
void Pin_Int_Action_Pin11(uint32_t,uint32_t);
volatile uint32_t test = 0x00 ;
int main (void)
{
board_init();
sysclk_init();
sysclk_enable_peripheral_clock(ID_PIOD);
pio_set_input(PIOD, PIO_PD7, PIO_PULLUP);
pio_handler_set(PIOD, ID_PIOD, PIO_PD7,PIO_IT_FALL_EDGE, Pin_Int_Action_Pin11);
pio_enable_interrupt(PIOD, PIO_PD7);
NVIC_EnableIRQ(PIOD_IRQn);

while(1)
{
}
}
void Pin_Int_Action_Pin11(uint32_t sourceid, uint32_t mask)
{
test = pio_get(PIOD, PIO_TYPE_PIO_INPUT, PIO_PD7);
}
nutsnbolts
Posts: 31
Joined: Mon Aug 25, 2014 11:20 pm

Re: External Interrupt run only one shot

Mon Nov 17, 2014 2:23 am

Do i need reinitialize interrupt  within Interrupt rountine (Pin_Int_Action_Pin11)?
I'd use 'acknowledge' rather than reinitialise- though the answer's still "yes". You need to read the interrupt status register or the interrupt is still 'marked' by the NVIC as "pending". Nothing special, just... (from my project):

Code: Select all

volatile int dummy;
//"volatile" stops it being optimised away... and keeps it where it's put!
...
dummy=REG_PIOA_ISR;
...
You may want to think about where you do this- Once done, the interrupt can be re-triggered- so if, for example, you do it at the start of your ISR, another trigger will re-enter the routine, whatever's happening gets put on hold (e.g. a sequential data log will probably have entries out of sequence)... yet another trigger comes along.. you get the picture?
Oh... you'll probably get a compiler warning that "dummy" is assigned a value that's never used.. (or something similar). You can safely ignore it.
Regards,
Mike.

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest