Hi, I'm trying the LLS sleep on K20DX 72Mhz
I've followed Starting Point for Kinetis Low Power LLS Mode | MCU on Eclipse - really fantastic - thankyou Eric.
The target environment I'm defining is - do some processing then go to sleep for ~5-15minutes. So I use the LPTMR0 for a short term 100mS interrupts, then use the RTC alarm for the longer term sleep.
I have a 32KHz external Xtal and that is used as the basis for the LPO_1Khz clock.
The board is a custom board - and only has on it the MK20DX126VLH7, 32KHz xtal, and 10K Pullup for JTAG.
For debugging I've set it "processing" to a couple of seconds (flash a LED to to see its working -but ignore it for current consumption) and then sleep 30 seconds - when I can measure sleep current
I can get down to about 160uA while LLS sleep - but haven't been able to reduce it further.
The MK20P64M72SF1 datasheet suggests that IDD_LLS Max@25C of about 8.6uA.
I've got a "compile debug" flag that I've set to be able to read and list internal registers - and then disable the outputing for the current measurement when the program is operating correctly.
If I take it to a VLSS3 - I still have about 160uA - which makes me think there is a module enabled taking current
I've experimented with turning off as many modules as I can see are enabled by Generated_Code\Cpu.c (included below) - but no luck.
I wonder if anybody has some suggestions?.
Many thanks in advance
Cpu.c: void PE_low_level_init(void)
{
/* Initialization of the SIM module */
/* PORTA_PCR4: ISF=0,MUX=7 */
PORTA_PCR4 = (uint32_t)((PORTA_PCR4 & (uint32_t)~(uint32_t)(PORT_PCR_ISF_MASK)) | (uint32_t)(PORT_PCR_MUX(0x07) ));
/* Initialization of the RCM module */
/* RCM_RPFW: RSTFLTSEL=0 */
RCM_RPFW &= (uint8_t)~(uint8_t)(RCM_RPFW_RSTFLTSEL(0x1F));
/* RCM_RPFC: RSTFLTSS=0,RSTFLTSRW=0 */
RCM_RPFC &= (uint8_t)~(uint8_t)( RCM_RPFC_RSTFLTSS_MASK | RCM_RPFC_RSTFLTSRW(0x03) );
/* Initialization of the FTFL_FlashConfig module */
/* Initialization of the PMC module */
/* PMC_LVDSC1: LVDACK=1,LVDIE=0,LVDRE=1,LVDV=0 */
PMC_LVDSC1 = (uint8_t)((PMC_LVDSC1 & (uint8_t)~(uint8_t)( PMC_LVDSC1_LVDIE_MASK | PMC_LVDSC1_LVDV(0x03))) | (uint8_t)( PMC_LVDSC1_LVDACK_MASK | PMC_LVDSC1_LVDRE_MASK));
/* PMC_LVDSC2: LVWACK=1,LVWIE=0,LVWV=0 */
PMC_LVDSC2 = (uint8_t)((PMC_LVDSC2 & (uint8_t)~(uint8_t)( PMC_LVDSC2_LVWIE_MASK | PMC_LVDSC2_LVWV(0x03))) | (uint8_t)( PMC_LVDSC2_LVWACK_MASK));
/* PMC_REGSC: BGEN=0,ACKISO=0,BGBE=0 */
PMC_REGSC &= (uint8_t)~(uint8_t)( PMC_REGSC_BGEN_MASK | PMC_REGSC_ACKISO_MASK | PMC_REGSC_BGBE_MASK );
/* Initialization of the LLWU module */
/* LLWU_PE1: WUPE3=0,WUPE0=0 */
LLWU_PE1 &= (uint8_t)~(uint8_t)((LLWU_PE1_WUPE3(0x03) | LLWU_PE1_WUPE0(0x03)));
/* LLWU_PE2: WUPE7=0,WUPE6=0,WUPE5=0,WUPE4=0 */
LLWU_PE2 = LLWU_PE2_WUPE7(0x00) |
LLWU_PE2_WUPE6(0x00) |
LLWU_PE2_WUPE5(0x00) |
LLWU_PE2_WUPE4(0x00);
/* LLWU_PE3: WUPE11=0,WUPE10=0,WUPE9=0,WUPE8=0 */
LLWU_PE3 = LLWU_PE3_WUPE11(0x00) |
LLWU_PE3_WUPE10(0x00) |
LLWU_PE3_WUPE9(0x00) |
LLWU_PE3_WUPE8(0x00);
/* LLWU_PE4: WUPE15=0,WUPE14=0,WUPE13=0,WUPE12=0 */
LLWU_PE4 = LLWU_PE4_WUPE15(0x00) |
LLWU_PE4_WUPE14(0x00) |
LLWU_PE4_WUPE13(0x00) |
LLWU_PE4_WUPE12(0x00);
/* LLWU_ME: WUME7=0,WUME5=1,WUME4=0,WUME3=0,WUME2=0,WUME1=0,WUME0=1 */
LLWU_ME = (uint8_t)((LLWU_ME & (uint8_t)~(uint8_t)( LLWU_ME_WUME7_MASK | LLWU_ME_WUME4_MASK | LLWU_ME_WUME3_MASK | LLWU_ME_WUME2_MASK | LLWU_ME_WUME1_MASK ))
|(uint8_t)( LLWU_ME_WUME5_MASK | LLWU_ME_WUME0_MASK ));
/* LLWU_FILT1: FILTF=1,FILTE=0,??=0,FILTSEL=0 */
LLWU_FILT1 = LLWU_FILT1_FILTF_MASK | LLWU_FILT1_FILTE(0x00) | LLWU_FILT1_FILTSEL(0x00);
/* LLWU_FILT2: FILTF=1,FILTE=0,??=0,FILTSEL=0 */
LLWU_FILT2 = LLWU_FILT2_FILTF_MASK | LLWU_FILT2_FILTE(0x00) | LLWU_FILT2_FILTSEL(0x00);
/* LLWU_RST: ??=0,??=0,??=0,??=0,??=0,??=0,LLRSTE=1,RSTFILT=0 */
LLWU_RST = LLWU_RST_LLRSTE_MASK;
/* SMC_PMPROT: ??=0,??=0,AVLP=1,??=0,ALLS=1,??=0,AVLLS=1,??=0 */
SMC_PMPROT = SMC_PMPROT_AVLP_MASK | SMC_PMPROT_ALLS_MASK | SMC_PMPROT_AVLLS_MASK; /* Setup Power mode protection register */
/* Common initialization of the CPU registers */
/* NVICIP20: PRI20=0 */
NVICIP20 = NVIC_IP_PRI20(0x00);
/* NVICIP21: PRI21=0 */
NVICIP21 = NVIC_IP_PRI21(0x00);
/* NVICISER0: SETENA|=0x00200000 */
NVICISER0 |= NVIC_ISER_SETENA(0x00200000);
(void)BitIoLdd1_Init(NULL); LedRed_Init();
(void)BitIoLdd2_Init(NULL); LedGrn_Init();
/* ### TimerInt_LDD "TimerIntLdd1" component auto initialization. Auto initialization feature can be disabled by component property "Auto initialization". */
(void)TimerIntLdd1_Init(NULL);
/* ### Asynchro serial "AS1" init code ... */
AS1_Init();
/* ### Shell "CLS1" init code ... */
CLS1_Init(); /* initialize shell */
/* Enable interrupts of the given priority level */
Cpu_SetBASEPRI(0U);
}