We want to use ADC operation of KL17 in our project. We are requiring ADC operation for mutilple analog inputs.
Since in KL17 we can perform ADC operation for only one channel at a time, we are doing ADC operation for next channel once first channel's ADC conversion is done. The next ADC channel is selected by writing SC1A register in Interrupt routine of first conversion.
ADC0 is configured as follows -
1) ADC0 is used as single ended 10 bit conversion mode with normal power configuration and long sample time disabled .
2) Input clock is selected as bus clock with divide ratio of 1.
3) ADC trigger is selected as software trigger.
4) Volatage reference source selected as external reference voltage source - VREFH and VREFL.
Following are the registers configured before triggering ADC conversion -
SIM_SCGC6 - Set bit 27 of this SFR to enable ADC0 clock gate.
ADC0_CFG1 - 0x00000008 //Normal powered ADC
//Clock source selected as input bus clock with devide ratio of 1
//Short sample time
//10 bit single ended ADC operation
ADC0_SC2 - 0x00000000 //Select ADC trigger as software trigger
//Disable compare function
//Select ADC reference voltage source as defualt voltage reference source i.e. VREFH and //VREFL
ADC0_SC3 - 0x00000000 //SC3 register feature are not used thus keeping its value 0.
Then write ADC0_CFG2 register to select channel a or b and then trigger the ADC operation by writing ADC0_SC1A register for first channel.
Selecting next channel and triggering ADC conversion for next channel is handled in Interrupt routine of ADC conversion.
We are trying to test this ADC functionality on FRDM-KL43Z freedom board but we are facing following problem -
Either we provide or not provide some input on analog pin -
For all channels, we are getting ADC value as 1023 if VREFH is not provided by keeping jumper J19 open .
For all channels, we are getting ADC value between 550 - 600 if VREFH is provided by shorting J19 jumper.
Could you please tell why we are facing above problem and not getting exact ADC value for individual channels ?
Are we missing something in ADC configuration or to test on FRDM-KL43Z freedom board?
Thanks and Regards,