On Thursday 15 January 2009 04:15:14 Dave Hylands wrote:
> Hi Lin (and Dennis),
>
> >> And the function ISR(USART1_RX_vect) in Linux saves even fewer
> >> registers.
> >
> >  The solution is to NOT call functions from within your ISR.  That is
> > just evil.  Get your data in the ISR, put it in a mailbox or buffer and
> > have a regularly scheduled function handle the details from outside the
> > ISR.  I like to use ring buffers to store data from an ISR.  When using
> > the ring buffer the ISR modifies the "write" pointer, not the read
> > pointer and the processing function outside the ISR modifies the read
> > pointer and not the write pointer.  This means that those pointers don't
> > need "push/popped" in the ISR either.
>
> And here's some code that implements such a ring buffer. As David
> Kelly points out, as long as the index type is uint8_t, then nothing
> special is required (which for this particular implementation means
> that buffers upto 128 entries would be supported)
>
> <http://websvn.hylands.org/filedetails.php?repname=Projects&path=%2Fcommon%
>2FCBUF.h&rev=0&sc=0>
>
> It's important that the queue be declared volatile (as myQ is in the
> sample).

And I was just about to ask if someone could post some well tested code! :)

Thanks.

-- 
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to