[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] About context saving in Vectors
From: |
Dave Hylands |
Subject: |
Re: [avr-gcc-list] About context saving in Vectors |
Date: |
Wed, 14 Jan 2009 09:45:14 -0800 |
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).
--
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/
- RE: [avr-gcc-list] About context saving in Vectors, (continued)
- RE: [avr-gcc-list] About context saving in Vectors, Stu Bell, 2009/01/14
- Re: [avr-gcc-list] About context saving in Vectors, David Kelly, 2009/01/14
- RE: [avr-gcc-list] About context saving in Vectors, Stu Bell, 2009/01/14
- Message not available
- RE: [avr-gcc-list] About context saving in Vectors, Stu Bell, 2009/01/15
- Re: [avr-gcc-list] About context saving in Vectors, Paulo Marques, 2009/01/15
- Re: [avr-gcc-list] About context saving in Vectors, dlc, 2009/01/14
- Re: [avr-gcc-list] About context saving in Vectors, David Kelly, 2009/01/14
- Re: [avr-gcc-list] About context saving in Vectors, dlc, 2009/01/14
- Re: [avr-gcc-list] About context saving in Vectors, David Kelly, 2009/01/14
- Re: [avr-gcc-list] About context saving in Vectors, Preston Wilson, 2009/01/14
Re: [avr-gcc-list] About context saving in Vectors,
Dave Hylands <=
Re: [avr-gcc-list] About context saving in Vectors, Dave Hylands, 2009/01/14
Re: [avr-gcc-list] About context saving in Vectors, Daniel O'Connor, 2009/01/14
RE: [avr-gcc-list] About context saving in Vectors, Weddington, Eric, 2009/01/14