[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] custom signal prologue
From: |
Christian Troedhandl |
Subject: |
RE: [avr-gcc-list] custom signal prologue |
Date: |
Wed, 24 Nov 2004 10:01:48 +0100 (MET) |
On Wed, 24 Nov 2004, Ben Mann wrote:
I had attempted the same thing but also wasn't wild about
reverse-engineering the register list after any changes.
I quite like Christian's solution to this problem, which allows a much
cleaner approach to managing the registers, albeit at the cost of an extra
function call (ie call/ret overhead). For the time being I'm using this
method.
Now, if there were a way to make my function call inline, and thereby
magically instantiate the prologue without the call/ret pair, ie like this:
Another idea...
If we exchange SIG_UART1_DATA() and MyInterruptHandler() and leave out the
function call and the ret instruction, the processor will continue to
MyInterruptHandler() after finishing SIG_UART1_DATA():
void SIG_UART1_DATA(void) __attribute__ ((naked));
void SIG_UART1_DATA(void) //SIGNAL(SIG_UART1_DATA)
{
//Disable UDRIE
BYTE UCSRBReg;
asm volatile ("push %0\n\t" : "=r" (UCSRBReg) :);
UCSRBReg= UCSR1B;
UCSR1B = UCSRBReg& ~_BV(UDRIE);
//Enable interrupts
sei();
asm volatile ("pop %0\n\t" : "=r" (UCSRBReg) :);
// CPU will continue to MyInterruptHandler()
}
inline void MyInterruptHandler(void) __attribute__ ((signal,always_inline));
inline void MyInterruptHandler(void) {
...Do Something...
}
The only problem is, that I don't know if the compiler will always
put the functions in the right order.
Christian
---------------------------------------------------------------------
Christian Troedhandl mailto:address@hidden
Embedded Computing Systems voice:+43 (1) 58801-18262
Vienna University of Technology
A-1040 Wien, Treitlstr. 3/182-2 http://www.vmars.tuwien.ac.at/