How to handle Memory Exceptions on S12Z

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to handle Memory Exceptions on S12Z

ソリューションへジャンプ
1,390件の閲覧回数
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 解決策
963件の閲覧回数
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 返答(返信)
964件の閲覧回数
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 件の賞賛
返信
963件の閲覧回数
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 件の賞賛
返信
963件の閲覧回数
axhubner
Contributor II

Thanks MJW and Radek!

0 件の賞賛
返信