Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 306 of 9364. Peripheral Interfacing and ControlFree lesson

Single Channel Data Acquisition Techniques

Learners will program the ADC peripheral to perform a single-shot conversion on a specific pin to read a static analog sensor value.

Programming the ADC for Single-Shot Acquisition

In this lesson, you will learn how to trigger a single-shot conversion on a specific analog pin to capture a static sensor value.

While we previously explored the theory of Successive Approximation Register (SAR) converters, practical implementation requires us to command the hardware to take a "snapshot" of the voltage present on a pin. In a single-shot configuration, the ADC remains idle until software explicitly initiates a conversion. Once the process completes, the peripheral signals that the digital value is ready, and then it returns to an idle state.

Initiating the Conversion

To acquire data, you typically interact with the peripheral's control register. The process follows a standard sequence:

  1. Selection: Set the channel multiplexer to point to your desired physical pin.
  2. Trigger: Set a "start conversion" bit in the control register.
  3. Wait: Poll the status register (or wait for an interrupt) to check if the conversion is complete.
  4. Read: Retrieve the result from the data register.

Consider this simplified logic for a single-shot read:

// 1. Select the analog channel (e.g., Channel 0)
ADC_SelectChannel(0);

// 2. Trigger the single-shot conversion
ADC_StartConversion();

// 3. Wait for the hardware to finish (poll the EOC - End of Conversion bit)
while (!(ADC_StatusRegister & ADC_EOC_BIT));

// 4. Retrieve and store the static value
uint16_t sensorValue = ADC_DataRegister;

Why Use Single-Shot?

Unlike continuous sampling where the ADC runs at full speed, single-shot acquisition is ideal for sensors that change slowly or for scenarios where you need to minimize power consumption. By only activating the converter when you specifically need a reading, you avoid unnecessary power draw and bus traffic. It is the most common technique for reading static inputs, such as a potentiometer position or a battery voltage monitor, where a continuous stream of data is unnecessary and would only serve to clutter your memory buffers.

Key Takeaway: Single-shot conversion provides precise control over data acquisition by manually triggering the hardware to capture a voltage sample only when required, effectively balancing power efficiency with measurement needs.