I am currently trying to optimize the sleep mode in my battery application. I have attempted to disable all GPIO signals and other HC12 subsystems in order to reduce current consumption during sleep. The MSCAN, however, has given me some problems. I have been trying to reduce the CANtx and CANrx signal levels to zero by disabling MSCAN altogether before putting the processor into STOP mode. I then use the respective port M bits as GPIO and set them to output low. I do this with the following code (or variations of it):
CAN0CTL0 &= ~(BIT2); // Disable wakeup from sleep
CAN0CTL0 |= (BIT1); // Enter sleep mode in order to disable CAN
CAN0CTL0 |= (BIT0); // Enter init mode in order to disable CAN
while ((CAN0CTL1 & BIT1)==0)
CAN0CTL1 &= ~(BIT7); // Disable CAN
DDRM.Byte |= (BIT1|BIT0);
PORTM.Byte &= ~(BIT1|BIT0);
// Put processor into STOP mode
CLKSEL.Bits.PSTP = 0;
When I reset and run my target with my BDM emulator (PE Micro) I get the results I expect. In particular, the CANtx and CANrx signals are low. Strangely, when I power cycle my target with the same code and let it run without emulator control, these same signals do NOT go low:
CANtx ~ 4v
CANrx ~ 3.75v
This consequently causes much high power consumption on my target board.
I have tried other configuration scenarios with the CAN including:
1) Don't do anything to it before putting processor into STOP mode.
2) Putting MSCAN only into SLEEP mode before stopping the processor.
None of these have given me the desired results.
Any help would be much appreciated!