Trigger an machine exception interrupt but nothing push in stack

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

Trigger an machine exception interrupt but nothing push in stack

Jump to solution
788 Views
wangyadong
Contributor II

Hi all,

         I get a strange problem:

         I try to trigger an machine exception interrupt by ECC generation module but nothing push in stack and which causes S12ZCPU illegal access memory after return form interrupt(wrong address return to PC (0x10529E)).

         Anyone has met case like this before?

         Thanks for helping.

                                                                                                                                                Yadong Wang

1 Solution
639 Views
lama
NXP TechSupport
NXP TechSupport

We recommend to generate reset ()S12Z safety manual.

However, this is application problem, you can do anything you want.

Theoretically as common solution, keeping in mind that some registers can be write once, stack has some value I can:

1) Go to the start of the code _Startup();

see file Start12.c in the project:

__EXTERN_C void _Startup(void) {
    __asm {
        LD S, #__SEG_END_SSTACK-1        /* initialize SP */

Do not forget to define the function in the module where you call it from.

void _Startup(void);

2) Go to any function I want to continue. (good to think about stack.... asm LD S, #your value or re-initialization to the beginning value ,  asm   LD S, #__SEG_END_SSTACK-1        /* initialize SP */)

3) Go to anywhere you want to continue asm JMP .....  still you have to think about consequences to previous process.

Best regards,

Ladislav

View solution in original post

4 Replies
639 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

https://www.nxp.com/docs/en/reference-manual/S12ZCPU_RM_V1.pdf  says:

7.3.3 Machine Exception
Machine exceptions are caused by the Memory Map Control module (MMC).
A Machine Exception causes the S12Z CPU to jump to the address in the Machine Exception vector as
soon as the current instruction finishes execution.
When execution of a Machine Exception begins, both the X- and I-bits are set and the U-bit is cleared.
A Machine Exception is considered a severe system error, so nothing is written on the stack. The MMC
module saves information about the S12Z CPU state which otherwise would be lost due to exception
processing (e.g. the Program Counter register and X-, I- and U-bits from the Condition Code Register).
This information can then be used to identify the source of the Machine Exception.
Please refer to the MCU reference manual for more information about possible sources of machine
exceptions present on a specific MCU.
NOTE
Machine exceptions are meant to signal severe system problems. Software
is expected to re-initialize the system when a machine exception occurs.
Unlike interrupts or software exceptions, a machine exception causes the
CPU to not perform any stack operations, so it is not possible to return to
application code by simply using an RTI (or an RTS) instruction.

Best regards,

Ladislav

639 Views
wangyadong
Contributor II

Hi lama,

            Thank you for answering my question.

            Does it mean that when machine exception occurs the only way to exit is to  re-initialize the system even if the system problem is solved.

            I am now working on memory test and ensure that double bit ECC error detection mechanism is good during initialization.So I hope software triggers double bit ECC error and then return from where it happens.

                                                                                                                                                    Yadong   Wang

0 Kudos
640 Views
lama
NXP TechSupport
NXP TechSupport

We recommend to generate reset ()S12Z safety manual.

However, this is application problem, you can do anything you want.

Theoretically as common solution, keeping in mind that some registers can be write once, stack has some value I can:

1) Go to the start of the code _Startup();

see file Start12.c in the project:

__EXTERN_C void _Startup(void) {
    __asm {
        LD S, #__SEG_END_SSTACK-1        /* initialize SP */

Do not forget to define the function in the module where you call it from.

void _Startup(void);

2) Go to any function I want to continue. (good to think about stack.... asm LD S, #your value or re-initialization to the beginning value ,  asm   LD S, #__SEG_END_SSTACK-1        /* initialize SP */)

3) Go to anywhere you want to continue asm JMP .....  still you have to think about consequences to previous process.

Best regards,

Ladislav

639 Views
wangyadong
Contributor II

Thank you for your answers.

0 Kudos