Hallo Vicente,
I do the same I think, but it don't work...
Bool ENTER_STOP_MODE = FALSE; // starts in Normal-Mode
Bool MCU_IS_STOPPED = FALSE; // the mcu isn't stopped
void main(void) {// Clear COP Watchdog timeout
SOPT1 = 0x20; // STOPE = 1, SOPT1 Bit5
SPMSC1 &= ~0x0C; // LVDE + LVDSE = 0, SPMSC1 Bit2 + Bit3
SPMSC2 &= ~0x01; // PPDC = 0, SPMSC2 Bit0 Stop3 with BDM
MCGC1 = 0xB8;
MCGC2 = 0x36;
MCGC3 = 0x00;
while(!(MCGSC&0x02)); // Wait until the initialization cycle of the external crystal clock is completed
// isrTimer1 configure and aktivate
TPM1MODH = 0xFD; // Timer1 Overflow
TPM1MODL = 0xD0;
TPM1SC = 0x4F;
MSCANInit();// CAN Schnittstelle initialisieren
// CANCTL0 |= 0x04; // WUPE = 1 ==> MSCAN Wake-Up enable
// CANRIER |= 0x80; // Enable Wake-Up IRQ
// RUN: CANE = 1, CSWAI = X, SLPRQ = 0, SLPAK = 0
// WAIT: CANE = 1, CSWAI = 0, SLPRQ = 0, SLPAK = 0
EnableInterrupts;
for (;;) {
if (ENTER_STOP_MODE) { // enter stopmode
if (!MCU_IS_STOPPED) {
MCU_IS_STOPPED = TRUE; // the mcu is now stopped
CANCTL0 |= 0x02; // SLPRQ = 1 ==> MSCAN SLEEP
CANCTL1 |= 0x02; // SLPAK = 1 ==> MSCAN SLEEP
asm ("STOP"); // switch into stop3 Mode
}
}
}
// The isrTimer1 sets the (Bool ENTER_STOP_MODE = True);
// In my canWakeUp irq I set (ENTER_STOP_MODE = MCU_IS_STOPPED = false) again
// After "asm (STOP);" the mcu ever reset
Thanks for your answer
Tom