AnsweredAssumed Answered

How to use the first argument of fopen for ADC with multiple inputs (e.g. for Kinetis K60)

Question asked by Vladimir Gainov on Mar 25, 2015
Latest reply on Mar 25, 2015 by David E Seymour

From IO_User_Guide it's not clear how to construct the proper name of ADC input channel for fopen call using the template: “<device>:<channel_number>”

For example, there are numerous input port combinations in Kinetis K60 (taken from adc_mk60.h):

#define ADC3_SOURCE_ADPM3       (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(3) | ADC_SOURCE_DIFF)

#define ADC3_SOURCE_AD0         (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(0))

#define ADC3_SOURCE_AD1         (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(1))

#define ADC3_SOURCE_AD2         (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(2))

#define ADC3_SOURCE_AD3         (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(3))

#define ADC3_SOURCE_AD4A        (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_A | ADC_SOURCE_CHANNEL(4))

#define ADC3_SOURCE_AD5A        (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_A | ADC_SOURCE_CHANNEL(5))

#define ADC3_SOURCE_AD6A        (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_A | ADC_SOURCE_CHANNEL(6))

#define ADC3_SOURCE_AD7A        (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_A | ADC_SOURCE_CHANNEL(7))

#define ADC3_SOURCE_AD4B        (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_B | ADC_SOURCE_CHANNEL(4))

#define ADC3_SOURCE_AD5B        (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_B | ADC_SOURCE_CHANNEL(5))

#define ADC3_SOURCE_AD6B        (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_B | ADC_SOURCE_CHANNEL(6))

#define ADC3_SOURCE_AD7B        (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_B | ADC_SOURCE_CHANNEL(7))

#define ADC3_SOURCE_AD8         (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(8))

#define ADC3_SOURCE_AD9         (ADC_SOURCE_MODULE(4) | ADC_SOURCE_MUXSEL_X | ADC_SOURCE_CHANNEL(9))

 

Could anyone please provide an explicit example?

Outcomes