>>Um... I may be defying the very basic laws of computer architecture,
>>but can we design an interrupt which after completion, doesnt return to
>>the place where its called from (i.e. continues from Program
>>Counter+1), rather loads the PC with a completely different (for
>>instance the beginning of a state machine (idle)) value?
>
>
> You might want to look at the setjmp() and longjmp() functions
Please do not use longjump() in an interrupt service routine
in an AVR - you'll end up with locked-up interrupt hardware.
--
Tauno Voipio
tauno voipio (at) iki fi
Reply by ●November 16, 20052005-11-16
> Um... I may be defying the very basic laws of computer architecture,
> but can we design an interrupt which after completion, doesnt return to
> the place where its called from (i.e. continues from Program
> Counter+1), rather loads the PC with a completely different (for
> instance the beginning of a state machine (idle)) value?
You might want to look at the setjmp() and longjmp() functions
--
:wq
^X^Cy^K^X^C^C^C^C
Reply by Kurt Harders●November 16, 20052005-11-16
Hi Dave,
Dave Hansen wrote:
> > It should read
> > INTERRUPT(SIG_OVERFLOW2)
>
> Actually, in all likelihood it should read
>
> SIGNAL(SIG_OVERFLOW2)
>
> You almost never want to use INTERRUPT. Check the avr-libc docs.
Thats true. I expected the OP to have a reason to use interrupt :-).
Regards, Kurt
--
Kurt Harders
PiN -Pr�senz im Netz GITmbH
mailto:news@kurt-harders.de
http://www.pin-gmbh.com
Reply by Dave Hansen●November 16, 20052005-11-16
On 16 Nov 2005 11:46:57 GMT in comp.arch.embedded, "Kurt Harders"
<news@kurt-harders.de> wrote:
>Hallo,
>
>Mak wrote:
>
>> // Timer 2 overflow interrupt service routine
>> interrupt(SIG_OVERFLOW2)//SIG_INTERRUPT0)//SIG_OVERFLOW2)
>
>It should read
>INTERRUPT(SIG_OVERFLOW2)
Actually, in all likelihood it should read
SIGNAL(SIG_OVERFLOW2)
You almost never want to use INTERRUPT. Check the avr-libc docs.
You also need to #include <avr/interrupt.h> and/or <avr/signal.h>
somewhere.
Regards,
-=Dave
--
Change is inevitable, progress is not.
Reply by Tauno Voipio●November 16, 20052005-11-16
Mak wrote:
> Thanks for the input, I believe the capital letters solves the problem,
> I am at peace now :).
>
> Um... I may be defying the very basic laws of computer architecture,
> but can we design an interrupt which after completion, doesnt return to
> the place where its called from (i.e. continues from Program
> Counter+1), rather loads the PC with a completely different (for
> instance the beginning of a state machine (idle)) value?
What should be done with the baseline code state
saved at the entry to the interrupt routine?
You'll have to decide e.g. what to do with the
call stack of te code that was interrupted.
It is not difficult to fudge the return PC.
It is difficult to do it so that nothing collapses.
--
Tauno Voipio
tauno voipio (at) iki fi
Reply by Mak●November 16, 20052005-11-16
Thanks for the input, I believe the capital letters solves the problem,
I am at peace now :).
Um... I may be defying the very basic laws of computer architecture,
but can we design an interrupt which after completion, doesnt return to
the place where its called from (i.e. continues from Program
Counter+1), rather loads the PC with a completely different (for
instance the beginning of a state machine (idle)) value?
Thanks
Reply by Tom●November 16, 20052005-11-16
> // Timer 2 overflow interrupt service routine
> interrupt(SIG_OVERFLOW2)//SIG_INTERRUPT0)//SIG_OVERFLOW2)
> {
> // Place your code here
> PORTD ^= _BV(7);
> }
>
> and make with winavr, I get the following warnings:
>
1 > E:/AVR/WinAVR/testfiles/isr.c:6: warning: return type defaults to `int'
2 > E:/AVR/WinAVR/testfiles/isr.c:6: warning: function declaration isn't a
> prototype
3 > E:/AVR/WinAVR/testfiles/isr.c: In function `interrupt':
4 > E:/AVR/WinAVR/testfiles/isr.c:6: warning: type of "__vector_4" defaults
> to "int"
5 > E:/AVR/WinAVR/testfiles/isr.c:9: warning: control reaches end of
> non-void function
>
> Why cant I point the
> interrupt vector table towards my desired routine using this syntax and
> WinAVR?
Looks to me like you need a return type on your function which in this case
should be void. That should solve 1,2,3 and 5. I reckon 4 has something to
do with your _BV() macro/function.
As for positioning your code in the vector table I'm not sure but in the IAR
compiler you need to use a pre-processor command __irq to tell the compiler
to use a return from interrupt at the end of the ISR. It might instruct the
linker where to put it as well but I'm not sure.
Reply by Kurt Harders●November 16, 20052005-11-16
Hallo,
Mak wrote:
> // Timer 2 overflow interrupt service routine
> interrupt(SIG_OVERFLOW2)//SIG_INTERRUPT0)//SIG_OVERFLOW2)
It should read
INTERRUPT(SIG_OVERFLOW2)
> {
> // Place your code here
> PORTD ^= _BV(7);
> }
>
> and make with winavr, I get the following warnings:
>
> E:/AVR/WinAVR/testfiles/isr.c:6: warning: return type defaults to
> `int'
Yout defined a function interrupr returning an int.
> E:/AVR/WinAVR/testfiles/isr.c:6: warning: function declaration
> isn't a prototype
He is right. interrupt(xxx) is no prototype. But you did not want to
write a prototype, you wanted the macro INTERRUPT
> E:/AVR/WinAVR/testfiles/isr.c: In function `interrupt':
> E:/AVR/WinAVR/testfiles/isr.c:6: warning: type of "__vector_4"
> defaults to "int"
> E:/AVR/WinAVR/testfiles/isr.c:9: warning: control reaches end of
> non-void function
> Can someone please tell me that is wrong here? Why cant I point the
> interrupt vector table towards my desired routine using this syntax
> and WinAVR?
You can, but you must use the correct spelling. All capital letters fpr
this macro.
Regards, Kurt
--
Kurt Harders
PiN -Pr�senz im Netz GITmbH
mailto:news@kurt-harders.de
http://www.pin-gmbh.com
Reply by Mak●November 16, 20052005-11-16
Hello all,
This is an AVR specific problem. When I write a function for timer2
overflow as follows:
// Timer 2 overflow interrupt service routine
interrupt(SIG_OVERFLOW2)//SIG_INTERRUPT0)//SIG_OVERFLOW2)
{
// Place your code here
PORTD ^= _BV(7);
}
and make with winavr, I get the following warnings:
E:/AVR/WinAVR/testfiles/isr.c:6: warning: return type defaults to `int'
E:/AVR/WinAVR/testfiles/isr.c:6: warning: function declaration isn't a
prototype
E:/AVR/WinAVR/testfiles/isr.c: In function `interrupt':
E:/AVR/WinAVR/testfiles/isr.c:6: warning: type of "__vector_4" defaults
to "int"
E:/AVR/WinAVR/testfiles/isr.c:9: warning: control reaches end of
non-void function
When I check the main.lss file, I notice that the interrupt routine is
not correctly placed in the inetrrupt vector, and hence the code doesnt
work,
Can someone please tell me that is wrong here? Why cant I point the
interrupt vector table towards my desired routine using this syntax and
WinAVR?
Thanks in advance
Mak