AnsweredAssumed Answered

Confusion of SWT for MPC5744P in S32DS

Question asked by yu chen on Oct 29, 2017
Latest reply on Oct 30, 2017 by Peter Vlna

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 */

/* 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

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

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


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



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

        for (;;)//Loop forever
        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!