{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lect13_notes - Foundations of Embedded Systems Lecture#13...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Foundations of Embedded Systems Lecture #13: Using the ADC12 Analog-to-Digital Converter -Reading for Today: 430 User's Manual Ch 20 Reading for Next Class: ADXL330 Datasheet HW #4 (on web): Due FRIDAY 9/26/2008 Lab #2 (on web): Due Tuesday 9/ 30/ 2008 Exam #2 — Now Tuesday 9/ 30/ 2008 4pm Last Class: > > Introduction to Analog-to-Digital Conversion > > Mapping output of analog sensors to an ADC (FSR, Resolution, Dynamic Range) MSP430F449 Analog-to-Digital Converter (ADC12) -> 8 channel, 12-bit sample and hold ADC (200k samples per second max.) -> Analog inputs A0—A7 available on AEXT header -> Configure are use by setting values in various control registers ADC12 Control and Data Registers (MSP430 Users Guide Ch 20) -—> K Qe 9 (1+ I ‘ s LMQ E , ‘ > > ADC12 conversion core configured using ADC12CTLO and ADC12CTL1. ADC12CTLO controls the following options -- Sample and Hold time (SHTlx and SHTOX) A? we‘ H use aka-9‘"? k Vd’lu‘e 3' -- Multiple sample conversion method (MSC) => Lo is o i: c o A 3 ‘5” Y‘AJL ‘L 0 m5 —- Reference Voltages (REF_25 and REF_ON) :9 We (43‘. \\ n e 241. MeSe i —-ADC1.'20N bit (= iurvxs on ADC12 (073.4,. b3 JQQQJJI'\ -— Enable and start conversion (ENC and ADC1 28C) @ mesg S i-aar + Measuremq‘i‘ -- Overflow/ Conversion time interrupt enables (ADC120VIE, ADC12TVIE) ADC 12CTL1 controls the following options -- Conversion start address (CSTART ADDX) is cam/2V ‘ —- Sample and hold source select (SHSX) ‘9 SAQCLS Md Slur 5‘ a“ A002 5: b‘.* on a. timer -— Sample and Hold pulse mode selectable (SHP) -- Invert signal sample and hold (ISSH) - - 4 --ADC1.2 clock divider (ADC12DIVx) => we H J‘UP‘C‘Jl‘d 561' ° 1 -- ADC1.2 clock source select(ADCSSELx)-=> A- 002 est (5' Mi“: 3 5 ( Asia: OKV L -- Conversion mode select (CONSEQx) . ‘31 as La 0r Mu H-t pie Chan neIS, 3““ 5’9 ° ’- ¢°“\‘l’1'\U°U$ SOMPlIns -- ADC1.2 busy/conversion not complete bit (ADCIZBSY) when Abe Izlssy :. I Con version ”M C90“ ‘34:“ W ‘* > > Results from each channel are stored in the lgmeitsof once? ‘6 Conversion Memory Registers (ADC12MEMx) fig > > Each memory register has a corresponding Convergion Memory Control Register (ADCIZMCTLx) Each ADC12M¢CTLx controls the following options for its Memory Register -- End oj'Sequence (EOS) = Is this channel the end on a sequence of channels that are to be converted -- Select Reference Voltages (SREFx) = ML) l 4 I P l-e O p‘l 10 A S we ill ercw-‘r \btj os‘LAS SREY..1 (lw- #73 , «ND ' Va}, ’ —- Analog input channel selection (INCHx) = I M C— W- 0 ‘10 I MCH’F' PM 5 effernaal ‘Tkese cvanCumJog> impala, INCH--3 +0 1pcu_u W C fl‘levnac/Q Capt)" C/lNacvmeVs So what does the programmer need to do to use ADC12? 1) Select ADC Core Behavior: In ADC12CTLO and ADC12CTL1 registers -- Clock source and divider A DC \7. SS EL 101+ 5 Cl .. - ‘ — A— M ' filD 20x0- OD— APCIZOSCC 5 Hz) Diviclev bf}: 0‘ : ACLK ID : MCLK ADc}:D‘V_O:OOOD>Dl\/l&bfll ADC\205(__3 : l I :-. SMCLK l4 DC/Z DIV._7‘=’ HI :>p;V:Je b7) 8 -- Sample and hold behavior SHSK : TY“SSQV Source SQIQ (Tl 00-: Use HDCR SC b-‘+ as +r13c3€r (U58r2n‘phqjlves) 0 D .. \ \ ~ ”I JH“ 'Pe"~0é‘\c CanaverStOAS (use +smer5> -- Reference Voltages REFZ— W =\ 91 We: 3 25" lniQi/‘Mfi Qe‘f REFZvS" ‘0 fits-L VNr - \~§v Z VoH-CLcdes ”REF-OI\)-=\ +uvn 0n (”Hem/well veyceremc-e 2) Select Conversion Mode required: CONSEQX bits in ADC12CTL1 register -- Single channel or a sequence of channels -- Also single conversion or repeated conversions 3) Select input channel(s): INCHX bits in ADCMCTLX registers —/\ > > ADC12 has 8 (external) analog input signals and 4 internal analog inputs ——> ADC12's 8 Analog Inputs A0 - A7 are multiplexed with Port 6 pins! Ex: Assume input channel A6 and A7 are to be used with ADC12 Port Selection bits for those pins should be 5424 t9__1_= Function Select > > Internal input channels 8h, 9h and 11h (INCHX = 1000, 1001, 1011) connected to different ch1p reference voltages 1'0 C H 3 ’ 1'. 0c M - ‘1’ I 0614— ( l -> Could be used to do “health” monitoring > > Internal input channel 10h (INCHX = 1010) measures is connected to an internal Temperature Sensor. INCA-1-”) 4) Enable appropriate interrupt -- ADC121E register -- Do not have to use interrupts, but useful for repeated measurements —- Write ISR (Should handle all 18 possible ADC interrupts with some default behavior a switch statement) 3 e I', ~l +co'rllv\ 31069.6 conversions $6 7 L0 L0 \\ 3 OJ :7 I00 Uviefru‘o‘lS 5) Enable and Start Conversion(s) —- ADC1CTLO register :93}? not uslnb (:rvlerrup‘ls Most TDOLL WDCJZ 355‘ b‘c6?or COM?l~a‘l‘LOI/\ 0;: COAUQV‘SlOK Ex. Continuing; on with the digital current meter, assume that the gain G is set so 1A equals the full scale voltage of 2.5V. Assume that the the analog input voltage is applied to A0. How would we set the ADC12 registers? cLKJ> Aibciz osc so ADCiz. 559.: 60—- ADClzssst-o Sinai? Mea..SU\f€v\/\ey\+ 2) 5H5): :1 IQDC. I7. 3C \Di'l- Mocl~€ win-l FSQZ 2gv =>Use (Ln‘l‘efnaj Z.SV Vrefl+ 3) SIMON COnvei/sion, SZA51€ Chad/H49 { 3. re? L001 am; cousaco :00 IA " 0”“ | I // Some code to implement the current sensor example from last // class. Input voltage range 0 t02.5V corresponds to 0 to 1A. unsigned int in_va1ue, busy; // Initialize control register ADC12CTLO = 0110 0110 0111 0000 // SHTlx and SHTOX = 66h (both 128 clks), MCS = 0 = no burst mode // REF2_5V = 2 (2.5V), REFON = l = use internal reference voltage // and ADC120N = 1 = turn ADC on ADCIZCTLO = SHTO_6 + SHT1_6 + REF2_5 + REFON + ADCIZON; // Initialize control register ADC12CTL1 = 0000 0010 0000 0000 // CSTART ADDx = 0000 = start conversion with ADC12MEMO, // SHSX = 00 = use SW conversion initiation trigger, ADClZSC bits // SHP = 1 = SAMPCON signal sourced from sampling timer, // ISSH = 0 = sample input signal not inverted, // ADC12DIVX = 000: divide ADC12CLK by 1, // ADCIZSSEL=00= ADC clock ADCIZOSC (~5 MHZ), // CONSEQx = 00 single channel, single conversion, // ADC12BUSY = 0 = no ADC operation active ADC12CTL1 = SHP; // Set conversion memory control register ADC12MCTLO = 0001 0000 // EOS = 0, SREF =001 ——>Voltage refs = GND to (Vref+) // INCHX = 0000 = analog input from A0 ADC12MCTLO = SREF_1 + INCH__O; PGSEL |= BITO; // Set Port 6 Pin 0 in FUNCTION mode for ADC //Enable and start (single) conversion (not using ADC interrupts) ADC12CTLO |= ADCIZSC + ENC; busy = 1; while (busy != O) // Wait until conversion complete busy = ADC12CTL1 & ADCIZBUSY; //Check BUSY bit (polling!) in_ya1ue = ADC12MEMO & OxOFFF; // keep only low 12 bits > > How would we use the results from the ADC in our program? Cabot} does ’\_\:1+ represeV‘J'? Jib: 0.2L!” MA/b§+ 4099 " ‘ ' be Curran-F [flack 1A6 LA md‘wmpsmu m fl_per- bf+ = 0.2qq; . -b}~ W\~I\\“CLW\PS;(‘P\OCL+) (”n-VOJU'Q J Mkper t “keg-V KS: we. C/Cunmcdeé gain G E$ocla 4/de +ke weso’u4lom was \\O\‘\‘ ; O.ag Mn ”9 ”MUS m1%k+ we (,QCLA‘} +0 do 9'? EXQC" VJU‘Q #0!‘ M'tqumps pram } Sim/\(J‘Q ln+€5er oper‘CLA‘toms'H 7—”) '00 ‘P’LOQJLIA 3 ">01 ver neeéei ii? F\Oa—+1’\3f9olfl+ 7-5 “EXPEMSIUEI‘ on msfiqgo} ...
View Full Document

{[ snackBarMessage ]}