Hi, I'm trying to develop a new board with the MKV30F64VMF10 and I'm testing my new hardware now; The problem I have is readind ADC in single-ended on ADC0_SE4a because I have a big value ascillation. I started with Processor Expert but after a while I started with a new empty project. My very simple code is this:
/* Write your code here */
//16 bit unsigned result
unsigned short Value;
//Enable port E
SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK;
//Enable ADC0
SIM_SCGC6 |= SIM_SCGC6_ADC0_MASK;
//ADC0 in 16bit mode, long time sample, input clock / 8
ADC0_CFG1 = ADC_CFG1_ADIV(3) | ADC_CFG1_ADLSMP_MASK | ADC_CFG1_MODE(0x03);
//Disable conversion
ADC0_SC1A = ADC_SC1_ADCH(31);
//my loop
for (;;) {
//select AD4 (ADC0_SE4a) and start the conversion
ADC0_SC1A |= 4 & ADC_SC1_ADCH_MASK;
//Wait while conversion is in progress
while(ADC0_SC2 & ADC_SC2_ADACT_MASK);
//Wait until conversion complete
while(!(ADC0_SC1A & ADC_SC1_COCO_MASK));
//Delay between end of conversion and read value (nedeed???)
Delay(0xFFFF);
//Read 16 bits conversion value
Value = ADC0_RA;
}\\ end of loop
//The simpliest delay function...
void Delay(unsigned long Ritardo) {
while (Ritardo) {
Ritardo--;
}
}
If I force elettrically the input pin (n° 3 in my package) to GND I always read values from 48000 to 52000 (but I expect to read about 0). If I put 1.2V on the same pin I read values from 44000 to 50000 (but I expect to read about 23800... If I do the same things with ADC0_SE17 (pin 10, changing the bolded line with the neew ADC0_SC1A |= 17 & ADC_SC1_ADCH_MASK) or ADC0_SE15 (pin 22, chancging the same line with ADC0_SC1A |= 15 & ADC_SC1_ADCH_MASK) I read about 0 in the first sample and about 24000 in the second... CORRECT!
What I'd like to know is if there are differences between ADx channels and ADxa/ADxb channels. (ADC0_SE4a and ADC0_SE15 for example)
Data sheet about MKV30F64VMF10 reports:

Is there something I don't understand on how to use this channels?
I thank you in advance for your help.
Regards,
Nicola