7 years, 4 months ago.

proprietary adc pin use in mbed

Hi

Is it possible to use the number of ADC's on the k64f in mbed from the other pin headers such as ADC0_SE18? i need more than the 6 analog inputs A0-6 and want to know how to access them in code.

Also, is it possible to use the single and dual input analogs all as single input, if so how?

Thanks!

Question relating to:

The Freedom-K64F is an ultra-low-cost development platform for Kinetis K64, K63, and K24 MCUs.

1 Answer

7 years, 4 months ago.

Instead of

AnalogIn ain(A0);

you could

AnalogIn ain(PTB2);

A0 is aliased to PTB2

The available analog pins, multiplexed from 2 x ADC peripheral, are

const PinMap PinMap_ADC[] = {
    {PTA17, ADC1_SE17, 0},
    {PTB0 , ADC0_SE8 , 0},
    {PTB1 , ADC0_SE9 , 0},
    {PTB2 , ADC0_SE12, 0},
    {PTB3 , ADC0_SE13, 0},
    {PTB6 , ADC1_SE12, 0},
    {PTB7 , ADC1_SE13, 0},
    {PTB10, ADC1_SE14, 0},
    {PTB11, ADC1_SE15, 0},
    {PTC0 , ADC0_SE14, 0},
    {PTC1 , ADC0_SE15, 0},
    {PTC2,  ADC0_SE4b, 0},
    {PTC8,  ADC1_SE4b, 0},
    {PTC9,  ADC1_SE5b, 0},
    {PTC10, ADC1_SE6b, 0},
    {PTC11, ADC1_SE7b, 0},
    {PTD1,  ADC0_SE5b, 0},
    {PTD5,  ADC0_SE6b, 0},
    {PTD6,  ADC0_SE7b, 0},
    {PTE0,  ADC1_SE4a, 0},
    {PTE1,  ADC1_SE5a, 0},
    {PTE2,  ADC1_SE6a, 0},
    {PTE3,  ADC1_SE7a, 0},
    //{PTE24, ADC0_SE17, 0}, //I2C pull up
    //{PTE25, ADC0_SE18, 0}, //I2C pull up
    {NC   , NC       , 0}
};

Thanks

Can i set PTE24/5 to analog input then by uncommenting this? if so where do i find it?

I take it any ADC not mapped to a pin as above isnt actually usable such as ADC1_SE18 mentioned above even though its on the header along with the adcx_dpx and adcx_dmx on header j4 odd??

posted by Guy Willetts 17 Jul 2017

Since you just need additional analog inputs, you can use other pins which are not used. Why must you use ADC0_SE17 and ADC0_SE18?

If you reaĺly want to do so, download the whole mbed source code from github, modify the file in https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/TARGET_FRDM/PeripheralPins.c

Compile it using gcc or any supported IDE.

posted by HM Yoong 17 Jul 2017