Adc Configuration Examples; C Code Example - Texas Instruments UCD3138 Technical Reference Manual

Digital power supply controller
Hide thumbs Also See for UCD3138:
Table of Contents

Advertisement

www.ti.com

8.15.1 C Code Example

The following example code demonstrates how to configure the ADC 12 for dual sample and hold
operation. In this example AD04 and AD00 are configured to measure simultaneously.
void init_ADC_polled(void)
{
AdcRegs.ADCCTRL.bit.MAX_CONV = 2;
AdcRegs.ADCCTRL.bit.SINGLE_SWEEP = 1;
AdcRegs.ADCCTRL.bit.ADC_EN = 1;
AdcRegs.ADCSEQSEL0.bit.SEQ0 = 4;
AdcRegs.ADCSEQSEL0.bit.SEQ1 = 3;
AdcRegs.ADCSEQSEL0.bit.SEQ2 = 0;
AdcRegs.ADCSEQSEL0.bit.SEQ0_SH = 1;
// Sample and Hold AD04 for simultaneous measurement with a following channel
AdcRegs.ADCCTRL.bit.BYPASS_EN = 6;
// 6 is "110 in binary", which means AD00 is the
// following/Converting channel that is measured together with AD04
}

8.16 ADC Configuration Examples

8.16.1 Software Initiated Conversions
The following example code demonstrates how to configure ADC12 to initiate a sequence of conversions
triggered by software.
Requirement: 10 conversions need to be sequenced during a single session with triggering done via
firmware. The required channels are as follows: Conversions = 09, 10, 02, 02, 02, 04, 04, 04, 12 and 14.
Here the maximum number of conversion is set to 9 and the ADC Sequence Select Register is configured
to:
SEQCHSEL0
SEQCHSEL1
SEQCHSEL2
SEQCHSEL3
A conversion session is initiated by firmware writing to the software start bit (SW_START) in the ADC
control register. When the sequence completes all the requested conversions, the sequencer sits idle
waiting for another software start bit transition from 0 to 1. The conversion results are placed in the ADC
result buffers.
SNIU028A – February 2016 – Revised April 2016
Submit Documentation Feedback
Usage of Sample and Hold Circuitry for High Impedance Measurement
// A total of 3 measurements
// First
measure AD04
// Second measure AD03
// Third
measure AD00
Bits
Field Name
4:0
SEQ00
9:5
SEQ01
14:10
SEQ02
Bits
Field Name
4:0
SEQ03
9:5
SEQ04
14:10
SEQ05
Bits
Field Name
4:0
SEQ06
9:5
SEQ07
14:10
SEQ08
Bits
Field Name
4:0
SEQ09
9:5
SEQ10
14:10
SEQ11
Copyright © 2016, Texas Instruments Incorporated
Channel Select Value
9
10
2
Channel Select Value
2
2
4
Channel Select Value
4
4
12
Channel Select Value
14
X
X
ADC12 Overview
311

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents