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;
Hello,
Could you please post more details on which MCU do you use and which ADC channels do you use?
A sample project or a .pe file with components settings would be helpful.
best regards
Petr Hradsky
Processor Expert Support Team