Hi,
I am trying to read ADC value from a pot.
The chip configuration is MK20DX256VLL10 and software i used KDS3.0+ KSDK1.2+PEx.
I am sure there is no problem with hardware since it works in my old code with KDS2.0+PEx.
So I am thinking my ADC configuration and code sequence might went wrong. I checked
example code and couldnt figure out what went wrong.
Every time i run the code, the ADC value jumped from 255 to 0. It made no difference when I plug and
unplug pot. I have attached my code project and configuration screen shot.
Could someone help? Thanks in advance.
Yaran
Original Attachment has been moved to: adc_test.zip
Hello Yaran,
- Does the channel is right ?
- I recommend you use the latest version of KSDK1.3 , you can download it here :
https://freescale.flexnetoperations.com/control/frse/product?child_plneID=695287
Under the ksdk1.3 install directory , there is a adc16 demo , i have test the demo on
TWRK21D50m board , i think it is the same with your chip, you can refer to .
The demo is here : KSDK_1.3.0\examples\twrk21d50m\driver_examples\adc16
Hope it helps
Alice
Hi Alice,
Thanks for your attention. Firstly, I don't think i will switch KSDK1.3 for
now, but I will research more about it to know the differences with KSDK1.2.
Secondly, I am working on a project which is in a critical time schedule.
Back to the question I was asking above, I tried ksdk1.2 ADC demo example
for twrk60, it works as well. I dont doubt there is something wrong with sample code.
It just i am using process expert at the same time, i am thinking I did something with
one or some of component configuration parameters.
Lastly I am pretty sure i used correct channel. That was the first thing i check.
If you have a time to take a look, that would be great.
Thanks in advance,
Yaran
Hello Yaran,
Ok, i create one ADC sample project on SDK1.2+PE, while for i have not the MK20DX256VLL10 chip , i test on K21D50,
while it is the same , please see the attachment . And when i change the resistance values , the ADC will changed , this screenshot
is the result i test on my side :
- I checked your project about the configuration of fsl_adc16 component , it have no error , my project is the same with yours (except the ADC chn).
So , i think you should be sure what about your ADC signal , you'd better check it use the oscilloscope or other instruments .
And also i don't know whether is the reason of MQX , could you please first create one simple bareboard project , only add fsl_adc , like my project(or directly
copy my code ), test whether it can work well .
Hope it helps
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Have a great day,
Alice
Hi Alice,
I got it working. The reason is beside of the code, i have to add another line of code to
configure channel (which is channel b in my project). I thought i set up pin at PE configuration.
Thanks for your helps though.
Yaran