Hi all, I have a problem with my stack pointer when i enter interrupt service routine. First thing i do is pushing all used registers to the stack ;push all registers to the stack ; move x0,x:(SP)+ ; move y0,x:(SP)+ ; move r2,x:(SP)+ ; move a0,x:(SP)+ ; move a1,x:(SP)+ ; move a2,x:(SP)+ ; move b0,x:(SP)+ ; move b1,x:(SP)+ ; move b2,x:(SP)+ ; move y1,x:(SP)+ ; move r0,x:(SP)+ ; move r1,x:(SP)+ ; move r3,x:(SP)+ ; move la,x:(SP)+ ; move lc,x:(SP)+ and then when i leave i pop them back ; pop lc ; pop la ; pop r3 ; pop r1 ; pop r0 ; pop y1 ; pop b2 ; pop b1 ; pop b0 ;; pop a2 ; pop a1 ; pop a0 ; pop r2 ; pop y0 ; pop x0 The problem i have is that my stacking pointer gets "stacked" for some reason and it stops updating causing program counter to go to some random location. I fix temporary this problem by pushing register to some memory location something like this move x0,x:$0820 move y0,x:$0821 move r2,x:$0822 and them pop them back later from that memory location. My program is not using SDK it is written in mixed C and assembly where all my isr are in assembly. I would like to find out what is wrong with my code, is there something else that i need to preserve when i enter this subroutine and do i need to worry about compiler temporary registers ( do i need to push them also on the stack). Thanks for any help. |
|
Interrupt stack pointer corruption
Started by ●October 23, 2002
Reply by ●October 23, 20022002-10-23
From your example it would appear that the method you are using is
inconsistent:
Example:
move x0,x:(sp)+
...
pop x0
rti
If the stack pointer is at 10 the first instruction will store x0 at
location 10 and increment the stack pointer to 11.
The final instruction (pop x0) will read the data from location 11 and
store it into x0 then decrement the stack pointer.
what you probably want to do is insert a LEA (sp)+ as the first
instruction.
lea (sp)+
move x0,x:(sp)+
...
pop x0
rti Jerry.
|
|
Reply by ●October 23, 20022002-10-23
I forgot to mention, that your last save of data to the stack register
should then not increment sp
move lc,x:(sp)
Jerry.
|
Reply by ●October 23, 20022002-10-23
Yes that's right, but in the example from Jerry below, he is
going to increment the Stackpointer once too much
Make sure that you do it that way:
lea (sp)+
move x0,x:(sp)+
move y0,x:(sp)+
move r0,x:(sp) ...
pop
r0
pop
y0
pop x0
rti rgds Chris
__________________________________
|
Reply by ●October 23, 20022002-10-23
To summarize the Stack Pointer stuff, here's the full code for the
"pushes" at the beginning of your interrupt service routine: ;push all registers to the stack lea (SP)+ move x0,x:(SP)+ move y0,x:(SP)+ move r2,x:(SP)+ move a0,x:(SP)+ move a1,x:(SP)+ move a2,x:(SP)+ move b0,x:(SP)+ move b1,x:(SP)+ move b2,x:(SP)+ move y1,x:(SP)+ move r0,x:(SP)+ move r1,x:(SP)+ move r3,x:(SP)+ move la,x:(SP)+ move lc,x:(SP) Your code for the "pop" instructions is OK. Also, pushing la and lc on the stack does NOT free up any of the Hardware Stack for a 'do' loop in your interrupt service routine. If you need to free up some or all of the Hardware Stack, please see the following Sections in the DSP56800 Family Manual: 8.12 Freeing One Hardware Stack Location 8.13 Multitasking and the Hardware Stack 8.13.1 Saving the Hardware Stack 8.13.2 Restoring the Hardware Stack Regards, Art Johnson Senior Systems Analyst PMC Prime Mover Controls Inc. 3600 Gilmore Way Burnaby, B.C., Canada V5G 4R8 Phone: 604 433-4644 FAX: 604 433-5570 Email: http://www.pmc-controls.com -----Original Message----- From: ljube20022000 [mailto:] Sent: Wednesday, October 23, 2002 6:37 AM To: Subject: [motoroladsp] Interrupt stack pointer corruption Hi all, I have a problem with my stack pointer when i enter interrupt service routine. First thing i do is pushing all used registers to the stack ;push all registers to the stack ; move x0,x:(SP)+ ; move y0,x:(SP)+ ; move r2,x:(SP)+ ; move a0,x:(SP)+ ; move a1,x:(SP)+ ; move a2,x:(SP)+ ; move b0,x:(SP)+ ; move b1,x:(SP)+ ; move b2,x:(SP)+ ; move y1,x:(SP)+ ; move r0,x:(SP)+ ; move r1,x:(SP)+ ; move r3,x:(SP)+ ; move la,x:(SP)+ ; move lc,x:(SP)+ and then when i leave i pop them back ; pop lc ; pop la ; pop r3 ; pop r1 ; pop r0 ; pop y1 ; pop b2 ; pop b1 ; pop b0 ;; pop a2 ; pop a1 ; pop a0 ; pop r2 ; pop y0 ; pop x0 The problem i have is that my stacking pointer gets "stacked" for some reason and it stops updating causing program counter to go to some random location. I fix temporary this problem by pushing register to some memory location something like this move x0,x:$0820 move y0,x:$0821 move r2,x:$0822 and them pop them back later from that memory location. My program is not using SDK it is written in mixed C and assembly where all my isr are in assembly. I would like to find out what is wrong with my code, is there something else that i need to preserve when i enter this subroutine and do i need to worry about compiler temporary registers ( do i need to push them also on the stack). Thanks for any help. _____________________________________ Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group. _____________________________________ About this discussion group: To Join: To Post: To Leave: Archives: http://www.yahoogroups.com/group/motoroladsp More Groups: http://www.dsprelated.com/groups.php3 ">http://docs.yahoo.com/info/terms/ |