AnsweredAssumed Answered

strange trashed return address(?) problem

Question asked by michael kaufman on Dec 21, 2009
Latest reply on Dec 27, 2009 by michael kaufman
Hi

I am working with MC9S08QE128 MCU and experience the following problem: my application sometimes seems to jump to wrong address when some function is called. I have reduced the funtion code to just "return 0;" statement, but the problem still persists (sometimes). It may be a plenty of explanations why this happens, but there is something I can't understand. The following is a bus trace captured with a debugger:

Frame |Address | Instruction | FIFO analyse remark |
--------------------------------------------------------------------------------------------------------
0 280D9 PSHX
1 280DA PSHH
2 280DB LDHX 8,SP
3 280DC
4 280DD
5 280DE CALL 0x028082
6 280DF
7 280E0
8 280E1
9 28082 CLRA
10 28083 RTC
11 28084
12 28085
13 28086
14 288B7 STX ,X Instruction outside application, DBG FIFO data 0
15 288B8 STX ,X Instruction outside application
16 288B9 STX ,X Instruction outside application
17 288BA STX ,X Instruction outside application
18 288BB STX ,X Instruction outside application
19 288BC STX ,X Instruction outside application

The function I am talking about is called at frame 5. The only instruction performed by function is CLRA which obviously can't alter the stack, but the following RTC causes jumps to wrong place. Can somebody explain how can it happen?

Outcomes