0% found this document useful (0 votes)
173 views33 pages

Getting Precise With MSP430 Sigma-Delta ADC Peripherals: Vincent Chan MSP430 Business Development Manager TI Asia

Uploaded by

StefanGL
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
173 views33 pages

Getting Precise With MSP430 Sigma-Delta ADC Peripherals: Vincent Chan MSP430 Business Development Manager TI Asia

Uploaded by

StefanGL
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 33

Getting Precise with MSP430 Sigma-Delta ADC Peripherals

Vincent Chan MSP430 Business Development Manager TI Asia vince-chan@ti.com


2005 Texas Instruments Inc, Slide 1

Agenda
Sigma-Delta basics & benefits Understanding the SD16_A Choosing an MSP430 integrated ADC Lab exercise: Hands-on with the SD16_A

2005 Texas Instruments Inc, Slide 2

Sigma-Delta Basics
AMPLITUDE

+
TIME

1 0

1-bit DAC

Simple analog: 1-bit ADC Integration () & difference () stages Complex digital: filter stage Over sampled input Decimation filtered output
2005 Texas Instruments Inc, Slide 3

- vs. Successive Approximation


Sigma-Delta typically higher resolution 1s ksps - vs. 100s ksps SAR Tolerance of analog step changes sample-to-sample
Inherent for SAR Step changes at the input must cycle through the - filter stage

- architecture ~90% digital: easier to integrate

2005 Texas Instruments Inc, Slide 4

SD16 Overview
F42x & FE42x Multiple channels Single external input per channel Up to 256 OSR 1MHz fM
Ax.0 Ax.1 Ax.2 Ax.3 Ax.4 Ax.5 Ax.6 Ax.7 + + + + + + + + Temperature sensor
Reference
fM

SD16 Control Block

VREF

1.2V
0 1 1 0 1

Divider

MCLK SMCLK ACLK TACLK

Group/Start Conversion Logic

Channel x

PGA

2nd Order Mod

SD16MEMx

SD16PREx

2005 Texas Instruments Inc, Slide 5

SD16_A Overview
F42x0 & F20x3 Single channel Multiple input pairs Input buffer AVCC measure 30kHz to 1.1MHz fM divider Up to 1024 OSR
A0 A1 A2 A3 A4 A5 A6 A7 + + + + + + + + Start Conversion Logic VREF 1.2V Reference fM Divider Divider 0 1 1 0 1

MCLK SMCLK ACLK TACLK

BUF

PGA

2nd Order Mod

SD16MEM0

Temp. sensor

A5

2005 Texas Instruments Inc, Slide 6

Conversion Modes
Single conversion
Conversion SD16SC Set in SW Auto-clear

= Result written to SD16MEMx

Continuous conversion
Conversion SD16SC Set in SW Conversion Conversion Conv

Cleared in SW

Clearing SD16SC immediately stops conversion: The value in SD16MEMx can change and should be read prior to halting conversion
2005 Texas Instruments Inc, Slide 7

SD16_A Input Design


Input Channels

Four external input pairs Fully differential Internal channels:


Temperature AVCC / 11 Offset shunt

A0 A1 A2 A3 A4 A5 A6 A7

+ + + + + + + + -

BUF

PGA

2nd Order Mod

Selectable current vs. speed input buffer PGA: 1, 2, 4, 8, 16 & 32x SD16AEx bits for internal AIN- connection to AVSS
* Buffer not in F20x3 devices

Temp. sensor

A5

Port Pin Control


to SD16 AxSD16AEx 0 1 AVSS from Ax- pin to GPIO disable
2005 Texas Instruments Inc, Slide 8

Analog Input Range


What is VREF? What is the PGA setting? Applies to all inputs & modes
V
FSR

GAIN 1
+0.6V +0.5V

32

V ref GAIN

/ 2
PGA

0V

+0.015V -0.015V

-0.5V -0.6V
2005 Texas Instruments Inc, Slide 9

Input Select vs. Channel Select


SD16_A: 1 channel, 4 external inputs per channel
MSP430F42x0 & MSP430F20x3

SD16: 3 channels, 1 external input per channel


MSP430FE42x & MSP430F42x

Channels are independent & can operate in parallel Inputs are multiplexed into each channel & must be selected/sampled sequentially

2005 Texas Instruments Inc, Slide 10

Using Preload: Multi-Channel Only


Offsets decimation filter for # of fM clocks Staggers conversion results channel-to-channel Used to introduce phase delay in the conversion flow for signal compensation Example: electricity meter I & V phase compensation
SD16OSRx = 32 fM cycles: SD16PRE0 = 8 40 Delayed Conversion 32 Conversion 32 Conversion

32 SD16PRE1 = 0 Conversion

1st Sample Ch0 (erroneous) 32 Conversion

1st Sample Ch0 32 Conversion Conversion Time

Start of Conversion

1 Sample Ch1

st

2005 Texas Instruments Inc, Slide 11

Input Step Response


Key for mux switching Decimation filter must cycle out the delta SD16INTDLYx sets automatic settling time to 1st conversion interrupt fM = 1.048MHz; OSR = 256
fSAMPLE = 4096 ksps -> tSETTLE(MAX) ~ 732usec
0.4
1
3.

Asynchronous Step
4.

0.8

0.6
2.

0.2
1.

Conversion
2005 Texas Instruments Inc, Slide 12

Internal Reference
SD16REFON VREF 0 1 Internal External SD16VMIDON Reference 1.2V AVSS AVCC VREF 0 1 Internal Only SD16VMIDON Reference SD16REFON 1.2V AVSS AVCC

Internal 1.2V reference 20ppm temperature coefficient VREF Options:


External ref: SD16REFON = 0, SD16VMIDON = 0 Internal ref: SD16REFON = 1, SD16VMIDON = 0 Internal ref w/ buffered output: SD16REFON = 1, SD16VMIDON = 1
2005 Texas Instruments Inc, Slide 13

For temperature (A6): use internal reference

Internal Reference Settling Time

SD16VMIDON = 0

SD16VMIDON = 1

CVREF = 470nF Ref buffer = +100x faster reference settling Disable once settled
2005 Texas Instruments Inc, Slide 14

Modulator Clock Selection


fM comparison using D4270:
(continuous conversion mode, reference buffer enabled)

ACLK = 32.768kHz, 256 OSR, SD16INTDLY_0 ~7.8ms/conversion ~950uA: CPU in LPM3 (~1009uA: CPU in LPM0) SMCLK = 1.048MHz, 256 OSR, SD16INTDLY_0 ~244us/conversion ~1095uA: CPU in LPM0 ~32x Faster Conversion @ ~15% Greater Current
2005 Texas Instruments Inc, Slide 15

Interrupt Vector Generator


15 0

Source SD16IV Contents No interrupt pending 0 SD16MEMx overflow 02h SD16CCTL0 IFG 04h Reserved 06h Reserved 08h Reserved 0Ah Reserved 0Ch Reserved 0Eh Reserved 10h

One shared interrupt vector: SD16_A IFG & overflow Fast decoding reduces code size/CPU load
2005 Texas Instruments Inc, Slide 16

SD16IV Handling With Assembler


SD16_ISR SD16_ISR add add reti reti jmp jmp &SD16IV,PC &SD16IV,PC Over_ISR Over_ISR ; Offset to Jump table ; Offset to Jump table ; SD16IV = 0, no int. ; SD16IV = 0, no int. ; Overflow handler ; Overflow handler

CH1_ISR CH1_ISR Over_ISR Over_ISR

; Handle channel 1 interrupt ; Handle channel 1 interrupt ; Handle overflow interrupt ; Handle overflow interrupt

2005 Texas Instruments Inc, Slide 17

SD16IV Handling With C


// SD16_ISR // SD16_ISR #pragma vector=SD16_VECTOR #pragma vector=SD16_VECTOR __interrupt void SD16_ISR(void) __interrupt void SD16_ISR(void) { { switch (__even_in_range(SD16IV, 16)) switch (__even_in_range(SD16IV, 16)) { { case 2: Handle overflow; case 2: Handle overflow; break; break; case 4: Channel 1 IFG; case 4: Channel 1 IFG; break; break; } } } }

2005 Texas Instruments Inc, Slide 18

Using __even_in_range()

versus

2005 Texas Instruments Inc, Slide 19

Selecting an MSP430 ADC


channels 8 12 3 ind 4 mux'd f SAM PLE (ksps) min 34 34 ~4 ~0.03 ~5 max 200+ 200+ res 10 12 16 16 SINAD (typ) 57 68 85 85 A IN Vss to Vref Vss to Vref +/-600mV +/-600mV reference Ref IN Ref OUT Ref I_OUT 1.4-3.6 1.5/2.5V 1.4-3.6 1.5/2.5V 1.0-1.5 1.2V 1.0-1.5 1.2V +/-1mA +/-1mA +/-1mA +/-1mA triggering gain features DTC Conv Mem Preload Buffered input SW/Timer/Cont N/A SW/Timer/Cont N/A SW/Cont to 32x SW/Cont to 32x

ADC10 ADC12 SD16 SD16_A

Voltage range to be measured? Max frequency for AIN? How much resolution? Differential inputs? Reference range? Multiple channels?

Bits 24 20 16 SAR 12 8 10 100 1k 10k 100k 1M Samples per Second


2005 Texas Instruments Inc, Slide 20

Sigma-Delta

Slope

Lab Exercise 1: Measuring Voltage


Configure SD16_A Measure variable voltage Convert to mVs Update LCD with result each second

2005 Texas Instruments Inc, Slide 21

Lab 1 Software Flow


SD16_A Configuration: 1x Gain Slow input buffer Channel A1+/ Internal VREF fM = ACLK, 256 OSR Single conversion 2s complement
Init Configure Peripherals Measure Offset Single sample A7+/Reconfigure for A1+/Main Enable Ref, Start Conv Enter LPM3 Calculate Voltage Update Display SD16 ISR Handle converison result/offset Disable Ref
2005 Texas Instruments Inc, Slide 22

WDT ISR (1sec) Exit LPM3 on wake

Lab 1 SD16_A Setup


// Add SD16_A Configuration Here // Add SD16_A Configuration Here SD16CTL = _____________________________; SD16CTL = _____________________________; SD16CCTL0 |= ____________________________; SD16CCTL0 |= ____________________________; // Get internal offset // Get internal offset SD16INCTL0 = __________________________; SD16INCTL0 = __________________________; SD16CCTL0 |= __________________________; SD16CCTL0 |= __________________________; while(!(SD16CCTL0 & ______)); while(!(SD16CCTL0 & ______)); offset = SD16MEM0; offset = SD16MEM0; // Configure for external potentiometer // Configure for external potentiometer SD16INCTL0 = __________________________; SD16INCTL0 = __________________________; SD16CCTL0 = __________________________; SD16CCTL0 = __________________________;

Add appropriate SD16_A configuration code Configure for single conversion from A7 Start conversion & poll IFG Reconfigure for single conversions from A1
2005 Texas Instruments Inc, Slide 23

Lab 1 SD16_A Main


// Main // Main while (1) while (1) { { SD16CTL |= _______________________; SD16CTL |= _______________________; SD16CCTL0 |= _______; SD16CCTL0 |= _______; _BIS_SR(LPM3_bits + GIE); _BIS_SR(LPM3_bits + GIE); } } Disp_Value(2, (float)result * MV_PER_LSB); Disp_Value(2, (float)result * MV_PER_LSB);

Enable internal reference Start a conversion

2005 Texas Instruments Inc, Slide 24

Lab 1 SD16_A ISR


// Add SD16_A ISR Here // Add SD16_A ISR Here #pragma vector=SD16_VECTOR #pragma vector=SD16_VECTOR __interrupt void SD16_isr(void) __interrupt void SD16_isr(void) { { switch (__even_in_range(SD16IV, 4)) switch (__even_in_range(SD16IV, 4)) { { case 2: case 2: break; break; case 4: case 4: result = _________________; result = _________________; SD16CTL &= ~(____________________); SD16CTL &= ~(____________________); break; break; } } } }

Get conversion and subtract measured offset Turn off internal reference
2005 Texas Instruments Inc, Slide 25

Lab Exercise 2: Measuring Pressure


Configure SD16_A Measure pressure sensor Convert to mbar Update LCD with result each second

ai r

pr

es su

re

2005 Texas Instruments Inc, Slide 26

Lab 2 Software Flow


SD16_A Configuration: 32x Gain Medium input buffer Channel A0+/ External VREF fM = MCLK, 1024 OSR Continuous conversion 2s complement
WDT ISR (1sec) Exit LPM0 on wake SD16 ISR Handle converison result/offset
2005 Texas Instruments Inc, Slide 27

Init Configure Peripherals Measure Offset Single sample A7+/Reconfigure for A0+/(continuous) Main Enter LPM0 Calculate Pressure Update Display

Lab 2 SD16_A Setup


// Add SD16_A Configuration Here // Add SD16_A Configuration Here SD16CTL = _____________________________; SD16CTL = _____________________________; SD16CCTL0 |= ____________________________; SD16CCTL0 |= ____________________________; // Get internal offset // Get internal offset SD16INCTL0 = __________________________; SD16INCTL0 = __________________________; SD16CCTL0 |= __________________________; SD16CCTL0 |= __________________________; while(!(SD16CCTL0 & ______)); while(!(SD16CCTL0 & ______)); offset = SD16MEM0; offset = SD16MEM0; // Configure for external potentiometer // Configure for external potentiometer SD16INCTL0 = __________________________; SD16INCTL0 = __________________________; SD16CCTL0 = __________________________; SD16CCTL0 = __________________________;

Add appropriate SD16_A configuration code Configure for single conversion from A7 Start conversion & poll IFG Reconfigure for continuous conversions from A0
2005 Texas Instruments Inc, Slide 28

SD16_A: 1000 And 1 Uses


16-bits with flexible input architecture Take into account reference settling SD16INTDLYx: Is it long enough? Match buffer settings for optimum power/performance Understand fM, OSR & sampling rate relationship Match the ADC with the application requirements Not just a matter of resolution!

2005 Texas Instruments Inc, Slide 29

Lab 1 SD16_A Setup Solution


// Add SD16_A Configuration Here // Add SD16_A Configuration Here SD16CTL = SD16VMIDON+SD16REFON+SD16SSEL1; SD16CTL = SD16VMIDON+SD16REFON+SD16SSEL1; SD16CCTL0 |= SD16BUF_1+SD16DF+SD16SNGL; SD16CCTL0 |= SD16BUF_1+SD16DF+SD16SNGL; // Get internal offset // Get internal offset SD16INCTL0 = SD16INCH_7; SD16INCTL0 = SD16INCH_7; SD16CCTL0 |= SD16SC; SD16CCTL0 |= SD16SC; while(!(SD16CCTL0 & SD16IFG)); while(!(SD16CCTL0 & SD16IFG)); offset = SD16MEM0; offset = SD16MEM0; // Configure for external potentiometer // Configure for external potentiometer SD16INCTL0 = SD16INCH_1; SD16INCTL0 = SD16INCH_1; SD16CCTL0 = SD16BUF_1+SD16DF+SD16SNGL+SD16IE; SD16CCTL0 = SD16BUF_1+SD16DF+SD16SNGL+SD16IE;

2005 Texas Instruments Inc, Slide 30

Lab 1 SD16_A Main Solution


// Main // Main while (1) while (1) { { SD16CTL |= SD16VMIDON+SD16REFON; SD16CTL |= SD16VMIDON+SD16REFON; SD16CCTL0 |= SD16SC; SD16CCTL0 |= SD16SC; _BIS_SR(LPM3_bits + GIE); _BIS_SR(LPM3_bits + GIE); } } Disp_Value(2, (float)result * MV_PER_LSB); Disp_Value(2, (float)result * MV_PER_LSB);

2005 Texas Instruments Inc, Slide 31

Lab 1 SD16_A ISR Solution


// Add SD16_A ISR Here // Add SD16_A ISR Here #pragma vector=SD16_VECTOR #pragma vector=SD16_VECTOR __interrupt void SD16_isr(void) __interrupt void SD16_isr(void) { { switch (__even_in_range(SD16IV, 4)) switch (__even_in_range(SD16IV, 4)) { { case 2: case 2: break; break; case 4: case 4: result = SD16MEM0-offset; result = SD16MEM0-offset; SD16CTL &= ~(SD16VMIDON+SD16REFON); SD16CTL &= ~(SD16VMIDON+SD16REFON); break; break; } } } }

2005 Texas Instruments Inc, Slide 32

Lab 2 SD16_A Setup Solution


// Add SD16_A Configuration Here // Add SD16_A Configuration Here SD16CTL = 0; // This is the default, delete line SD16CTL = 0; // This is the default, delete line SD16CCTL0 |= SD16BUF_2+SD16OSR_1024+SD16DF+SD16SNGL; SD16CCTL0 |= SD16BUF_2+SD16OSR_1024+SD16DF+SD16SNGL; // Get internal offset // Get internal offset SD16INCTL0 = SD16GAIN_32+SD16INCH_7; SD16INCTL0 = SD16GAIN_32+SD16INCH_7; SD16CCTL0 |= SD16SC; SD16CCTL0 |= SD16SC; while(!(SD16CCTL0 & SD16IFG)); while(!(SD16CCTL0 & SD16IFG)); offset = SD16MEM0; offset = SD16MEM0; // Configure for external potentiometer // Configure for external potentiometer SD16INCTL0 = SD16GAIN_32+SD16INCH_0; SD16INCTL0 = SD16GAIN_32+SD16INCH_0; SD16CCTL0 = SD16BUF_2+SD16OSR_1024+SD16DF+SD16SC+SD16IE; SD16CCTL0 = SD16BUF_2+SD16OSR_1024+SD16DF+SD16SC+SD16IE;

Make sure external reference has settled before offset measurement is made!

2005 Texas Instruments Inc, Slide 33

You might also like