Hello ! I am test the stop mode for mpc5744,Peripherals used in the project include CAN,PIT,FlexPWM,ADC,ETIMER,LINFlexD,Watchdog.
I just want to wakeup by the the SIUL2 External Interrupt,but when I go into stop mode,I can still get the message of 0x18000021,how can I close the can module? The mode conversion code is as follows:
void STOP_mode(void)
{
//Enable STOP mode
MC_ME.ME.B.STOP0 = 0x1;
MC_ME.ME.B.HALT0 = 0x1;
//0x00110010;
MC_ME.STOP0_MC.R= 0x00910010;
MC_ME.LP_PC[0].R=0x00000000;//
MC_ME.LP_PC[1].R=0x00000400;//
MC_ME.PCTL30.B.LP_CFG = 0; //PIT
MC_ME.PCTL255.B.LP_CFG = 0;//PWM
MC_ME.PCTL247.B.LP_CFG = 0;//ETIMER_0
MC_ME.PCTL91.B.LP_CFG=0;//
MC_ME.PCTL204.B.LP_CFG=0;//
MC_ME.PCTL124.B.LP_CFG=0;//AD3
MC_ME.PCTL126.B.LP_CFG=0;//AD1
MC_ME.PCTL237.B.LP_CFG=0;//AD0
MC_ME.PCTL77.B.LP_CFG= 0;//CAN_2
MC_ME.PCTL78.B.LP_CFG = 0;//CAN_1
MC_ME.PCTL79.B.LP_CFG = 0;//CAN_0
PIT_0.TIMER[0].TCTRL.B.TIE = 0;//PIT
LINFlexD_0.LINIER.B.DRIE=0;//
LINFlexD_1.LINIER.B.DRIE=0;//
ETIMER_0.CH[4].INTDMA.B.ICF1IE=0;
ETIMER_0.CH[4].INTDMA.B.ICF2IE=0;
ETIMER_0.CH[5].INTDMA.B.ICF1IE=0;
ETIMER_0.CH[5].INTDMA.B.ICF2IE=0;
ETIMER_0.CH[0].INTDMA.B.TCF1IE=0;
CAN_0.IMASK1.R=0;
CAN_0.IMASK2.R=0;
CAN_1.IMASK1.R=0;
CAN_1.IMASK2.R=0;
CAN_2.IMASK1.R=0;
CAN_2.IMASK2.R=0;
CAN_0.MCR.B.MDIS = 1;
CAN_1.MCR.B.MDIS = 1;
CAN_2.MCR.B.MDIS = 1;
//Mode transition to STOP mode with IRC running
MC_ME.MCTL.R = 0xA0005AF0; //STOP Mode & Key
MC_ME.MCTL.R = 0xA000A50F; //STOP Mode & Key
}
Meanwhile,I also don't understand why i can do like this, I am use the SIUL2 External Interrupt Source 21,but i can use the " Vector 243 SIUL2 External Interrupt_0 SIUL2 " , thefor interrupt address .The code is as follows:
(1) Initialize:
SIUL2 External Interrupt
SIUL2.MSCR[104].B.IBE = 1;
SIUL2.IMCR[194].B.SSS=1; //
SIUL2.DIRSR0.B.DIRSR21=0;//
SIUL2.IFEER0.B.IFEE21=1;//
SIUL2.IFER0.B.IFE21=1;//
INTC_0.PSR[243].R = 0x8005;
SIUL2.DIRER0.B.EIRE21=1;//
(2) Vector:
//(uint32_t) &dummy, /* Vector # 243 SIUL2 External Interrupt_0 SIUL2 */
(uint32_t) &SIUL2_External_Isr,
(uint32_t) &dummy, /* Vector # 244 SIUL2 External Interrupt_1 SIUL2 */
(uint32_t) &dummy, /* Vector # 245 SIUL2 External Interrupt_2 SIUL2 */
(uint32_t) &dummy, /* Vector # 246 SIUL2 External Interrupt_3 SIUL2 */
(uint32_t) &dummy, /* Vector # 247 Reserved for SIUL2 External Interrupt_4 SIUL2 */
(uint32_t) &dummy, /* Vector # 248 Reserved for SIUL2 External Interrupt_5 SIUL2 */
(uint32_t) &dummy, /* Vector # 249 Reserved for SIUL2 External Interrupt_6 SIUL2 */
(uint32_t) &dummy, /* Vector # 250 Reserved for SIUL2 External Interrupt_7 SIUL2 */
Hi,
most probably you did not enter stop mode. Before doing mode transition you need to clear all set peripheral flags, so ideally stop timers, halt communications and clear flags which can prevent STOP mode acknowledgement. For CAN module you can request Freeze mode and wait until it is there.
Regrading wrong interrupt vector; you should work with vector #245 for EIRQ21, it worked well on my side.
BR, Petr
The reason why i can received CAN is because i don't stop the watchdog clock on stop mode, now i have stop it like this:
void SWT_Init(uint32_t Time_Out_Ms)
{
SWT_0.SR.R = 0xC520;
SWT_0.SR.R = 0xD928;
SWT_0.TO.R = (Time_Out_Ms*16000);/* Set SWT timeout */
//SWT_0.CR.R = 0xFF000103;
SWT_0.CR.R = 0xFF000107;
}
I want to know if the microcontroller who wake up from the stop mode will restart? because my microcontroller will restart after wake up.
Hi,
upon exit from Stop code continues where it stops.
BR, Petr