Content area
Full Text
The ADC data sheet often shows the sequence of events required to create the "pseudocode" in a software driver and can translate directly into C.
Analog to digital converters (ADCs) provide an embedded controller's window into the analog world. A properly chosen ADC can eliminate a board's worth of op amps and adjustment potentiometers, resulting in a clean, robust design.
The design process involves making sure that the analog requirements of the circuit are met, and that the processor can do something useful with the ADC's output data; the glue between the two is the low-level driver code.
Analog to digital converters require special consideration when writing firmware, when compared with purely digital peripherals such as memory, UARTs and I/O expanders. If an ac signal is to be analyzed, the timing of the start of the conversion must be absolutely deterministic and free from software-induced jitter, placing strict requirements on how the controller initiates a conversion.
High-resolution ADCs for dc measurements may have a conversion time that is significantly longer than any other process that the controller has to perform. And lastly, the digital interface may not be a perfect match to the controller's built in peripheral controllers.
This article describes a step-by-step approach to writing a driver for a 24-bit, delta-sigma ADC with an I[2]C interface.[(1)] It illustrates many of the subtleties of driver design for a number of reasons:
- The conversion time is very long compared with most things that happen in a microcontroller.
- It uses an I[2]C interface, which is built into many controllers, but each controller has its own specific implementation.
- The I[2]C interface itself is used to indicate the status of a conversion, rather than a status bit.
- It has multiple input channels, requiring proper sequencing in firmware.
ADC details
An ADC has to do two things--take an analog measurement and send the data to a controller. These can occur simultaneously, depending on the ADC architecture. For example, the LTC2366 (a 12-bit ADC) uses the serial data clock to advance the conversion.[(2)] This makes sense for a high-speed part; the more operations you can do at the same time, the faster you can sample. But the ADC described here uses a delta-sigma architecture to achieve...