9S12G ATD Multi-Channels sample issues

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

9S12G ATD Multi-Channels sample issues

Jump to solution
1,075 Views
grace
Contributor I

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*/
}

Labels (1)
0 Kudos
1 Solution
365 Views
kef
Specialist I

It is not clear what is expected. You set ATDCTL5_SC bit. Do you expect to get conversion results for special channels, Reserved, Vrh, Vrl, etc?

View solution in original post

0 Kudos
2 Replies
366 Views
kef
Specialist I

It is not clear what is expected. You set ATDCTL5_SC bit. Do you expect to get conversion results for special channels, Reserved, Vrh, Vrl, etc?

0 Kudos
365 Views
grace
Contributor I

Kef,

Thanks. You reminds me. ATDCTL5_SC bit should not be set.

0 Kudos