我之前在做项目时也遇到过类似问题,后来解决了。
应该主要是进入睡眠前要注意ADC的状态,确保ADC处于不活动的状态。具体的,我记不太清。。。
以下贴一段代码,您可以参考以下。以下代码中有一部分是为了解决STOP状态下,芯片整体电流过大的。
void adc0_DeInit(void)
{
byte tmp_ADCxCTL_0 = ADC0CTL_0; // Save customer settings, these values will be restored afterwards
byte tmp_ADCxTIM = ADC0TIM;
byte tmp_ADCxSTS = ADC0STS;
ADC0CTL_0 = 0x00; // Disable ADC
ADC0TIM = 0x00; // ADC is set to maximum frequency
// Devicespecification of allowed frequency is ignored,
// the ADC conversion is stopped when reaching error state
// There is no conversion result generated.
ADC0CTL_0 = 0x88; // ADC is enabled, single access mode data bus, restart mode
ADC0CTL_0 = 0x88; // Re-do in order to guarantee ADC is ready for requests before Restart Event occurs
ADC0FLWCTL = 0x20; // ADC is restarted, RSTA bit is set: the first command of list 0 is loaded from memory. The command type does not matter, the conversion is immediately stopped
while(ADC0FLWCTL_RSTA == 1) {} // Wait for restart completion (within a few clock cycles)
ADC0FLWCTL = 0x40; // Start conversion (TRIG)
ADC0FLWCTL = 0x40; // The second TRIG immediately generates a TRIG_EIF, ERROR state is entered
while (ADC0EIF_TRIG_EIF ==0) {} // Wait for trigger error interrupt flag (within a few clock cycles)
ADC0CTL_0_ADC_SR = 1; // Execute ADC soft-reset (SR), ADC enters IDLE state
while (ADC0STS_READY == 0) {} // Wait for ADC soft-reset done (within a few clock cycles)
ADC0CTL_0 = 0x00; // ADC is disabled
ADC0TIM = tmp_ADCxTIM; //Restore previous customer settings
ADC0STS = tmp_ADCxSTS;
ADC0CTL_0 = tmp_ADCxCTL_0; // ADC0CTL_0 is the last one to be restored, in case ADC was enabled before...
// ADC0CTL_0 = 0;
// ADC0CTL_0_ADC_EN = 0;
}