I started the subclock oscillator and shifted AGT 1 over to that clock source. That lets me shut down the LOCO as well. My oscilloscope shows me that the main oscillator is stopped and that the subclock oscillator is running. If I breakpoint the call to g_lpm0.p_api- wupenSet(), I can see that the HOCO, MOCO, and LOCO are all stopped and that SOPCCR.SOPCM is set. Power consumption is still 700 uA. That persists even if I disconnect the debugger USB cable and power cycle the board with an external supply at connector J1. I even tried grounding pin 13 of connector J15 to hold the debugger processor in reset thinking that maybe the debugger is keeping me out of subclock speed mode. No help. The function currently looks like this: #define WUPEN_AGT1_UNDERFLOW_MASK (1 28) // Wake the processor up on AGT 1 underflow only. void sleepProcessorMs(uint32_t ms) { static const cgc_system_clock_cfg_t normalClockConfig = { .iclk_div = BSP_CFG_ICK_DIV, .pclkb_div = BSP_CFG_PCKB_DIV, .pclkd_div = BSP_CFG_PCKD_DIV }; static const cgc_system_clock_cfg_t slowClockConfig = { .iclk_div = CGC_SYS_CLOCK_DIV_1, .pclkb_div = CGC_SYS_CLOCK_DIV_1, .pclkd_div = CGC_SYS_CLOCK_DIV_1 }; static bool state = false; /* Wind up our timer. */ g_timer0.p_api- periodSet(g_timer0.p_ctrl,ms,TIMER_UNIT_PERIOD_MSEC); /* * Do the rest of this with the interrupts disabled so that we don't get * stuck in software standby mode if this code is breakpointed and so that * we don't service any complicated interrupts with the clock running slow. */ __disable_irq(); /* Start our timer. */ g_timer0.p_api- start(g_timer0.p_ctrl); /* Switch the clock to the watch crystal oscillator then drop the processor to low speed mode. */ g_cgc.p_api- systemClockSet(CGC_CLOCK_SUBCLOCK,(cgc_system_clock_cfg_t *)&slowClockConfig); g_cgc.p_api- clockStop(CGC_CLOCK_MAIN_OSC); g_cgc.p_api- clockStop(CGC_CLOCK_MOCO); g_cgc.p_api- clockStop(CGC_CLOCK_LOCO); g_cgc.p_api- clockStop(CGC_CLOCK_HOCO); g_lpm0.p_api- operatingPowerModeSet(LPM_OPERATING_POWER_LOW_SPEED_MODE, LPM_SUBOSC_SELECT); /* Configure the processor to exit low-power mode on AGT 1 underflow. */ g_lpm0.p_api- wupenSet(WUPEN_AGT1_UNDERFLOW_MASK); /* Put the processor into software standby mode. */ g_lpm0.p_api- lowPowerCfg(LPM_LOW_POWER_MODE_STANDBY, LPM_OUTPUT_PORT_ENABLE_RETAIN, LPM_POWER_SUPPLY_DEEPCUT0, LPM_IO_PORT_NO_CHANGE); g_lpm0.p_api- lowPowerModeEnter(); /* Raise the processor to high-speed mode then switch the clock back to the HOCO. */ g_lpm0.p_api- operatingPowerModeSet(LPM_OPERATING_POWER_HIGH_SPEED_MODE, LPM_SUBOSC_OTHER); g_cgc.p_api- clockStart(CGC_CLOCK_HOCO,&dummyPLLConfig); g_cgc.p_api- systemClockSet(CGC_CLOCK_HOCO,(cgc_system_clock_cfg_t *)&normalClockConfig); /* And we're out of the touchy bits. */ __enable_irq(); /* Use 'scope on P1_6 to see how often this exits. */ state = !state; g_ioport.p_api- pinWrite(IOPORT_PORT_01_PIN_06,state); } Now what?
↧