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

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

RE: [avr-gcc-list] About context saving in Vectors


From: Stu Bell
Subject: RE: [avr-gcc-list] About context saving in Vectors
Date: Wed, 14 Jan 2009 10:02:48 -0700

> > The solution is to NOT call functions from within your 
> > ISR.  That is just evil.

Perhaps.  And yet, there are occasions when even the reviled "goto" is
useful, and even correct.

"All generalizations fail at some point.  Including this one."

> > 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 [to be] "push/popped" in the ISR either.
> 
> Pointers, or indexes?
> 
> Don't quite understand the push/popped reference, but if a 
> variable is accessed in both interrupt space and "user" space 
> it needs to be protected so that its uses "atomically".

Which is why there is the <util/atomic.h> macros.  Check out:

ATOMIC_BLOCK( ATOMIC_RESTORESTATE )
{
   ... Mangle pointers
}

Best regards, 

Stu Bell 
DataPlay (DPHI, Inc.) 





reply via email to

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