AnsweredAssumed Answered

MPC5744P SWT keep running in STOP0 mode

Question asked by Hang Xie on Jan 4, 2017

1. config the SWT timeout to 1 second with drv_cpu_initswt().

void drv_cpu_initswt(uint32_t Timeout)
{
/* remove the SWT Soft lock */
SWT_0.SR.R = 0xC520;
SWT_0.SR.R = 0xD928;
/* Wait for solf-lock bit */
while (SWT_0.CR.B.SLK == 0x1);
/* Disable SWT_0 */
SWT_0.TO.R = 0x0F42400 * Timeout; //
SWT_0.CR.R = 0xFF00010E; // STP = 1, FRZ = 1, WEN = 0
}

2. after all init finished, enable the swt with drv_cpu_enableswt()

void drv_cpu_enableswt(void)
{
// remove the SWT Soft lock
SWT_0.SR.R = 0xC520;
SWT_0.SR.R = 0xD928;
while (SWT_0.CR.B.SLK == 0x1);
/* Enable SWT_0 */
SWT_0.CR.R = 0xFF00010F; // STP = 1, FRZ = 1, WEN = 1
}

3. CPU enter STOP0 mode with _switchMode(STOP0)

void _switchMode(CPUModeTypedef NewMode)
{
MC_ME.MCTL.R = (NewMode<<28)|0x00005AF0; // Enter Mode & Key
MC_ME.MCTL.R = (NewMode<<28)|0x0000A50F; // Enter Mode & Inverted Key
while (MC_ME.GS.B.S_MTRANS) {}; // Wait for mode transition to complete
while(MC_ME.GS.B.S_CURRENT_MODE != NewMode) {}; // Verify NewMode is the current mode
}

4. The CPU will reset after 1 second .

5. If stop SWT then the CPU will keep in STOP0 mode.

Outcomes