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?
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
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!