Keil™, An ARM® Company

Discussion Forum

A RET instruction does not return correctly (problem only with flash) !!!

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Mikael Briday
Posted
20-May-2005 12:51
Toolset
C166
New! A RET instruction does not return correctly (problem only with flash) !!!
I have a problem in the context switch function of an OS.
the switch function saves the context of the task that is running. Then, it sets the appropriate registers and need to jump to the task_function. The adress of the task_function is set on top of the stack. Then I returns (RET)

But I get a class B interrupt when using the flash.
The value of CSP is not modified ("near" memory model). The value of SP, and the address pointed by SP are correct (I see it on an LCD connected to the developpement kit). I use a C167CS processor (PhyCore). I don't know where the processor jumps, but not to the function it was supposed to :-/

Does someone has an idea? What is the difference between using the simulator and the real hardware?
Read-Only
Author
Mike Kleshov
Posted
21-May-2005 12:14
Toolset
C166
New! RE: A RET instruction does not return correctly (problem only with flash) !!!
Can you read the contents of the TFR register after the hardware trap occurs? This could narrow down the search:
http://www.keil.com/support/docs/2534.htm

- mike
Read-Only
Author
Mikael Briday
Posted
23-May-2005 02:16
Toolset
C166
New! RE: A RET instruction does not return correctly (problem only with flash) !!!
I found the bug, which was a bad configuration of the stack (Maximum System Stack Size selection (SYSCON.13 .. SYSCON.15) )
SP was changed using MOV instructions (the function change a context) and generate no exception. The problem appear only with the RET instruction, when SP is used.

Thanks Mike Kleshov for your help, I'm sure it will help us!

Next Thread | Thread List | Previous Thread Start a Thread | Settings