|Subject:||AW: [avr-gcc-list] Preemptable Interrupts|
|Date:||Thu, 20 Feb 2003 09:12:43 +0100|
the interrupt priority only is important if two interrupts are
pending at the same time (exactely). If an interrupt is
active then *NO* other interrupt will be able to interrupt
the actual one, no matter what priority level.
(That is due to the interrupt mechanism clearing the I flag).
If you enable interrupts again inside the interrupt handler
via the SEI instruction then *ANY* interrupt will be able to
interrupt! The AVR has nothing like the old 80C51 family with
two real interrupt priority levels - every interrupt configured
to be of higher priority could even interrupt every active
interrupt handler of lower priority.
Be careful, though using the term 'priority' in both cases we're
talking about two different concepts.
Conclusion - if you really need to have serveral priority levels
you have to enable/disable the interrupt inside your handler -
don't forget the I flag itself!
(an INTERRUPT handler enables the I flag again,
a SIGNAL handler disables the I flag (resp. does nothing))
Attention - both handler types return via RETI and enable the I flag
Any more questions ? - feel free to ask them
> Hi Steve.
> >> I'm trying to figure out how to make the SIG_UART_DATA and
> >> signals preemptable. I've got another interrupt that I
> want interrupt
> >> the UART interrupts if it comes along. I've also got other lower
> >> priority interrupts that I don't want interrupting the
> UART interrupts.
> Looking at your sample program, you don't have to disable
> lower priority
> interrrupts as this is done automatically in hardware on
> AVR's. Take the
> M16 chip for example.
> IntR Function
> 4 Timer2 COMP
> 5 Timer2 OVF
> 6 ... 11
> 12 - UART Rx Complete
> 13 - UART - DATA
> 14 - UART Tx Complete
> 15 ...
> Interrupts 0 ... 12 have higher priority over UART-DATA.
> So, you don't have to disable any thing about #12 as they are
> automatically disabled by AVR internal h/w untill the AVR UART DATA
> ISR returns. So, according to your code snippet you should
> only have to
> disable the Timer2 interrupt.
> Hence (assuming the only other activated interrupts below AVR
> UART DATA
> is the Timer2 stuff );
> cbi(TIMSK, TOIE2); /* disable lower priority interrupt */
> sei(); /* turn interrupts back on */
> /* do stuff here, (minimal amount of code, of course) */
> sbi(TIMSK, TOIE2);
> Hope this helps.
> Cheers. Grahame
> avr-gcc-list mailing list
|[Prev in Thread]||Current Thread||[Next in Thread]|