Hi,
i were checking the <adc_test.c> example but it doesn't seem right.
uint16 adc_read(uint8 channel)
{
ADC0_SC1A = !AIEN_ON | DIFF_SINGLE | ADC_SC1_ADCH(channel) ; // start conversion
while((ADC0_SC1A & ADC_SC1_COCO_MASK)!= 0){};
return ADC0_RA;
}
Page 453 of KL15P80M48SFORM.pdf
7 COCO
Conversion Complete Flag
Field Description
This is a read-only field that is set each time a conversion is completed when the compare function is
disabled, or SC2[ACFE]=0 and the hardware average function is disabled, or SC3[AVGE]=0. When the
compare function is enabled, or SC2[ACFE]=1, COCO is set upon completion of a conversion only if the
compare result is true. When the hardware average function is enabled, or SC3[AVGE]=1, COCO is set
upon completion of the selected number of conversions (determined by AVGS). COCO in SC1A is also set
at the completion of a calibration sequence. COCO is cleared when the respective SC1n register is written
or when the respective Rn register is read.
0 Conversion is not completed.
1 Conversion is completed.
So we start conversion and wait while Conversion is completed...