Illegal Opcode IRQ

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

Illegal Opcode IRQ

2,041 Views
Yellowfish
Contributor I

Hi,

 

I wonder if anyone can help me. I am using the MC9S12XDT512 processor and something is causing the unimplemented opcode IRQ to execute.

 

How can I go about finding what part of my code caused this to happen?

 

Thanks,

Stuart

Labels (1)
Tags (1)
0 Kudos
Reply
2 Replies

730 Views
kef
Specialist I
In your trap handler you could inspect the stack. Illegal instruction trap ISR return address (and I think the address of illegal instruction +2, must check)  should be stored at SP+8.
I think you should try using onchip trace buffer. I'm not familiar with it. But I would try to enable trace buffer, put breakpoint in trap ISR, and when breakpoint is hit trying to trace it.

730 Views
Lundin
Senior Contributor IV
Most common cause is indeed stack overflow.

The quick & dirty way to find stack errors is to download the code through the debugger, then in the memory map, set every byte in the whole stack area to a certain value, like 0xAA.

After that, start the program and let it run. When it catches the breakpoint for illegal instruction, pick up the memory map and check the stack. You should be able to see how much of the 0xAA on the stack that the program has munched away at. If it is all the way to the top, or close, then the cause is stack overflow.