Jump to Reset vector from machine exception ISR for S12ZVL Micro

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

Jump to Reset vector from machine exception ISR for S12ZVL Micro

3,355 Views
charudattaingal
Contributor IV

Hello Team,

From machine exception ( interrupt vector 5 ) handler we are jumping to reset vector address 0x00FFFFFC.

this will again generate the machine exception interrupt for number of time and application control is stuck in it.

Application control is not jumping to address 0x00FFFFFC.

Requesting help for the same.

Thanks & Regards,

Charudatta

7 Replies

2,583 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello,

 

I’m not sure I understand. 

In general, a machine exception is triggered upon an illegal memory access or due to a double-bit ECC error. It is not possible to return to the application and the MCU recovers through the reset.

Please check MMCEC registers which hold information about the cause of the machine exception.

 

Regards,

Daniel

0 Kudos
Reply

2,583 Views
yvesbriant
NXP Employee
NXP Employee

Hello Daniel,

I don't understand why a reset is necessary to recover from a Machine Exception.

Some situations are not so critical (e.g. double ECC error in EEPROM), and in these cases generating a reset is very brutal.

My understanding is that S21Z behaves similarly as PPC e200 cores in this situation: the Program Counter and the Machine states (CCR) are saved in 2 special purpose registers. The exception handler should then save these registers and other status (General Purpose Reg) in the stack, so that a RTI would allow to come back to the state before the ECC error has been seen.

Is my understanding correct ?

Thanks

0 Kudos
Reply

2,583 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Yves,

The meachine exception is decribed in Chapter 7.3.3 of CPU S12Z RM.

"Software is expected to re-initialize the system when a machine exception occurs."

But the MMC module stores Program Counter in MMCPC registers.

So theoretically it is possible, I haven't tried it though.

Regards,

Daniel

0 Kudos
Reply

2,583 Views
charudattaingal
Contributor IV

Hello Team,

I am handling machine exception in  software as shown below.

interrupt 5 void ECC_ISR(void)

{

    /* Log the DTC */

   __asm(JMP 0x00FFFFFC );   /* I am not able to jump to reset vector */

}

Vector 0 is mapped to _Startup

I believe something gone wrong with startup stack initialization as shown below

_EXTERN_C void _Startup(void) {
    __asm {
        LD S, #__SEG_END_SSTACK-1        /* initialize SP */
#ifdef __ALIGN_STACK_OPT__
        TFR S, D6                        /* align SP to 4*/
        AND D6, #-4
        TFR D6, S
#endif        
    }
    DoZeroOut();
    DoCopyDown();
#ifdef __cplusplus
    __static_init();
#endif
    main();
}

static void DoZeroOut(void) {
    __asm {
        LD D6, _startupData.nofZeroOuts
        BEQ end                    /* nothing to do */  
        LD X, _startupData.pZeroOut
    zeroOutLoop:
        LD Y,  (0,X)                /* X points to the first range */
        LD D7, (3,X)                /* D7 holds size */
    doZeroOut:
        CLR.b (Y+)
        DBNE D7, doZeroOut
        LEA X, (7,X)
        DBNE D6, zeroOutLoop
    end:
    }
}

static void DoCopyDown(void) {
     __asm {
        LD Y, _startupData.toCopyDownBeg
        BEQ end                    /* the pointer is NULL */
    nextItemLoop:
        LD D6, (Y+)                /* load the size */
        BEQ end
        LD X, (Y+)                /* load the destination */
    copyLoop:
        MOV.b (Y+), (X+)            /* copy the data */
        DBNE D6, copyLoop
        BRA nextItemLoop
    end:
    }
}

In Machine exception handler I am not able to jump to reset vector address 0x00FFFFFC .

How I  can  make it work ?

Please suggest.

Thank You very much.

Best Regards,

charudatta

0 Kudos
Reply

2,583 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello,

 

First, S12Z has a 16-bit CPU so it takes only 16-bit wide addresses. So this is probably the reason you get another machine exception.

 

The MCU goes through the reset vector at the end of Reset sequence, it is an entry point for an application.

Startup() function (see starts12z.c) is stored at the reset vector address.

So you can call the function and then the application will go through initialization.

// declaration
extern _Startup();
// jump to the address stored in the reset vector
_Startup();

But this will not restart the MCU.

There are only five reset sources. See Table 1-11 (Reset Sources and Vector Locations).

 

There are two possible options:

You can force COP reset

 

CPMUCOP = 0x01;    // Initialize COP watchdog, unless it is already initialized.
                   // Note: CPMUCOP is write-once register
CPMUARMCOP = 0x00; // Write any value except 0x55 or 0xAA cause MCU reset

or you can use a GPIO pin connected to the reset pin externally.

In the machine exception, you can set it as output and pull the reset pin down.

 

Regards,

Daniel

0 Kudos
Reply

2,583 Views
charudattaingal
Contributor IV

Hello Daniel,

At this time we can not change the hardware design.

cop reset is not working for us due to some boot loader and application sync issue.

Is there any way to jump on reset vector address 0x00FFFFFC from application. ?

Thanks & Regards,

Charudatta

0 Kudos
Reply

2,583 Views
MJW
NXP Employee
NXP Employee

Hello Charudatta,

Two things:

  1. While a vector-table entry is 4-byte aligned, only three bytes are actually used. The first byte is just padding. For the reset-vector this means the address of the program-start is in 0xFFFFFD..0xFFFFFF.
  2. The "JMP" instruction needs the location of the jump target. This is not the reset-vector address, but its content.

So, in order to jump to the program-start, change your code to this:

      __asm(JMP [0xFFFFFD]);

HTH,

MJW