S12XE ATD on 16 Channels

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

S12XE ATD on 16 Channels

Jump to solution
643 Views
rayhall
Contributor V

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;   

}

Labels (1)
0 Kudos
Reply
1 Solution
555 Views
rayhall
Contributor V

These are the correct settings to read from 16 channels.

Ray

void Init_ATD0(void) {

  ATD0CTL1 = 0x30; // 10bit, Discharge before sample

  ATD0CTL2 = 0x42; // Fast Flag Clear All, Complete Interrupt Enable   

  ATD0CTL3 = 0x80; // Right Justified, Converison Sequence Length (16)

  ATD0CTL4 = 0x58; // Sample Time Select 8, ATD clock 1MHz with 50 MHz bus  

  ATD0CTL5 = 0x30; // Continuous conversion sequence, Multi-Channel  

}

View solution in original post

0 Kudos
Reply
2 Replies
556 Views
rayhall
Contributor V

These are the correct settings to read from 16 channels.

Ray

void Init_ATD0(void) {

  ATD0CTL1 = 0x30; // 10bit, Discharge before sample

  ATD0CTL2 = 0x42; // Fast Flag Clear All, Complete Interrupt Enable   

  ATD0CTL3 = 0x80; // Right Justified, Converison Sequence Length (16)

  ATD0CTL4 = 0x58; // Sample Time Select 8, ATD clock 1MHz with 50 MHz bus  

  ATD0CTL5 = 0x30; // Continuous conversion sequence, Multi-Channel  

}

0 Kudos
Reply
555 Views
iggi
NXP Employee
NXP Employee

I just wanted to tell you that Conversion Sequence Length you set to 8 initially should be changed to 16 :-)

0 Kudos
Reply