AnsweredAssumed Answered

S12XE ATD on 16 Channels

Question asked by Ray Hall on Aug 10, 2016
Latest reply on Aug 11, 2016 by iggi

I am using the 205 pin BGA version of the S12XE with a bus clock of 50 Mhz and the ATD clock at 1 Mhz.

 

I cannot get the ATD to read values in channels 8 to 15. I have no problem with 0 to 7 channels. Below is my code.

 

Ray.

 

void Init_ATD0(void) {

   

   ATD0CTL1 = 0B00110000;

    //ETRIGSEL - External Trigger Source Select

    //SRES[1:0] - A/D Resolution Select

    //SMP_DIS - Discharge Before Sampling Bit

    //ETRIGCH[3:0] - External Trigger Channel Select

 

  ATD0CTL2 = 0B01000010;

    //Reserved

    //AFFC - ATD Fast Flag Clear All

    //ICLKSTP - Internal Clock in Stop Mode Bit

    //ETRIGLE - External Trigger Level/Edge Control

    //ETRIGP - External Trigger Polarity

    //ETRIGE - External Trigger Mode Enable

    //ASCIE - ATD Sequence Complete Interrupt Enable

    //ACMPIE - ATD Compare Interrupt Enable

 

  ATD0CTL3 = 0B11000000;

    //DJM - Result Register Data Justification (Right Justified)

    //S8C, S4C, S2C, S1C - Converison Sequence Length (8)

    //FIFO - Result Register FIFO Mode (0)

    //FRZ[1:0] - Background Debug Freeze Enable (Finish current converison, then freeze)

 

  ATD0CTL4 = 0B01011111;

    //SMP[2:0] - Sample Time Select (8)

    //PRS[4:0] - ATD Clock Prescaler (ATD clock 1MHz with 50 MHz bus)

 

  ATD0CTL5 = 0B00110000;//start continuous conversion

    //Reserved

    //SC - Special Channel Conversion Bit

    //SCAN - Continuous or Single conversion sequence (Continuous)

    //MULT - Multi-Channel Sample Mode (multichannel)

    //CD, CC, CB, CA - Analog Input Channel Select Code (channel AN0)

}

 

#define ADC_ARRAY  18

volatile uint16_t adcVal[ADC_ARRAY];

 

//-------------------------- ATD0 Interrupt ------------------------------

interrupt void ATD0_ISR(void) {

 

    adcVal[0] = ATD0DR0;

    adcVal[1] = ATD0DR1;

    adcVal[2] = ATD0DR2;

    adcVal[3] = ATD0DR3;

    adcVal[4] = ATD0DR4;

    adcVal[5] = ATD0DR5;

    adcVal[6] = ATD0DR6;

    adcVal[7] = ATD0DR7;

    adcVal[8] = ATD0DR8;

    adcVal[9] = ATD0DR9;

    adcVal[10] = ATD0DR10;

    adcVal[11] = ATD0DR11;

    adcVal[12] = ATD0DR12;

    adcVal[13] = ATD0DR13;

    adcVal[14] = ATD0DR14;

    adcVal[15] = ATD0DR15;   

}

Outcomes