Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: external intrrupt runs only Once in keil ?!!
PostPosted: Sat Feb 13, 2010 12:20 pm 
Offline

Joined: Sat Feb 13, 2010 12:06 pm
Posts: 8
after run rotin cpu can not work.
help me please
keil 3.3 .

init :
//* define switch SW3 at PIO input for interrupt IRQ loop
AT91F_PIO_CfgInput(AT91C_BASE_PIOA, INP_ENC1_F1 | INP_ENC2_F1);


// open external IRQ interrupt
AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, INP_ENC1_F1, 0);

// open external IRQ0 interrupt
AT91F_AIC_ConfigureIt (AT91C_BASE_AIC, AT91C_ID_IRQ0, PIO_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE, InterruptEnc1);
AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_IRQ0);


rotin:

void InterruptEnc1 ( void ) {
int dummy;

ctcEnc1++;

PORTA->PIO_PER = 0x00000008; /* Enable PIO for LED1..4 */
PORTA->PIO_OER = 0x00000008; /* LED1..4 are Outputs */
PORTA->PIO_SODR = 0x00000008;
PORTA->PIO_SODR = 0x00000008; /* Turn on LED's ("1") */

// printf ("%u--%u\n",ctcEnc1,ctcEnc2);

//* enable the next PIO IRQ
dummy =AT91C_BASE_PIOA->PIO_ISR;
//* suppress the compilation warning
dummy =dummy;


// AT91F_AIC_ClearIt(AT91C_BASE_AIC,AT91C_ID_IRQ0);

// AT91F_AIC_AcknowledgeIt(AT91C_BASE_AIC);
//AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_IRQ0);
// *AT91C_AIC_EOICR = pPIT->PITC_PIVR; /* Ack & End of Interrupt */



}


Top
 Profile  
 
 Post subject: Re: external intrrupt runs only Once in keil ?!!
PostPosted: Sun Feb 14, 2010 3:06 pm 
Offline

Joined: Thu Mar 02, 2006 1:32 pm
Posts: 127
Location: Switzerland
Hi

If your are handling vectored interrupts directly, your interrupt routine needs to be declared as an interrupt rather than a subroutine [Keil uses __irq]

eg.
void __irq InterruptEnc1 ( void )
{
....
acknowledge the IRQ here too
}

If this is not followed it will crash as the interrupt is returned from since the compiler has used a "return from subroutine" rather than a "return from interrupt".

If you are using an interrupt dispatcher (this can be seen from the irq vector address) the handler must be declared as normal subroutine and doesn't acknowledge the interrupt on exit (as in your example).

The easiest way to verify is to put a break point in the routine and step out watching the assembler code to see where it returns to and if it uses the correct assembler instructions.

Regards

Mark

www.uTasker.com


Top
 Profile  
 
 Post subject: Re: external intrrupt runs only Once in keil ?!!
PostPosted: Mon Feb 15, 2010 11:16 pm 
Offline

Joined: Sat Feb 13, 2010 12:06 pm
Posts: 8
THANKS FOR YOUR ANSWER .
I CHECK __IRQ BUT KEIL HAVE ERROR :
main.c(65): error: #167: argument of type "void (*)(void)__irq" is incompatible with parameter of type "void (*)()"
FORM : AT91F_AIC_ConfigureIt (AT91C_BASE_AIC, AT91C_ID_IRQ0, PIO_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE, InterruptEnc1);


Top
 Profile  
 
 Post subject: Re: external intrrupt runs only Once in keil ?!!
PostPosted: Mon Feb 15, 2010 11:46 pm 
Offline

Joined: Thu Mar 02, 2006 1:32 pm
Posts: 127
Location: Switzerland
Hi

There is no error with __IRQ but instead an incompatibility with the call AT91F_AIC_ConfigureIt().

You should be able to cast the passed routine so that the compiler no longer complains:

AT91F_AIC_ConfigureIt (AT91C_BASE_AIC, AT91C_ID_IRQ0, PIO_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE, (void (*)(void))InterruptEnc1);

Regards

Mark

www.uTasker.com


Top
 Profile  
 
 Post subject: Re: external intrrupt runs only Once in keil ?!!
PostPosted: Wed Feb 17, 2010 11:26 pm 
Offline

Joined: Sat Feb 13, 2010 12:06 pm
Posts: 8
very very thanks .
solved my problem.


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


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:  
cron