How to handle Memory Exceptions on S12Z

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

How to handle Memory Exceptions on S12Z

Jump to solution
1,119 Views
axhubner
Contributor II

I am trying to implement an ECC Error-handling. If an EEPROM ECC Error is detected, the software should try to handle it.

Each double Bit ECC Error causes a Machine Exception.

For debugging purpose, I generate a machine exception by writing a value to the P-Flash, like 01:

 

Memory Loc. | Commands

01                  *((byte *)0xFE0000) = 0; <-Causes Memory Exception

02                  next Command = 0; <- Next Command

 

After attending this line of code, a Machine Exception is triggered and the interrupt routine is executed correctly, but

When I return from the ISR, the PC is not set to the next command.

For me it seems that some random code ore some random ISRs will be executed. At the end the Program Counter is loaded with 0x000001.

 

Do i have to clear the Memory Exception Interrupt?

In the ISR i clear the MMCEC register by writing MMCEC = 0xFFFFFFFF to it.

 

 

Thanks Axel

Labels (1)
0 Kudos
1 Solution
692 Views
MJW
NXP Employee
NXP Employee

Hello Axel,

what your are getting in the case of a double ECC fault is actually a Machine Exception, not an Interrupt.

There is no stack-frame created for a Machine Exception so simply calling "RTI" (which expects a stack-frame) at the end of the Machine Exception routine will result in a crash.

The difference is explained here:

http://cache.nxp.com/files/microcontrollers/doc/ref_manual/S12ZCPU_RM_V1.pdf​​

("Chapter 7, Exceptions").

HTH,

MJW

View solution in original post

0 Kudos
3 Replies
693 Views
MJW
NXP Employee
NXP Employee

Hello Axel,

what your are getting in the case of a double ECC fault is actually a Machine Exception, not an Interrupt.

There is no stack-frame created for a Machine Exception so simply calling "RTI" (which expects a stack-frame) at the end of the Machine Exception routine will result in a crash.

The difference is explained here:

http://cache.nxp.com/files/microcontrollers/doc/ref_manual/S12ZCPU_RM_V1.pdf​​

("Chapter 7, Exceptions").

HTH,

MJW

0 Kudos
692 Views
RadekS
NXP Employee
NXP Employee

Thanks MJW. That is correct.

Axel,

When we detect double ECC fault or illegal memory accesses, we cannot be sure that we read and execute correct code, therefore correct recovery action should be (signalize error and) MCU reset.

See attached example code where I used COP watchdog for MCU reset.

Note: For using watchdog in that way, we must not “initialize” watchdog by command “CPMUCOP = 0x00;” in application. Command “CPMUCOP = 0x00;” will not enable watchdog but it counts for the “write once” condition.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
692 Views
axhubner
Contributor II

Thanks MJW and Radek!

0 Kudos