AnsweredAssumed Answered

9S12G ATD Multi-Channels sample issues

Question asked by Yiye Lv on Dec 24, 2010
Latest reply on Dec 27, 2010 by Yiye Lv

Hi Expert,

I use 9S12G ATD Multi-Channels sample feature but the result is not as expected. AN0~AN8 will be sampled during each ATD multi-channels conversion. I read register ATDDRn and ATDDRn are not correct after conversion is completed. Please help analyze the issue.

/* ===========================================================================
*   Function:   ATD  initial
* ========================================================================= */

void ADC_MultInit(void)

{
    ATDCTL0=ATDCTL0_WRAP3_MASK;
    ATDCTL1=0x00;
    ATDCTL2=0x00;
    ATDCTL3=ATDCTL3_DJM_MASK +ATDCTL3_S8C_MASK+ATDCTL3_S1C_MASK;
    ATDCTL4=ATDCTL4_PRS2_MASK;

    ATDDIEN = (u16)(ATDDIEN_IEN9_MASK + ATDDIEN_IEN10_MASK + ATDDIEN_IEN11_MASK);

 

    ATDCTL5=ATDCTL5_SC_MASK + ATDCTL5_MULT_MASK;  /*Start mult convert*/
}

 

 

#define ATDDR_PTR(channel)  *(ATDDR_ARR + (channel))

 

/* ===========================================================================
*   Function:   Read ATD convert value one by one
*
* ========================================================================= */
void ADC_Service(void)
{
    if (ATDSTAT0_SCF)
    {
        for (ucIndex=0;ucIndex<eADC_MAX;ucIndex++)
        {
        /*Save current conversion value to average buffer*/
            stAdcBufferObj_s[ucIndex].aucAdcAvgCnt[0]=(u8)ATDDR_PTR(ucIndex);
        }
        ATDSTAT0_SCF = 1;
    }
    ATDCTL5=ATDCTL5_SC_MASK + ATDCTL5_MULT_MASK;      /*Mult convert go on*/
}

Outcomes