Hello
Same problem here. I am using a mc9s08qe8, and when I enter low power mode, and been SPMSC2_LPRS set, my power consumption just with the microcontroller and 32Khz crystal goes up to 1mA @2V, 1,1ma@3V. After trying a lot of codes I've used the functions in the demoqe08 to enter low power run mode. Most perhiperals are clock gated, so I am lost.
//CODE/////////////////////////////////////////////////
// enable STOP, BDM, RST and RSTO
SOPT1 = SOPT1_STOPE_MASK|SOPT1_BKGDPE_MASK;
// Disable LVD
SPMSC1 = 0x00;
// Enable (but don't select) stop2 mode
SPMSC2_PPDE = 1; //PPDE is write once, so set during MCU initialization
//ICS_Config(0x00,0x07,NVICSTRM,0x20);
/* System clock initialization */
/* ICSC1: CLKS=2,RDIV=0,IREFS=0,IRCLKEN=0,IREFSTEN=0 */
ICSC1 = 0x80; /* Initialization of the ICS control register 1 */
/* ICSC2: BDIV=0,RANGE=0,HGO=0,LP=0,EREFS=1,ERCLKEN=0,EREFSTEN=0 */
ICSC2 = 0x04; /* Initialization of the ICS control register 2 */
while(!ICSSC_OSCINIT) { /* Wait until the initialization of the external crystal oscillator is completed */
}
/* ICSSC: DRST_DRS=0,DMX32=0 */
ICSSC &= (unsigned char)~0xE0; /* Initialization of the ICS status and control */
while((ICSSC & 0xC0) != 0x00) { /* Wait until the FLL switches to Low range DCO mode */
}
//WaitNms(1);
/* SCGC1: TPM2=0,TPM1=0,ADC=0,IIC=0,SCI=0 */
SCGC1 &= (unsigned char)~0x75;
/* SCGC2: DBG=0,FLS=0,IRQ=0,KBI=0,ACMP=0,RTC=0,SPI=0 */
SCGC2 &= (unsigned char)~0xFD;
ICS_Config(0x80,0x0F,NVICSTRM,0x20);
WaitNms(1);
SPMSC2_LPR = 1; // Enter LPRun Mode
//////////////////////////////////////////////////////
////////////////////////////////////////
#define IREFS_INTERNAL 0x04
void ICS_Config(unsigned char CTL1, unsigned char CTL2,byte TrimValue, byte CTL3)
{
if(CTL1 & IREFS_INTERNAL)
{
/* internal clock reference is */
ICSC1 = CTL1; /* init ISC control register 1 */
ICSC2 = CTL2; /* init ISC control register 2 */
ICSTRM = (unsigned char)TrimValue;
ICSSC = CTL3; /* init ISC control register 3 */
if(ICSC1_CLKS == 0b01){
/* FBI Mode wait for CLKST */
while (ICSSC_CLKST != ICSC1_CLKS);
}
else {
/* FEI Mode wait for CLKST and DRST */
while (ICSSC_CLKST != ICSC1_CLKS);
while ((ICSSC&ICSSC_DRST_DRS_MASK) != (CTL3&ICSSC_DRST_DRS_MASK) );
}
}
else
{
ICSC2 = CTL2; /* init ISC control register 2 */
ICSC1 = CTL1; /* init ISC control register 1 */
ICSSC = CTL3;
/* wait for CLKST and OSCINIT */
while (ICSSC_CLKST != ICSC1_CLKS);
while (!ICSSC_OSCINIT);
}
}
/////////////////////////////////////////////////////////////////////////
Any ideas or code would be greatly apreciated.
Thanks in advance to anyone who can help.
My code: