ADC module when S12ZVML STOP to WeakUP

cancel
Showing results for 
Search instead for 
Did you mean: 

ADC module when S12ZVML STOP to WeakUP

230 Views
SCort_li
Contributor I

ADC 可以在 CPU 停止之前收集正确的值。停车和醒来后,ADC 模块收集的数字始终为 0.有人知道这是为什么吗?

期待您的帮助。

 

The ADC can collect the correct value before the CPU stops. After parking and waking up, the number collected by the ADC module is always 0. Does anyone know why?

0 Kudos
3 Replies

222 Views
ArchieLuo
Contributor II

我之前在做项目时也遇到过类似问题,后来解决了。

应该主要是进入睡眠前要注意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;
}

185 Views
SCort_li
Contributor I

感谢老铁的回复!

0 Kudos

178 Views
ArchieLuo
Contributor II

同是天涯汽车人,客气啥~

0 Kudos