An Analog-to-Digital Converter (ADC) is a device that translates an analog voltage to a digital value that a microprocessor can understand.

The MCA ADC controllers are 12-bit resolution, right justified, unsigned format. The MCA ADC channels are suitable for low-frequency sampling (under 10 Hz).

Available ADC pins

On the ConnectCore 8M Mini system-on-module:

  • Five MCA pads can be configured as ADC channels:

    • MCA_IO1

    • MCA_IO2

    • MCA_IO3

    • MCA_IO4

    • MCA_IO14

On the ConnectCore 8M Mini Development Kit:

  • The following ADC channels are accessible on the XBee Cellular socket J39-J40:

    • MCA_IO1 (MCA ADC channel 1)

    • MCA_IO2 (MCA ADC channel 2)

    • MCA_IO3 (MCA ADC channel 3)

    • MCA_IO4 (MCA ADC channel 4)

Formula

The value read on the ADC inputs responds to the formula:

\$V_(READ) = (V_(IN) * 4095) / V_(REF)\$

where:

  • VREAD is the digital value read

  • VIN is the analog input voltage

  • VREF is the ADC voltage reference

Voltage reference

  • For the MCA ADCs the reference voltage is configurable through one of the following device tree properties:

    • digi,adc-vref = <value_in_mV>: This device tree entry makes MCA ADCs use MCA_VCC as reference voltage. This is an input voltage for the ConnectCore 8M Mini so you must configure it to the voltage value for your board.

    • digi,internal-vref: This boolean device tree entry makes MCA ADCs use a steady temperature-compensated 1.2 V as reference voltage.

      • Pad MCA_VREF_OUT will output the 1.2 V to be used as a voltage reference for external peripherals.

      • The value in digi,adc-vref property will be ignored.

ADC channel mapping

  • The indexes of MCA ADC channels correspond to their MCA IO number: MCA_IO1 is channel 1, MCA_IO2 is channel 2, and so on.

    Not all MCA IO pins are ADC-capable. See MCA I/O pads for a list of all available MCA IOs and their capabilities.

Kernel configuration

You can manage the ADC drivers through the following kernel configuration options:

  • Digi ConnectCore SOMs Micro Controller Assist ADC (CONFIG_MCA_ADC)

These options are enabled as built-in on the default ConnectCore 8M Mini kernel configuration file.

Kernel drivers

Device tree bindings and customization

The MCA ADC device tree binding is documented at Documentation/devicetree/bindings/iio/adc/digi,mca-adc.txt.

The device tree must contain entries for:

  • The ADC interface

  • The enabled channels

ConnectCore 8M Mini MCA ADC interface

ConnectCore 8M Mini device tree
	mca_cc8m: mca@63 {
		mca_adc: adc {
			compatible = "digi,mca-cc8m-adc";
		};
	};

Example: enable MCA ADC channels 1, 2, 3 and 4 on ConnectCore 8M Mini Development Kit

For example, MCA ADC channels 1, 2, 3 and 4 are available on the ConnectCore 8M Mini Development Kit XBee Cellular socket. To enable them, you must:

  • Disable the mca_uart2 node on the device tree.

  • Add channels 1, 2, 3 and 4 to digi,adc-ch-list property on the ADC node.

  • Enable the mca_adc node.

For accurate measurement conversion, you must measure the input voltage MCA_VCC and pass it to the kernel via property digi,adc-vref.

ConnectCore 8M Mini Development Kit device tree
//&mca_uart {
//	status = "okay";

	/* UART connected to XBee cellular socket */
//	mca_uart2: serial@0x940 {
//		iopins-names = "rx", "tx", "cts", "rts";
//		iopins = <2 1 3 4>;
//	};
//};

&mca_adc {
	digi,adc-ch-list = <1 2 3 4>;
	digi,adc-vref = <3000000>;
};

Customize the ADCs for your platform

Follow these steps to configure ADC channels on your custom design:

  • Identify the pins you want configured as ADC and verify that they are ADC-capable.

  • In the device tree of your platform, create or uncomment the nodes for the ADC interfaces you plan to use (mca_adc for MCA).

  • Enable the channel indexes you want to enable by using digi,adc-ch-list.

  • Compile the device tree and install it in your platform.

Using the ADCs

You can access the ADC channels from your Android application. See ADC API for more information about the ADC APIx.

Sample application

The ADC Sample Application demonstrates the usage of the ADC API. In this example, you can select one of the ADC channels available in your ConnectCore 8M Mini and configure the sample rate of that interface.

Go to GitHub to see the application instructions and source code.