Using ADC channels with no pin muxing

On the Freedom K64F board, some ADC channels don’t have to be muxed to a pin
It is not possible to use them as the AnalogIn API expects a PinName argument

I have modified the AnalogIn API to accept an ADCName argument: https://developer.mbed.org/users/jcassette/code/mbed-dev/rev/9f34958201cc

I guess another way is to create “fake” pins in the PinName enum (PinNames.h) and add them in PinMap_ADC (PeripheralPins.c) to map ADC channels

What’s the official way to use peripheral I/O with the API when they don’t have to be muxed to a pin?

You can fake them. There was similar case for DAC which did not have actually any pin, so was set to 0xFFFFFFE to be distinguish.

What else is it required to be changed in mbed-hal-ksdk-mcu/analogin.c file ? You can create an issue with a proposal for the fix in the ksdk mcu hal repository.

Hi Martin,

There is nothing to change in analogin_api.c.
But fake pins need to be created in PinNames.h, which looks to be generated from chip_pins.array.

If we go the “fake pins” route, it would make sense to add every ADC channel (ADCn_xxx).
Don’t you think it is cleaner to add a constructor to the AnalogIn class as I did? I understand changing the API is a bigger deal…

Cheers,
Julien

Hi Juilen and Martin,

I’m new to mbed and I’m disappointed that I cannot use ADC0_DP1, ADC0_DM1, ADC1_DP1 and ADC1_DM1 with AnalogIn() out of the box. I tried to compile within the Compiler Deprecation | Mbed environment the code that Julien has publish but I cannot compile the source obtaining errors in CallChain.cpp (unknown symbols for _size and _elements…). I obtained the same results if I’m importing to my Programs any mbed-src library even without Julien’s modifications. How can I solve the error while compiling mbed-src and use Julien’s modifications to access the 16-bits ADC converter and start my testing.

Regards,

        Sylvain

Hello,

I’m have FRDM-K66F board and I want to use the DAC. Which file shall I modify?

Hello.
Sorry I cannot remember since this was 4 years ago.
I hope this pull request will help you :

Julien