how to fix "format error" due to improper stack frame?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to fix "format error" due to improper stack frame?

1,791 Views
vskarine
Contributor I
Hello,
 
I need the timer to interrupt currently running subroutine and switch it to another. I change the SR and PC before I call RTE in the stack. In the manual it is says that before RTE is called the stack should look like :
 
SR  <- 4bytes
PC <-- 4bytes
 
but when I test it the stack pointer is misaligned by 8 bytes and it gives me error "fromat error"
Could anyone please help and tell me how RTE works and what I need to change to get my program to work properly?
 
Thank you very much.
Labels (1)
0 Kudos
1 Reply

302 Views
mccPaul
Contributor I
Hi
 
You give us very little information (cpu, compiler, is your code C or assembler, ...) but I can give you some information.
 
Look in the Coldfire Programmer's Reference Manual, chapter 11, section 11.1.2. This gives you details of the exception stack frame. When the CPU executes the RTE instruction it will expect this frame to be on the stack. The Format exception means that the format field is incorrect.
 
Are you trying to write an exception (interrupt) handler in assembler? If so, when the interrupt occurs, the CPU will create a correct exception frame on the stack and it will then jump to your exception handler. Or maybe you are trying to write some code that may not be called by the Interrupt module but you have to return with RTE?
 
Please give some more details.
 
Paul.
 
Edit: spelling.


Message Edited by mccp on 2007-07-04 09:18 AM
0 Kudos