Confusion of SWT for MPC5744P in S32DS

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

Confusion of SWT for MPC5744P in S32DS

1,092 Views
hyacinth
Contributor II

Dear all,

I've met a Confusion of SWT for MPC5744P in S32DS.For this part,the code involves 3 parts,

1.void SWTInit(void),

2.void SWTClear(void),

3.void FCCUInit(void),

as follows:

// 1

void SWTInit(void)
{
/* Provide a Key to unlock SWT configuraiton registers */
SWT_0.SR.R = 0xC520;
SWT_0.SR.R = 0xD928;

/* Wait for solf-lock bit */
while (SWT_0.CR.B.SLK == 0x1);
/* Enable SWT_0 */
SWT_0.CR.B.WEN = 0x1;
/* Set SWT timeout */
SWT_0.TO.R = 0x000FFFFF;
SWT_0.CR.R = 0xFF000101;//0xFF000315;//0xFF000101;
}// end of SWTInit

// 2

void SWTClear(void)
{
SWT_0.SR.R = 0x0000A602; // 向SR中写入0xA602和0xB480喂狗
SWT_0.SR.R = 0x0000B480;
}// end of SWTClear

// 3

void FCCUInit(void)
{
/* Unlock configuration */
FCCU.TRANS_LOCK.B.TRANSKEY = 0xBC;

/* provide Config state key */
FCCU.CTRLK.R = 0x913756AF;

/* enter config state - OP1 */
FCCU.CTRL.R = 0x1;

/* Verify if state change was sucessful */
while (FCCU.CTRL.B.OPS != 0x3); //operation status successful

#if LONG_RESET
/* Configure FCCU to react on NCF14 with long functional reset */
FCCU.NCFS_CFG[0].R = 0x20000000; //long functional reset reaction

#else
/* Configure FCCU to react on NCF with short reset */
FCCU.NCFS_CFG[0].R = 0x10000000;

#endif

FCCU.NCF_CFG[0].R = 0x4000;

//set up the NOMAL mode of FCCU
FCCU.CTRLK.R = 0x825A132B; //key for OP2
FCCU.CTRL.R = 0x2; //set the OP2 - set up FCCU into the NORMAL mode
while (FCCU.CTRL.B.OPS != 0x3); //operational status succesfull

}//FCCU_Init

In the MAIN fuction,call the functions like this:

int main(void)
{
        int counter = 0;


        xcptn_xmpl (); // Configure and Enable Interrupts
        peri_clock_gating(); // Configures enabling clocks
        PLLInit(); 
        GPIOInit(); 
        PITInit(); 
        FCCUInit();
        SWTInit();


        for (;;)//Loop forever
        {
                counter++;
                HandleDevice();
                //SWTClear(); 
                //FCCUClearFaults();
        }
        return 0;
}//end of main

In the main function,no matter call SWTClear or not ,the MCU does not reset.

But when I config the FCCU as

FCCU.NCFS_CFG[0].R = 0x4000;

then no mater call SWTClear or not, the MCU will reset time after time papidly,and the period does not depend on the register :

/* Set SWT timeout */
SWT_0.TO.R = 0x000FFFFF;

(I judge the MCU reset or not by a LED which is configed to be light on.When the LED stay light on,I think the MCU does not reset;when the LED bink,I think the MCU is reset again and again.)

I wonder is there anything wrong in my configuration,or is there any example of SWT for MPC5744P in S32DS.

I am looking forward to your reply!

Labels (1)
1 Reply

624 Views
petervlna
NXP TechSupport
NXP TechSupport

Hi,

I will try to sumarize and explain how SWT works here. However I have already explained it in other thread.

1. By default reaction on SWT timeout is disabled after reset.

2. Configure reaction on SWT in FCCU.

3. You have to configure and enable SWT.

This way the SWT will work as expected. On timeout it will trigger interrupt or reset, dependent on configuration.

Example MPC5744P SWT Short reset GHS614 

Example MPC5744P SWT Long reset GHS614 

I have posted 2 examples of SWT.

Possible issues:

A.) When SWT expire and you dont have configured in FCCU reaction the SWT will not reset micro.

B.) When SWT is enabled and in FCCU_Ex is also enabled, but no reaction is set in FCCU_CFGx. And SWT expire, the FCCU FOSU will perform destructive reset.

The fault line active in FCCU_Ex will start internal counter, and after it expires and no reaction is taken in FCCU, the FOSU will reset micro.


Peter