Re: External interrupt on PE6

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: External interrupt on PE6

Elger Jonker
On 6/8/05, Ole Reinhardt <[hidden email]> 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
> --
>
>
>
_______________________________________________
En-Nut-Discussion mailing list
[hidden email]
http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: External interrupt on PE6

Ole Reinhardt
> > 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.

Ahhh, ok :-) In this case you don't need the thread and the events. Only
register your interrupt and enter the "while" loop there.

You also could use the avr watchdog to reboot the system.

Bye,

Ole

--
kernel concepts    Tel: +49-271-771091-14
Dreisbachstr. 24   Fax: +49-271-771091-19
D-57250 Netphen    E+ : +49-177-7420433
--


_______________________________________________
En-Nut-Discussion mailing list
[hidden email]
http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion