I am trying to test our ADC on a custom board using mqx 3.8.1. and CW10.3. I downloaded and built the example mqx 3.8.1 app: adc_twrk40x256 without error, but this is set to use a twrk40dx256 and we are using our custom board with a k20dx256z part and not a Tower module.
We are using the bsp for the twrk40dx256, so I looked in the twrk40x256.h file and can see a definition for ADC1_SOURCE_AD1, but I don't know what that translates to; is this ADC1_DP1, or ADC1_DM1, or the differential pair??
We want to use a SE (single ended), ADC1_DM1 pin 15 for conversion. Can someone suggest how I go about making a definition for that channel please?
I tried following the declarations in the debugger but I do not get a specific define that I can relate to the base package. Thanks for the help.
ADC1_DM1 is name of pin for differential negative input of ADC. You need to find assigned single ended ADC channel to this name.
Open RM of your chip. There is table ADC1 Channel Assignment.(chapter 18.104.22.168.1 in K20P100M72SF1RM).
If you want to use ADC1_DM1 as single ended you need to check this input signal in right column of table (When DIFF is 0).
Then you need to check channel column to assign channel to your ADC1_DM1(Channel AD20 in my RM).
Now you are working with ADC1_SOURCE_AD20 in MQX and it should works.
PS.Make sure that your ADC driver use correct file for your chip family .(\mqx-repo\mqx\source\io\adc\kadc\adc_mk20.h).
Thank you for the help.
I can see the channel and input signal I want in the table, ADC0_DP1, but the problem I have is I do not know how to define this for MQX. I am using the example mqx project code adc_twrk40x256
Can you recommend or point me to any other sample code to test the adc under MQX?
Thank you for checking; no it is not sorted out yet. I get the code to build, but it will only read once correctly then never again. Should I create a new discussion, or continue with this issue here? The sample code didn't work well for me.
continue discussion here if required and it's still not sorted out yet :smileywink: Why does it read only once ? Have you checked flags in ADC registers? What does it return?
I do not know why it only reads 1 - 3 times. I tried changing the number of samples to a lower number but that did not change the problem result.
I think it is related to the PDB. We are using just the code for a single channel from the example code. It compiles and loads and runs without error, but after 1 - 3 samples always traps on the fail printf. I am assuming that it is the ADC not completing a read in the required time but I don't know.
Can you suggest anything for me to check?
There are definitions in mentioned file (\mqx-repo\mqx\source\io\adc\kadc\adc_mk20.h). You can check MQX name of your pin there. There is defined if the pin is single ended or differential. Name for ADC0_DP1 is ADC0_SOURCE_AD1. This name you can use as any other single ended channel and it should works.
Answers for your questions:
Almost all kinetis board use potentiometer connect to differential input. We used it in way i described.
adc_demo should be enough for testing. Other examples are more complex and not point only on ADC.
I hope this information's should help you.