[En-Nut-Discussion] External interrupt on PE6
Ole Reinhardt
ole.reinhardt at kernelconcepts.de
Wed Jun 8 14:32:36 CEST 2005
Hi,
> I want to use PINE6 as an external interrupt. The board has the
> default configuration (PE5 lan interrupt). I connected the 5V power
> pin to PE6 with a switch. When i hit the switch it should give PE6
> enough power to say there is an interrupt (i think).
Of course this is enough power to cause an interrupt. But be aware of
the chatter, your button will cause. (You'll get more than one
interrupt).
> In the software i use:
> INTERRUPT(SIG_INTERRUPT6){
> while(1){
> /* Do nothing */
> }
> }
Oh hell.. I think you have fully missunderstood the concept of
interrupts. You may never call an endless loop in a interrupt handler as
it will fully block your system.
You should do it like this:
handle my_event;
static void my_irq_handler(void *arg)
{
NutEventPostFromIRQ(&my_event);
}
THREAD(MY_THREAD, arg)
{
// do something here...
while (1) {
NutEventWait(&my_event, NUT_WAIT_INFINITE);
// Interrupt arrived... do something here...
}
}
void init_my_interrupt(void) {
NutThreadCreate("my_thread", MY_THREAD, NULL, 256);
if (NutRegisterIrqHandler(&SIG_INTERRUPT6, my_irq_handler, NULL)) {
// there was an error...
return;
}
}
Bye,
Ole
--
kernel concepts Tel: +49-271-771091-14
Dreisbachstr. 24 Fax: +49-271-771091-19
D-57250 Netphen E+ : +49-177-7420433
--
More information about the En-Nut-Discussion
mailing list