How to handle Memory Exceptions on S12Z

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to handle Memory Exceptions on S12Z

跳至解决方案
1,120 次查看
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

标签 (1)
0 项奖励
1 解答
693 次查看
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 项奖励
3 回复数
694 次查看
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 项奖励
693 次查看
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 项奖励
693 次查看
axhubner
Contributor II

Thanks MJW and Radek!

0 项奖励