Understanding the Tiva ADC

In this let's see the ADC that comes in a TM4C123GH6PM MCU. Some figures and all tables are taken from the datasheet of the MCU. Specific information about the Tiva ADC is taken from the datasheet. This will only give a introduction to the ADC, for much more in depth information about the ADC please check the datasheet.

First, what is a ADC

ADC stands for Analog to Digital Converter, it allows a MCU, which works with digital signals, and any other digital circuit to read analog signals. There are various types of ADCs, with different methods to transform a analog signal to a digital one, and with different interfaces, from parallel binary output to i2c.

A MCU being of the digital world works just with 1's and 0's. A analog signal varies in voltage with multiple values, hence the need for a ADC.

The type of ADC in the Tiva has a internal reference of 3V and that is the maximum voltage it can measure, the minimum

will be equal to GND.

The ADCs also have a maximum resolution, something like a 12bits ADC, like the one in the Tiva, will have the ability of distinguish 4096 different values betwen GND and the reference, with a 3V reference that means each value is about 0,73mV

The bigger the resolution of the ADC, the better a analog signal is read and stored. If you need to later reproduce that same analog signal you need it to be recorded as close to the original as possible. You can see on the image on the right how a converted analog signal can lose allot of values with a low resolution ADC, there are some values that are lost between readings.

I hope this as enlightened you about ADCs in general. For more info heck the web for more information about ADCs. Also check DACs, Digital to Analog converters which do the opposite of a ADC. For reference, the Tiva ADC module uses a Successive Approximation Register (SAR) architecture.

Now let's see the features on the ADC modules that comes with the Tiva

The TM4C123GH6PM microcontroller provides two ADC modules with each having the following features:

  • 12 shared analog input channels

  • 12-bit precision ADC

  • Single-ended and differential-input configurations

  • On-chip internal temperature sensor

  • Maximum sample rate of one million samples/second

  • Optional phase shift in sample time programmable from 22.5º to 337.5º

  • Four programmable sample conversion sequencers from one to eight entries long, with corresponding conversion result FIFOs

  • Flexible trigger control

    • Controller (software)

    • Timers

    • Analog Comparators

    • PWM

    • GPIO

  • Hardware averaging of up to 64 samples

  • Eight digital comparators

  • Power and ground for the analog circuitry is separate from the digital power and ground

  • Efficient transfers using Micro Direct Memory Access Controller (μDMA)

    • Dedicated channel for each sample sequencer

    • ADC module uses burst requests for DMA

So those are the features. Some are more complex to use.

There are 2 ADCs modules as referred and each 4 sample sequencers which allow sampling of multiple sources without processor intervention.

There is something that can be a bit confusing. Most peripherals have specific pins for each input/output. The ADC do have specific pins connected to it like you can see in table 13-1, but you can use any of them for any sequencer or ADC module, for example, you can use AIN9 for either ADC0 or ADC1 and any of the 4 sequencers.

The ADC sampling can be triggered by various sources, simply by software or any of the following peripherals: timer, PWM module, GPIO or Analog Comparators. The trigger starts a pre-configured reading to start.

You can see clearly in this image that all ADC input channels are all connected to both ADC modules and that also the the triggers can be used to either ADC modules. Also it's visible that the interrupts from each ADC are distinguishable, they also have triggers because they can trigger other peripherals like the DMA.

You can fire the different modules at the same time but not different sample sequencers from the same module. That is because each module only has 1 converter as you can see in the following image. The different sequencers are useful to have different configurations setup and then fire them as needed, without having to reconfigure everything each time.

Sample sequencers

The sampling control and data capture is handled by the sample sequencers. All of the sequencers are identical in implementation except for the number of samples that can be captured and the depth of the FIFO. Each sample that is captured is stored in the FIFO. In this implementation, each FIFO entry is a 32-bit word, with the lower 12 bits containing the conversion result. Table 13-2 shows the number of samples that can be store in each sequencer, the FIFOs are more useful with the implementation of the DMA.

Sample average circuit

The ADC modules come with a basic average circuit. It allows higher precision readings with the trade-off of slower sample/rate. It can average up to 64 in powers of 2 so it's 2, 4 8 16 32 64 averages. If you use for example a average of 4 then the read speed is 4 times slower.

This is a example of a average of 4 values taken from the datasheet. Figure 13-6 shows an example in which the ADCSAC register is set to 0x2 for 4x hardware oversampling and the IE1 bit is set for the sample sequence, resulting in an interrupt after the second averaged value is stored in the FIFO.

Voltage Reference

As referred before the ADC has a internal reference of 3V. Other Tiva parts can have a external reference but the tm4c123gh6pm only can use internal reference.

Interrupts

The ADC can generate any of the folowing interrupts:

  • ADC_INT_SS0 - interrupt due to ADC sample sequence 0.

  • ADC_INT_SS1 - interrupt due to ADC sample sequence 1.

  • ADC_INT_SS2 - interrupt due to ADC sample sequence 2.

  • ADC_INT_SS3 - interrupt due to ADC sample sequence 3.

  • ADC_INT_DMA_SS0 - interrupt due to DMA on ADC sample sequence 0.

  • ADC_INT_DMA_SS1 - interrupt due to DMA on ADC sample sequence 1.

  • ADC_INT_DMA_SS2 - interrupt due to DMA on ADC sample sequence 2.

  • ADC_INT_DMA_SS3 - interrupt due to DMA on ADC sample sequence 3.

  • ADC_INT_DCON_SS0 - interrupt due to digital comparator on ADC sample sequence 0.

  • ADC_INT_DCON_SS1 - interrupt due to digital comparator on ADC sample sequence 1.

  • ADC_INT_DCON_SS2 - interrupt due to digital comparator on ADC sample sequence 2.

  • ADC_INT_DCON_SS3 - interrupt due to digital comparator on ADC sample sequence 3.

Well that's pretty much it for this tutorial. For more information please check the datasheet. There are features like the sample phase control and differential sampling. Also check out how to initialize the registers for the different features.

I hope you liked reading and goodbye.