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.
已解决! 转到解答。
Hi,
I tested watchdog in STOP mode and it works correct on my side. I created simple example, which demonstrates the functionality of STP bit in SWT_CR register.
Please see example and also Reset signal. In my example I defined macro STOP_SWT. If this symbol is set to 1, watchdog is stopped in STOP mode, if STOP_SWT is 0, watchdog is running in STOP mode. I tested the example without debugger connected.
First case: SWT is disabled in STOP mode:
1) Reset signal after power on reset
2) Reset signal when microcontroller is running
Second case: SWT is enabled in STOP mode:
1) Reset signal after power on reset
2) Reset signal when microcontroller is running
In the first case you see, there is no reset, because SWT is stopped while microcontroller is in STOP mode (I do not wake up micro from STOP mode in my example).
In the second case there is periodical reset caused by SWT, because SWT is still running, even if microcontroller is in STOP mode.
Please test the example, and let me know if it works on your side.
PS: I did not test your example, but if I were you, I will check the STOP mode at first. Because if there is some pending interrupt or some event, microcontroller does not go to STOP mode and STP bit in SWT has no effect. It is also better to test the example without debugger.
I use MPC5744P 1N15P, so we have the same mask.
Regards,
Martin
Hi,
the behavior you describe is correct. If SWT is stopped (microcontroller is not reset after 1 second), microcontroller stays in STOP mode. The normal exit from the STOP0 mode is by an interrupt or a wakeup event (WKPU module, RTC module). Please see reference manual chapter Mode Entry module.
What is your goal? Do you want to switch microcontroller back from stop mode? Please clarify more detail.
Regards,
Martin
Hi,
I'm migrating the code from MPC5643L in our own design. the MPC5744P mask is "1N15P" (samples from Arrow Electronics).
The FCCU config is:
void _clearFCCUfaults(void)
{
int32_t i;
for (i=0;i<3;i++)
{
FCCU.NCFK.R = FCCU_NCFK_KEY;
FCCU.NCF_S[i].R = 0xFFFFFFFF;
while (FCCU.CTRL.B.OPS != 0x3);
}
}
void _configFCCU(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
/* Configure FCCU to react on NCF14 with long functional reset */
FCCU.NCFS_CFG[0].R = 0x20000000; //long functional reset reaction
//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
}
Hi,
I tested watchdog in STOP mode and it works correct on my side. I created simple example, which demonstrates the functionality of STP bit in SWT_CR register.
Please see example and also Reset signal. In my example I defined macro STOP_SWT. If this symbol is set to 1, watchdog is stopped in STOP mode, if STOP_SWT is 0, watchdog is running in STOP mode. I tested the example without debugger connected.
First case: SWT is disabled in STOP mode:
1) Reset signal after power on reset
2) Reset signal when microcontroller is running
Second case: SWT is enabled in STOP mode:
1) Reset signal after power on reset
2) Reset signal when microcontroller is running
In the first case you see, there is no reset, because SWT is stopped while microcontroller is in STOP mode (I do not wake up micro from STOP mode in my example).
In the second case there is periodical reset caused by SWT, because SWT is still running, even if microcontroller is in STOP mode.
Please test the example, and let me know if it works on your side.
PS: I did not test your example, but if I were you, I will check the STOP mode at first. Because if there is some pending interrupt or some event, microcontroller does not go to STOP mode and STP bit in SWT has no effect. It is also better to test the example without debugger.
I use MPC5744P 1N15P, so we have the same mask.
Regards,
Martin
Hi,
I test your example in my board, and it works. So I try to find the different from your code, but there no any different with mine, finally I try to remove the debugger, every works fine! Great Thanks!!