AnsweredAssumed Answered

How to change an ADC channel to another

Question asked by alejandro garcia on Dec 6, 2012
Latest reply on Dec 10, 2012 by Petr_H

How to change an ADC channel to another, I'm using two ADC channels, one differential and one common mode, with Processor Expert

//CHANNEL 0:

//--------------------------------------------

     clrReg32Bits(PORTE_PCR22, 0x01000700U);

        ADC_TP = ADC1_CreateSampleGroup(ADC1_DeviceData,1,1U);      

        ADC_TP = ADC1_StartSingleMeasurement(ADC1_DeviceData);

        while(!ADC1_GetMeasurementCompleteStatus(ADC1_DeviceData));

        ADC_TP  = ADC1_GetMeasuredValues(ADC1_DeviceData,&adc_buffer);

        adc_result =(uint16_t)adc_buffer;

        if(adc_result < 0x8000){adc_result = 0;

        }else{adc_result -= 0x8000;}

           

        Temp_hambiente = (adc_result * 0.000036621);

        Temp_hambiente -= 0.424;

        Temp_hambiente  = (Temp_hambiente / 0.00625);

//CHANNEL 1:

//--------------------------------------------

        clrReg32Bits(PORTE_PCR20, 0x01000700U); /* MUX=0x00U */

        clrReg32Bits(PORTE_PCR21, 0x01000700U); /* MUX=0x00U */

    

          ADC_TP = ADC1_CreateSampleGroup(ADC1_DeviceData,0,1U);      

        ADC_TP = ADC1_StartSingleMeasurement(ADC1_DeviceData);

        while(!ADC1_GetMeasurementCompleteStatus(ADC1_DeviceData));

        ADC_TP  = ADC1_GetMeasuredValues(ADC1_DeviceData,&adc_buffer);

        adc_result =(uint16_t)adc_buffer;


Outcomes