You are on page 1of 3

LAB 9 EVENT COUNTER PROGRAMMING

OBJECTIVES: To program the 8051 timer/counter as an event counter. To progr a m the 8051 timer/co u n t e r as a clock to keep time. . REFERENCE: Mazidi and McKinlay, The 8051 Microcontroller and !m"edded #ystems,$ %hapter &. MATERIALS: 8051 train er 8051 ass e m "l e r #'uar e (ave gen e r a t o r )or this la" you nee d an e*t er n al sourc e o+ the s'u ar e (ave. This can "e +rom a signal gen e r a t o r ,or som e call it a +unction gen e r a t o r - or s'u ar e (ave +rom TT. oscilators +ound in the /amec o catalo g. ACTIVITY 1 %onn ec t the s'u a r e (ave to pin 01.2 +or timer 0 and set the +re'u e n c y to 1 3z. 4rite and run a progr a m +or count e r/ ti m e r 0 to count up +rom 00 to a ma*i m u m o+ 555 ,))3- as eac h puls e is +ed into the 8051. The count is displaye d on the .%6 ,or sent to a 0% monitor via the serial port-. 7otice that the num " e r s displaye d +or the count mus t "e in decim al ,00 8555-. That me a n s that the count e r value mus t "e conver t e d +rom he* to decim al and the n ma d e into 9#%:: to "e displaye d on the .%6 ,or 0% monitor-. :+ you do not hav e acce s s to a s'u ar e (ave gen e r a t o r you can us e a de"o u n c e s(itch to gen e r a t e each puls e "y pres sin g the pus h8 "utto n s(itch. ACTIVITY 2 Modi+y and run the progr a m +rom 9ctivity 1 to count +rom 100 to 555 inste a d o+ 00 to 555. #ince upon res e t T.1; 0, you mus t set T.1; 8100 in addition to T31; 8100. ACTIVITY 3 %onn ec t a <03 s'u ar e (ave to timer/co u n t e r 1 ,pin 01.5- and (rite and run a progr a m to gen e r a t e a clock to keep time. The time is in the +orm hr=min=s e c. The time displaye d on the .%6 ,or 0% scre e n - al(ays start s +rom a +i*ed time, e.g., 01=00= 0 0. Lab Manual for The 8051 Microcontroller and Embedded Systems LAB

LAB 9 WORKSHEET

LAB Systems

Lab Manual for The 8051 Microcontroller and Embedded

LAB 9 EVENT COUNTER PROGRAMMING


7ame= 6ate= %lass=

1. !*plain the role o+ the %/T "it in the TM>6 regist e r.

5. 3o( is the 8051 used as an eve n t count e r to count an e*t er n al eve n t ?

1. :+ timer/co u n t e r 0 is used as an eve n t count e r, (hat is the ma*i m u m count +or the +ollo(ing mod e s ? Mode 1 Mode 5 2. :ndicat e (hich pin is used +or the +ollo(ing. ,a- timer/co u n t e r 0 ,"- timer/co u n t e r 1 5. :+ timer/co u n t e r 0 is used in mod e 1 to count an e*t er n al eve n t, e*plain (hen T)0 is set to high. <. :+ timer/co u n t e r 1 is used in mod e 5 to count an e*t er n al eve n t, e*plain (hen T)0 is set to high.

Lab Manual for The 8051 Microcontroller and Embedded Systems

LAB

You might also like