TM4C123x MCUs: Analog Peripherals
This video covers the various analog peripherals on the TM4C123x family of microcontrollers. Specifically, this video will cover the ADC and Analog Comparators.
Resources
[MUSIC PLAYING]
Hello, and welcome. My name is Ashish Ahuja. I'm an applications engineer with Texas Instruments. I'm really excited to introduce you to various analog peripherals and the state-of-art, new Tiva C series TM4C123x family of microcontrollers. We will talk about the ADC and analog comparators today.
We will begin our discussion by briefly talking about key features of the ADC module. That will lead us to a discussion on functional description of ADC that involves different modes of operation, voltage references, sample sequences, et cetera. We will have a similar discussion on analog comparator as well.
In the end, I'll also introduce the new TivaWare for C series software and how you can use it to jumpstart embedded software development with TM4C123x devices. So by the end of this presentation, you will be familiar with the key features and specifications of the new analog-to-digital converter, digital comparator, and analog comparator on TM4C123x family of microcontrollers.
An analog-to-digital converter is a peripheral that converts a continuous analog voltage to a discrete digital number. TM4C123x family of microcontrollers feature two ADC modules, ADC0 and ADC1, which share 24 analog input channels. Each ADC module has 12-bit output resolution.
Each ADC module also contains four programmable sequencers, which allow sampling of multiple analog input sources without microcontroller's intervention. Input source, triggers, and interrupt for each sample sequencer can be configured to meet the requirements of a wide number of applications. In addition to that, each ADC module has its own temperature sensor, which we will discuss in detail later.
So let's take a quick look at the key features and specifications of the ADC module. At this point in time, I will talk about the key features listed on the screen very briefly. In the later section of this training, most of these features will be discussed in detail.
In addition to 12-bit resolution, 24 shared analog channels, each ADC module supports both single-ended and differential modes of operation. Each ADC module is capable of sampling at 1 megasamples per second. To achieve higher sampling rates, two ADC modules can be configured to capture analog signals simultaneously for [? interleaved ?] operation.
This is a new grounded design that features selectable reference signals for ADC. That is, the ADC reference voltages can be provided internally from within the chip or externally from the regulated power supply. The ADC modules also have a hardware averaging circuit that can be used to average up to 64 samples for applications that involve higher accuracy.
Each ADC module can be triggered from the software or the processor or from other peripherals, like timers, comparators, PWMs, and GPIOs. There are 8 comparators per ADC module. DMA may be used to increase efficiency by allowing each sample sequencer to operate independently and transfer data without processor's intervention or reconfiguration. ADC module also features optional phase shift and sample time, and we'll really talk about this feature in more detail as we go along.
So let us take a quick look at the key specifications of ADC module in TM4C123x microcontrollers. As I've mentioned previously, the ADC in TM4C123x devices has been designed from ground up. The performance and accuracy has been greatly improved.
I won't read the table, but I would like to mention that these are preliminary numbers. While comparing these specifications against the competition, please make sure that the numbers being compared are valid for the entire temperature range-- that is, from minus 40 C to 85 C-- and are measured at comparable resolution and sample rate.
Now, let us take a moment and examine the block diagram of the ADC module. Remember, there are two such ADC modules in TM4C123x devices, and they are both identical. Each ADC module has 24 input channels that can be used to provide analog input signals to the ADC circuit. These are labeled as [? A and ?] [? X ?] on the screen.
Each ADC module consists of four programmable sample sequencers which can be configured to capture data from analog input channels in different ways. The external reference voltage to the ADC can be supplied using VREFA+ and VREFA- terminals. In addition to the digital comparators and hardware average, each ADC module also has its own interrupt control block which can generate an interrupt for each sample sequencer.
Different triggers, such as from timer, PWM, et cetera, are multiplexed together to the control status block inside the ADC module. That leads us to a discussion on the functional description of various blocks inside the ADC module. Before we talk about the other features of the ADC, we will first take a look at the ADC clocking.
The ADC module is clock-gated. That is, before the ADC module can be used, the clock to the DC module must be enabled by setting Rx bit in the run mode clock-gating register. The ADC control logic runs at 16 megahertz. The clock source can be selected by setting the clock source bit in the ADC clock source register. The clock source can be PLL or precision internal oscillator. Otherwise, the system clock must be at least 16 megahertz.
To reduce the overall current consumption, the ADC can be operated in deep sleep mode with precision internal oscillator selected as a clock source. Each ADC module has four sample sequencers which are used to collect and sample data using a programmable sequence-based approach. Each sample sequencer is a fully programmable series of consecutive, back-to-back samples that allows the ADC module to collect data from various input sources without having to be reconfigured and the CPU's intervention. All sample sequencers are identical except for the number of samples they can capture.
To configure a sample sequencer, you are required to know which import channel is connected to the signal source, whether you want to capture samples in single-ended or differential mode, whether you want to generate an interrupt on sample completion or not, an indicator for the last sample in the sequence.
The ADC uses VREFP and VREFN as the reference voltages to produce the conversion value from the selected analog input. The reference voltages can be supplied from within the chip or from an external voltage source. VREFP can be connected to either VDDA or VREFA+. And VREFN can be connected to either ground A or VREFA-.
This can be configured by setting the VREF bit in the ADC control register. In single-ended mode, the ADC resolution can be expressed as a difference of positive and negative reference voltages or maximum number of ADC steps. This is mathematically represented in form of an equation, shown on the screen.
The diagram on the left shows the conversion range of the ADC in single-ended mode. The conversion result will vary from 0 hex to FFF hex for the input voltage range, starting from the negative reference voltage of the ADC all the way to the positive [? reference ?] voltage of the ADC.
In addition to the traditional single-ended sampling mode, the ADC module also supports differential sampling of two analog input channels. To enable differential sampling, software must [? send ?] the DN bit to the ADC sample sequence control register in the step configuration [? enable. ?] When a sequence step is configured for differential sampling, the input paired to the sample must be configured in the sample sequencer multiplexer register-- differential pair 0, samples analog inputs 0 and 1, differential pair 1, samples analog inputs 2 and 2, and so on.
The diagram on the left shows the conversion range of the ADC in differential mode. The conversion results will vary from 0 hex to FFF hex for the input voltage range starting from negative difference between ADC reference voltages to the positive difference between ADC reference voltages.
The trigger source for ADC0 and ADC1 may be independent. The two ADC modules can also operate from the same trigger source and on the same or different inputs. If both ADC modules are running at the same sample rate, they may be configured to start convergence coincidentally or with one of the 15 different discrete phases relative to each other.
The sample time can be delayed from the standard sampling time in 22.5 degree increments up to 337.5 degrees. Each ADC module has a hardware sampling averaging circuit that can be used to generate high-precision results. Averaging circuit can be used to accumulate up to 64 samples and average them to form a single data entry to appear in the sequencer FIFO.
By default, hardware sample averaging circuit is off, and all the data from the converter passes through the sequencer FIFO. All channels are averaged equally, irrespective of their configuration-- single-ended or differential. It is important to understand that the throughput is decreased proportionally to the number of samples in the averaging calculation.
Each ADC module has a temperature sensor that can be used to sense that die temperature for reliable system operation. It can also be used to obtain temperature measurements in order to calibrate hibernation modules, RTC term value. The internal temperature sensor module consists of a bandgap reference circuit that provides reference voltages to various analog modules. The relation between the reference voltage and the die temperature is mathematically expressed by the first equation shown on the screen.
In most applications, internal temperature sensor can be used to provide rough estimation of the die temperature. The relation between the temperature and ADC output code can be expressed mathematically using the second equation shown on the screen. The ADC modules in TM4C123x microcontrollers also feature eight dedicated micro DMA channels for ADC sample sequencers. Micro DMA can be used to effectively transfer data from ADC sample sequences without CPU intervention or reconfiguration.
ADC module can also be used to generate interrupts when a sample sequencer completes sampling a signal, or when hardware sample averaging circuit completes sample averaging, or when particular voltage is seen on the input of the digital comparator based on the mode of operation. The register configurations of the sample sequencers and the digital comparators dictate which events generate raw interrupts but do not have a control over whether the interrupt is actually sent to the interrupt controller.
The ADC module also consists of eight digital comparators that can be used to compare the ADC module's output with the user programmable limits. Depending on the result of the comparison, a processor interrupt or a trigger to the PWM module can be generated. It can be used in applications where the sample value needs to be compared against a predefined value without requiring CPU intervention.
If the sample value meets the comparison criterion, a trigger can be asserted. This reduces CPU overhead. The digital comparators can be operated in four different modes, as listed on the screen. In Always mode, an interrupt or trigger is always asserted when comparison criterion is met.
In Once mode, an interrupt or trigger is asserted when comparison criterion is met but previous one did not. In Hysteresis mode, an interrupt or trigger is asserted by comparison criterion is met, previous comparison criterion is also met, and the hysteresis condition has not been cleared by entering the opposite region.
In Hysteresis Always mode, an interrupt or trigger is asserted only when ADC conversion value meets its comparison criterion, the hysteresis condition is clear, and the previous ADC conversion did not meet the comparison criterion. Please note that threshold COMP1 should be greater than or equal to threshold COMP2.
OK, so that was all you wanted to know about the ADC module. Let us spend a minute and talk about the TivaWare for C series. TivaWare for C series is an extensive suite of software designed to simplify and speed up embedded application development using Tiva C series microcontrollers.
TivaWare for C series include peripheral driver library, graphics library, USB library, and sensor library, which includes several APIs to configure and initialize different peripherals on the Tiva T-series microcontrollers. These libraries come with the source code which is mostly in C. They are pre-compiled for use as is and can also be adapted as desired.
TivaWare for C series also includes a bootloader, several code examples, and third party packages that allow you to focus on your application development and not so much on how to set up the microcontroller. The peripheral driver library in TivaWare for C series includes a set of function calls, commonly known as APIs, which can be used to initialize and configure the ADC module without having too much knowledge about various registers and bit configuration.
More details about the functions, including the description, prototypes, arguments, et cetera, can be found in the peripheral driver library documentation, which is available in the TivaWare for C series. I strongly encourage you to take a look at that before you start using these functions.
Now that we have equipped you with a solid understanding of the ADC, let us take a quick look at the analog comparators now. An analog comparator is a peripheral that compares two analog voltages and provide the logical output that signals the comparison result. The comparator can provide its output to the device pin, acting as a replacement for an external analog comparator.
There are three analog comparators integrated in TM4C123x devices. The analog comparator can be used to signal the application via interrupts or trigger the startup of a sample sequence in the ADC. The interrupt generation and ADC triggering logic is separate and independent. This flexibility means, for example, that an interrupt can be generated on a rising edge and the ADC can be triggered on a falling edge.
The block diagram of the analog comparator module is shown on the screen. It includes three identical analog comparators, each with its own pair of inputs, Cn+ and Cn-, and outputs Cn, and trigger signal that can be used to initiate an ADC sample sequence.
Analog comparators can be configured through two status control registers-- analog comparator control and analog comparator status registers. The internal reference is configured through one control register, analog comparator reference voltage control. Interrupt status and control are configured through three registers-- analog comparator [? math ?] interrupt status register, analog comparator raw interrupt status register, and analog comparator interrupt enable register.
Typically, the comparator's output is used internally to generate an interrupt as controlled by the [INAUDIBLE] bit in the ACC control register. The output may also be used to drive an external pin, C0, or generate an analog-to-digital converter trigger.
The peripheral driver library in TivaWare for C series also includes function calls, which we call APIs, which can be used to initialize and configure the analog comparators without having too much knowledge about various registers and bit configuration. More details about these functions, including the description, prototypes, arguments, et cetera, can be found in the driverlib documentation, which is available in the TivaWare for C series. I strongly encourage you to take a look at that before you start using these functions.
Where to go if you need more information? We have an extensive repository of excellent documentation, including device data sheets, user manuals, application notes, et cetera, that have been created to strengthen your understanding about TM4C123x devices and accelerate design and development of your project. If you have a technical question, you can contact Tiva C series experts on TI's E2E forum. Please visit ti.com/tiva-c for technical documents, ordering samples, downloading tools and software, and e2e.ti.com to obtain technical guidance.
So today, we learned about analog peripherals in the state-of-art, new Tiva C series TM4Cx family of microcontrollers. We began our discussion by briefly talking about key features of the ADC module. That led us to our discussion on function description of the ADC.
We learned about different modes of operation, voltage references, sample sequences, et cetera. We had a similar discussion on analog comparator as well. In the end, we walked through TivaWare for C series, our software that enables you to jumpstart embedded applications development with TM4C123x devices. Thanks for watching, and stay tuned for more exciting and innovative products.
[MUSIC PLAYING]