[En-Nut-Discussion] External interrupt on PE6

Elger Jonker elger.jonker at gmail.com
Fri Jun 10 10:15:52 CEST 2005


On 6/8/05, Ole Reinhardt <ole.reinhardt at kernelconcepts.de> wrote:
> 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.

It might seem that way, but in this case this is exactly what i want.
I want to use the hardware interrupt as a state of emergency. Nothing
else may occur when it is triggered until the system resets.


> 
> 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;
>    }
> }
> 
I'll try it this way, it looks solid. Thank you very much!

> 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