lect11_notes

lect11_notes - Foundations of Embedded Systems A Term --...

Info iconThis preview shows pages 1–7. 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 DocumentRight 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 DocumentRight 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 DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Foundations of Embedded Systems A Term -- Fall 2008 Lecture #11: Real World Timers and Intro to ADC Reading for Today: User's Guide Ch 13 & 20 Reading for Next Class: User's Guide 20 HW #3 (on web): Due Tomorrow 9/19/2008 Lab #2 (on web): Early Sign—off 9/26/08, Report due 9/30/08 Last Class: Introduction to the MSP43OF449‘S timers. >> Setting the control registers for Timer B >> Example application of a Stop Watch. Stop Watch example continued... >> Want to implement Stop Watch with accuracy of 0.01 seconds. Selected ACLK = 32768 Hz as Timer B source clock and Up count mode --> want timer to generate Interrupt when MAX COUNT reached /*** This function configures and starts Timer B to count 0.01 second intervals ***/ void runtimerb(void) { // Use ACLK (TBSSEL_1), 16 Bit (CNTL_0),clock divider of 1 //( ID__0), and start timer counting in Up mode (MC_1) TBC'I‘L = TBSSEL_1 + CNTL_0 + MC_1 + ID_O; TBCCRO = 0x0147; // 327 ACLK tics = ~1/100 seconds TBCCTLO = CCIE; // TBCCRO interrupt enabled What will it mean when the CPU gets an interrupt from TimerBO? What should the ISR do? :> -T-lWlerB ISR Shoo coun‘l' how mama imLeer‘l‘S have occurred! (Mo‘t’kivlf) Ebsel> _ék’ :> Moan Appllcqjl'ton boll] “63c! +0 Conver+ é‘xme +0 m'.nu+es +Secawds #pragma vector=TIMERBO_VECTOR __interrupt void Timer_B0(void) { fi'uvser ++J' ASSUM‘Q timer .ISQIOIOQ, I} Uns‘tcomeé c‘n-ieajer What does the CPU do when it receives the interrupt (assuming interrupts are enabled) andbetweenyl‘r‘ltce'r‘rugtspro‘oram => Nevaw know exac‘H‘j A whet/x LMeer+ Isa x512 unsigned int timer; // global timer count variable while(1) // Forever loop of the stop watch { cthtns(); ’ s clearLCD(); V/iuTCRzuPT pecan disptime(); if(BTNl) { stoptimerb(1); } 5+3” ano+her IMT if(BTN2)L/\/ { tdir=l; runtimerb(); } if BTN3 {( ) Rno‘ther IUT tdir=0; c/“// runtimerb(); } $6 C'PU meskes We if(BTN4) 4 { ' ruc/ 10A stoptimerb(O); 0L$$€Mlbllj \fid” } } H—‘xs executan Wen } 3065 +0 152 like H—waes a fiwxd‘ton 6th mod “‘9” resemes where H; \ePr ODD How accurate will our stop watch be? Is that accuracy 0k? >> Duration of l clock tic = 1/32768 Hz = 3.053E—5 sec (327 3(3.0§3E‘§§ ; aooctq‘l‘lz seg pseé we” :2) we'll SQL3 0.0l SECOAc‘ has 6‘4 ov‘p‘j 0.00447filsec have fiont b3 3) Ronni n3 keg ‘i- :7 ‘1"- wcor \qlo bo+ no+ O.l<. PM +‘imzn43 “We >> Our stop watch will actuall run a bit fast. How lon until it is off by .01 sec 0 ha m Pic 5 y g a 0‘ 56C. Z Co+€rrup+§)(0.0|5 " AL (0.06447Cl286c) )X : L—l <30. 3 érrterrup‘l-s fi 3 inierruptéa-O' H,%\ saconls fix; Q‘Fifr seconcl our A‘hgplayeé fin/pg w‘ll) be 0.0l secomgs flags—(— >> Not unusual for clock crystals to run at odd—ball frequencies (32768 Hz is actually reasonably nice!) >> We can compensate in software — using leap counts! 0| 9 our global) Loom7L 15 (945+ 5‘31 “lewd evew3 qu Ln‘lervcpis =-_> 50 skip macaw}! e S a 55 Um c n+ #pragma vector=TIMERBO_VECTOR A, V;va '” \0 OJ S interrupt void TimerBO ISR(Void) 61"“ e 0 {— ‘ M // timer and leap_cnt are Global unsigned integers L4? (gem-Mme < mm 3 E‘Mer-H'J‘ fleCLP- Cnt +13 1 else i ‘ e( COUVF‘ RQQP-Lount-=O_'J S’hLP 6‘ {Hm I H evewfi 43‘ CWWWUP‘L‘ >> Is this perfect? Now how long is will the stop watch be accurate to 0.01 sec? N o ’P F Lest 7&Xmer .: “'14 Lake“ I'm-ERRU?T occm e‘xmer +*’:> H80 D‘SP\&LL5 4%va = 4,80 52.; 300+ eukpsei 4Zme Ls redle “Jug Ll%0xc CLOCQQ‘ICLZS: 4.7900145“ pr'LL next Cnierrup‘t é‘cmer (Si-«vs a,“ 430 D‘\$?\6L~3 ":KA/y; LL80 53C RC‘V‘ t\me =H8\ w aeoc‘onfiz _—_ H.7444952sec =>S~tiH £a3+ ba+ 0W3 553 (WAS O'Olgi 1 goggjyg (Livia/vac,“ => (303333043521) 51.34MS :: 10000 56C. 12% Libqu 4105e¢ 5>S+opuocddd omits [Ow/WLS *0 ‘0 MM! Analog-to-Digital Converter (ADC12) >> A/D converters have become ubiquitous! ——> YOU will very like need to use them to complete your ECE2799 project and you MQP! ——> But, how do they work and how do you use them properly? % B‘wxaxnfi Coées Ckfe 6L$$Lo$neé 4o Cixeé V re“ V0\*'C&C$€$ énnmlos voH’age is SQMpIeA at {Mme CA‘}€r'vq\$ => 00490“: code 04: Wedves+ Volixcae \eve\ \s quQneJ VWJLEn‘l: OH) \00, \m‘ \0\) no! COMO”) These values cam be share; in a“ arr6~fl Cm Wee/monj // p" “W \V f; U-” k Cole : 12ml >6? ~ 1 i vet we \\\\ Md? '- £6. .. ‘\___..'. ..... \.\ "xwr\“ M~MW/ MW JR; #:JL 0;} this Lnfle ADC >> Some A/D realities... Sample and Hold A/D >> Real—world, non—ideal Circuits can lead to non-linearities in conversion results (see “ABC‘s of ADC's” on class links page) :> SLJI‘l'Cle ‘lrcwainA am} vol'l'a.,coc fiecawfi are real: ‘Pkese 64396045 --> Resolution is the smallest change that can be measured m Value CLSSOC‘L‘LJQA uJK‘LK l AIMS 3 (Val; " Var) A: #5 bfls Zn / #136 Q’& Example: Sigma—Delta ADC typically have better sampling characteristics than a sample and hold ADC. What is the dynamic range and resolution of the 16 bit sigma—delta ADC that is available with the MSP430x3xx family. DR “when? Q’L:Q0j0%w(ésqse7 Ho 2;) deal?— fim 57Lewgo Swab $«Pecs 4,? gyms 44415 number ...
View Full Document

Page1 / 7

lect11_notes - Foundations of Embedded Systems A Term --...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online