avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] interrupts


From: Oliver Kasten
Subject: Re: [avr-gcc-list] interrupts
Date: Fri, 18 Mar 2005 10:07:34 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

here is my two pennies worth. (i'm pretty pretty sure the following is right, but wouldn't mind if someone could confirm or disprove.)

if interrupts are disabled in ISRs interrupts can get lost when two or more interrupts occur while servicing an ISR. then you might also miss a byte, for example, from the USART. if your ISR-code makes assumptions about the form of the incoming data (e.g., you expect the bytes from the USART stream to alternate sign), your assumption might brake and your code might enter into an endless loop or so. the problem then would be your code, not the interrupt handling of the controller.

now, how do interrupts (and data) get lost exactly?
let's assume interrupts are disabled in ISRs (as in your case). internally the interrupt condition (timer compare match etc.) sets an interrupt-specific boolean flag (there is one flag per interrupt type). if interrupts are enabled, the ISR is entered immediately and the flag is cleared. if the previous ISR is still executing and a second interrupt of the same type occurs, the flag is again set, but the IRS is not executed until the previous has finished. the flag is used to keep track of pending interrupt requests. however, only one pending interrupt can be remembered. if two or more interrupts occur during the execution of an ISR, only one can be remembered.

some interrupts are associated with data, for example, the reception of a data byte on the USART. typically, there is a one or two-byte FIFO queue for storing the data until it is read. if the data comes in faster than it is read, old values are obviously overwritten and are lost for good. so loosing an interrupt might also mean loosing data.

we had a case like that, when a timer ISR did some lengthy bookkeeping every now and then. when at the same time there was high-speed serial data transfer, we lost some bytes. took us some time to figure that out...

hmm, maybe that was obvious. anyway, it hope it helps someone.

best,
olli*


Jamie Morken wrote:
> Hi,
>
> When in an interrupt service routine, and another interrupt is
>
> [...]
>
> cheers, Jamie Morken

--
oliver kasten
eidgenössische technische hochschule (eth) zürich
distributed systems group, eth zentrum, ch-8092 zuerich, switzerland
tel: +41-1-632 06 63  fax: +41-1-632 16 59  www.inf.ethz.ch/~kasten/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]