AnsweredAssumed Answered

How to initialize the ADC into continuous conversion mode?

Question asked by 卢 正弘 on Jun 7, 2019
Latest reply on Jun 10, 2019 by Edward Karpicz

I have met some problem when using ADC12B_LBA_V1 module on the MC9S12ZVC192(64 pin).

The hardware I use is the NXP official DEVKIT-S12ZVC board.

I want to use the ADC module in continuous conversion mode like the reference manual says:

>>

Applications that only need to continuously convert a list of channels, without the need for timing control

or the ability to perform different sequences of conversions (grouped number of different channels to

 

convert) can make use of the following simple setup:

• “Trigger Mode” configuration

• Single buffer CSL

• Depending on data transfer rate either use single or double buffer RVL configuration

• Define a list of conversion commands which only contains the “End Of List” command with automatic wrap to top of CSL

After finishing the configuration and enabling the ADC an initial Restart Event is sufficient to launch the

continuous conversion until next device reset or low power mode

>>

so I initial the ADC module in this way:

>>

volatile u32 __attribute__ ((aligned (4))) adc0_cmdlist[2] = {
0x00D04000UL,
0x80D14000UL};
volatile u16 __attribute__ ((aligned (4))) adc0_results[16]={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void ADC_init(void){
u16 tmp;
ADC0CTL_0 = 0x0D; /*Dual Access mode and trigger mode selected */
ADC0CTL_1 = 0x00; /* Single command and result value list */
ADC0TIM = 0x07; /*  prescaler selected \*/
ADC0FMT = 0x82; /*Right justified and 10 bit resolution*/

/* ADC0 Command & Result Base Pointers */
ADC0CBP_0 = (unsigned char)(((long)adc0_cmdlist) >> 16);
ADC0CBP_1 = (unsigned char)(((long)adc0_cmdlist) >> 8);
ADC0CBP_2 = (unsigned char)((long)adc0_cmdlist);

// ADC0 Result Base Pointer
ADC0RBP_0 = (unsigned char)(((long)adc0_results) >> 16);
ADC0RBP_1 = (unsigned char)(((long)adc0_results) >> 8);
ADC0RBP_2 = (unsigned char)((long)adc0_results);
ADC0CTL_0_ADC_EN= 1;/* Enables the ADC*/
for(tmp=0;tmp<10000;tmp++){}
ADC0FLWCTL_RSTA=1;
for(tmp=0;tmp<10000;tmp++){}

}

>>

When I try to periodically read the conversion result  of AN1 by 'my_result=adc0_results[1]', I found that the value does not change at all although I have changed the position of the potentiometer on the DEVKIT-S12ZVC board which is linked to the AN1.

Since I think it is initialized into the continuous conversion mode, I do not give one more trigger or restart event after initialization and directly read the conversion result per 10 ms:

void TenmsInt(void)
{
   my_result = adc0_results[1];
}

So anyone can help me to figure out where is the problem?

 

Outcomes