Dear,
I use K70 Kinetis with MQX 3.8.1
I want to read the following adc channels in single ended mode :
PGA0DP_ADC0DP0_ADC1DP3 pin R1
PGA0DM_ADC0DM0_ADC1DM3 pin R2
PGA1DP_ADC1DP0_ADC0DP3 pin T1
PGA1DM_ADC1DM0_ADC0DM3 pin T2
ADC settings per channel :
const ADC_INIT_CHANNEL_STRUCT PP1 =
{
ADC0_SOURCE_ADPM0, /* physical ADC channel */
ADC_CHANNEL_MEASURE_LOOP | ADC_CHANNEL_START_NOW,
4, /* number of samples in one run sequence */
0, /* time offset from trigger point in us */
ADC_SAMPLING_PERIOD, /* period in us */
0, /* scale range of result (not used now) */
4, /* circular buffer size (sample count) */
ADC_PDB_TRIGGER,
&evnWaitAdc,
0x01
};
const ADC_INIT_CHANNEL_STRUCT PP2 =
{
ADC0_SOURCE_ADPM1, /* physical ADC channel */
ADC_CHANNEL_MEASURE_LOOP | ADC_CHANNEL_START_NOW,
4, /* number of samples in one run sequence */
0, /* time offset from trigger point in us */
ADC_SAMPLING_PERIOD, /* period in us */
0, /* scale range of result (not used now) */
4, /* circular buffer size (sample count) */
ADC_PDB_TRIGGER,
&evnWaitAdc,
0x01
};
same for ADC0_SOURCE_ADPM2 and ADC0_SOURCE_ADPM3
I used the pin names as defines in adc_mk70.h :
#define ADC0_SOURCE_ADPM0 (ADC_SOURCE_MODULE(1) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(0) | ADC_SOURCE_DIFF)
#define ADC0_SOURCE_ADPM1 (ADC_SOURCE_MODULE(1) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(1) | ADC_SOURCE_DIFF)
#define ADC0_SOURCE_ADPM2 (ADC_SOURCE_MODULE(1) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(2) | ADC_SOURCE_DIFF)
#define ADC0_SOURCE_ADPM3 (ADC_SOURCE_MODULE(1) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(3) | ADC_SOURCE_DIFF)
I use 12 bit resolution :
const ADC_INIT_STRUCT adc_init = {
ADC_RESOLUTION_12BIT, // 12 bit resolution
};
If I read these channels, it seems that they are in differential mode ??? I get readings (High = 3.3V) in the range of 65535 (16bit) instead of 12 bit 4096 range ??
I suspect that these channels are per default defined as differential pins ??
My first question, how can I set these pins in single ended mode ?
Possible in the mqx adc way? Or should I set this with direct registers?
My second question :
Is it correct to assume that
PGA0DP_ADC0DP0_ADC1DP3 pin R1 corresponds with #define ADC0_SOURCE_ADPM0
PGA0DM_ADC0DM0_ADC1DM3 pin R2 corresponds with #define ADC0_SOURCE_ADPM1
PGA1DP_ADC1DP0_ADC0DP3 pin T1 corresponds with #define ADC0_SOURCE_ADPM2
PGA1DM_ADC1DM0_ADC0DM3 pin T2 corresponds with #define ADC0_SOURCE_ADPM3
This is only a guess, I can not find a direct link(proof) in the manuals.
Anyone can help me with one of my questions ?
Many thanks in advance
Regards,
Michris
Hi Christophe
Was this ever resolved? Can you share what you did to solve the problem?
Regards
Robert
Hello christophe michiels,
any news about ADC? Have you already solved it?
Regards,
MartinK
Hi, Thanks for followup.
No the issue is not yet solved.
I'm in contact with one of your FAEs. Ticket : SR# 1-998416432.
The problem is, on the board of the FAE it works, but on my TWR-K70 it does not work?
We use the same code. Config settings in user_config.h seems ok.
So we have no clue why it does not work on my board?
Regards,
Christophe