You are on page 1of 18
UNITI 1, List the various SFR’s in 8051 microcontroller. 2. Distinguish between Microprocessor & Microcontroller? 3. Draw and explain structure of PSW in 8051. 4, List the characteristics of Embedded Computing Applications. 5. What are the challenges in embedded systems? 6. Define Interrupts and write its applications 7. List out the purpose of embedded design process LAQ Draw and Explain in detail block diagram of 8051 microcontroller. Explain working of Port0 in 8051 using circuit diagram. Explain the structure of TCON and TMOD. Draw and Explain 8051 pin configuration, Explain various SFR’s used to handle interrupts in 8051. What are different modes of Timers in 8051? Explain. Differentiate between microprocessors and Microcontrollers, en awe ren = . Describe how serial data communication is performed in 8051? Explain the various modes of operation and SFR’s used for serial communication. LONG ANSWER QUESTIONS 1Q) Draw and Explain in detail the block diagram of 8051 microcontroller a FAGURE 2.10. B51 Beck Oden =) | |B) PS pegs Jie) [ee Uk. or rT we] [ES et) | ' Fe | T— [eer] HEE ' | Pie 1 [ees] Eat i a ! ‘Tne HOST mieroconironeractelly telnet 8 woe faily of microcontroller Ha have ‘umber ranging from 803110 8751 and ae available in N-Channel Metal Onide Silicon (NMOS) and Complementary Mes! Oxide Silicon (CMOS) consructon in a vaety of ‘The #051 microconroler actully inelaes 3 who fri of microcontrollers that hove numbers ranging from 803110 8751 and are available in N-Channel Metl Oxi Siicon (NMOS) and Complementary Metal Onde Silicon (CMOS) consirvtion in a variety of | ‘Te block diagram of the 8051 in Figure 21a shows all of he Features unique to io contol Inermal ROM and RAM, HO ports with programmable pins Timers and counters Sera dave communication ‘The gue sto shows the wsoal CPU comport: program counter, ALU, woking reise ters and cack cre" “The 8051 architecture consists of thee specific features: ightbit CPU wih epsters A (the accumulator ond B Sixteensit program counter (PC) and dat pointer (DPTR) igh program status word (PSW) Fgh bi stack painter (SP) Teterrat ROM or EPROM (8751) of 0 (8031) 1 4K (#051) Terral RAM of 128 bytes: Four register hanks each containing eight repsters ‘Sheen yes, whieh may be addressed atthe bi level ighy bytes of genera purpose data memory ‘Thiry-t%oinpvouput pins arranged 9s fou 8-bit ports: PO-P3 ‘Two t6-ictimer/counters: TO and T1 Full plex serial daa reciverfransmiter: SOUP Cont registers: TCON, TMOD, SCON, PCON, Pan 1E ‘Two extemal and thee interna inemupt sources ‘Oscillator and clock circuits Port 0 Port 0 pins may serve as inputs, outputs, or, when used together, as a bi-directional low- order address and data bus for external memory. For example, when a pin is to be used as an input, a | must be written to the corresponding port 0 latch by the program, thus turn- ing both of the output transistors off, which in turn causes the pin to “float” in a high- impedance state, and the pin is essentially connected to the input buffer. When used as an output, the pin latches that are programmed to a 0 will turn on the lower FET, grounding the pin. All latches that are programmed to a | still float; thus, external pullup resistors will be needed to supply a logic high when using port 0 as an output. ‘When port 0 is used as an address bus to external memory, internal contro! signals switch the address tines to the gates of the Ficld Effect Transistories (FETs). A logic | on an address bit will turn the upper FET on and the lower FET off to provide a logic high at the pin. When the address bit is a zero, the lower FET is on and the upper FET off to provide a logic low at the pin. After the address has been formed and latched into external circuits by the Address Latch Enable (ALE) pulse, the bus is turned around to become a data bus. Port 0 now reads data from the external memory and must be configured as an input, so a logic | is automatically written by internal contro! logic to all port 0 latches. Port 0 (Pin No 32 — Pin No 39) It has 8 pins (32 to 39). It can be used for input or output. Unlike P1, P2, and P3 ports, we normally connect PO to 10K-ohm pull-up resistors to use it as an input or output port being an open drain. It is also designated as ADO-AD7, allowing it to be used as both address and data. In case of 8031 (i.e. ROMless Chip), when we need to access the external ROM, then PO will be used for both Address and Data Bus. ALE (Pin no 31) indicates if PO has address or data. When ALE = 0, it provides data DO- D7, but when ALE = 1, it has address AO-A7. In case no external memory connection is available, PO must be connected externally to a 10K-ohm pull-up resistor. 10K 8051 P03 00d ANS) A) “THE TIMER CONTROL (TCON) SPECIAL FUNCTION REGISTER Bit Symbol Function 2) TH Terri ag. Se whe mel om oes ole when pooceee ‘eclosion sere out ated at roar ade COE 6 TR Tee rumen Sto Byprogram wenbitier to cam eed 100 by ‘yam he Dotson tome HO Tne @Qvrtoy fag,Set when ier om ars, led when eee Vecios to wea inenl sere out leat at program aces OO 4 190 YmerOruncona St 101 by prom enable eer to coum: eared 100 by Trop ta hi tne Bonet at me 36 seed Sto te sight tani rated t pase aes OO ex et me Cora 21 xematmtenat ins ye contol bt ett by programto este erate Tete rowed by ling sage sna St Oy progam enase sw et Seach otal 0 geo tne + RD ——_sealterugt edge tg Sto when abightolow ae soa atecrned ont ‘pr. GR) Cearedwnen pectin nion to marup see tune ced at ‘rogiem aden 009% hat ened 0 te pean Bit Symbol Function 20 xtemaliteupt Og! type contol it Set by program to enable etna intern! 0 Tobe tiggered by a allng ee sal. Sel to by program to nate 3 ow evel ‘gal on etal iterapt Dts goreratean inert It dtresatte 25 TCONLO 10 TCONT poe 5 4 3 2 1 one [ of [on [x0 [Tone | cm [mm | c Ter Tews 1 ‘THE NMER MODE CONTROL (THD) SPEGIAL FUNCTION REGISTER Bit Symbol Function 1A Gate OR ete enti wich conto RINISIO® oe 110. Se to 1 ogra 9 ele Tame toran ot Aer CON eet nd rl on evel erg TO pe NBN Credo Oy pour tent iner oun TRON TCON se G2 CA seta tty rogianto mate ie 10 act as csr by eouting obs om ett net pm 33 71)0°3.4(7) Clened oO by oyemtamate ime acts 9 ier ‘eciming trl ease, 5 Mme opeating mene sel i. Sele by rapt tect mode 47 MO Tiara opting made slic. Stare by prog tse mode ° CDE te atime ‘A pinout of the 8051 packaged in a 40-pin DIP is shown in Figure 2.2 with the full and abbreviated names of the signals for each pin. Programming instructions or physical pin connections determine the use of any multi-function pins. For example, port 3 bit 0 (abbreviated P3.0) may be used a 2 general-purpose VO pin, oras an input (RXD) to SBUF, ‘the serial data receiver register. The system designer decides which ofthese two functions is to\he used and designs the hardware and software affecting that pin accordingly. FIGURE 2.2 8051 DIP Pin Assignments ptt 8n9 Pon pe rat pee reat ren 1846 wrens ba) Fea ae out ot) Pon 3882 cere at 3012 titer mero renee s write Sheba) at 3947 anasto) cota nat 2 eateoat cron Po race) prac 3.20070) paar 73.786) aoure 38 uonre. 36 aonpo 35 vwonro.7 32 | pxtoen7 aerate) TEPAOU Propemnine toee pra heron Pu) Progam Se Enabie asre7 20 | rt 2007 ee 5) Cater) pt 2005 Aes es 12) et2013 Cae aes 0) Pe 2841 aves a) anore6 27 onawes 26 anes 24 auore2 23 ame 2 ‘ate: Aterate tonchont se shawn blow the port name neurites) rn Am ‘ers and pn names ue shown made the IP package ‘The pin diagram of $051 microcontroller consists of 40 pins as shown below. A total of 32 pins are set away into four Ports such as PO, PI, P2 and P3, Where, ‘Therefore, the microcontroller 8051"s pind “Pr a input or output pins ach port contains 8 pins, 1 and explanation is given below, 1 (Pint to Pin): Port includes pinL.O to pinl.7 and these pins can be configured ‘+ Pin 9 (RST): Reset pin is used to Reset 8051 Microcontroller by giving a positive pulse to this Pin © Port3 (Pin 10 to 17): The Port3 Pins are similar to port! pins and can be used as universal Input or output pins. These pins are dual function Pins and the function of each Pin is given as: * Pin 10 (RXD): RXD pin is a Serial Asynchronous Communication Input or Serial synchronous Communication Input. Pin 41 (TXD): Serial Asynchronous Communication Output or Serial Synchronous Communication clock Output. © Pin 12 (INTO): Input of Interrupt 0 © Pin 13 (INTL): Input of Interrupt 1 © Pin 14 (10): Input of Counter 0 clock © Pin 15 (TH): Input of Counter 1 clock: . Pin 16 (WR): Vriting Signal to write content on external RAM. . Pi 7 (RD): Reading Signal to read contents of external RAM. X2 and X1 pins are input output pins for the oscillator. ‘These pins are used to connect an internal oscillator to the microcontroller. © Pin 20 (GND): Pin 20 isa ground pin, © Port2 (Pin 21 to Pin28): Port2 includes pin21 to pin28 which can be configured as Input Output Pins. But, this is only possible when we don’t use any extemal memory. If' we use external memory, then these pins will work as high order address bus (A8 to AIS). is used to enable extemal program memory. If we use an ex! ROM for storing the program, then logic O appears oni, which indicates Mieto cor 7 74 4 to read data from the memory. © Pin 30 (ALE): Address Latch Enable pin is an active high-output signal. If we use multiple memory chips, then this pin is used to distinguish between them. This Pin also gives program pulse input during programming of EPROM. © Pin 31 (EA): If we have to use multiple memories then the application of logic 1 to this pin instruets the Microcontroller to read data from both memories: first internal and then external. ‘© Port 0 (Pin 32 to 39): Similar to the port 2 and 3 pins, these pins can be used as input output pins when we don’t use any external memory. When ALE or Pin 30 is at 1, then this port is used as data bus: when the ALE pin is at 0, then this port is used as a lower order address bus (AO to A7) © Pin40 (VCC): This VCC pin is used for power supply. The 8051 Oscillator and Clock The heart of the 8051 is the circuitry that generates the clock pulses by which all internal operations are synchronized. Pins XTALI and XTAL2 are provided for connecting a resonant network to form an oscillator. Typically, a quartz crystal and capacitors are employed, as 7; 8) The IE or Interrupt Enable Register is used to enable or disable individual interrupts. Ifa bit is SET, the corresponding interrupt is enabled and if the bit is cleared, the interrupt is disabled. In 8051 micro controller there are 21 Special function registers (SFR) and this. includes Register A, Register B, Processor Status Word (PSW), PCON etc. So, it required 21 unique locations for these 21 special function registers and the size of each register is of 1 byte. Some of these special function registers are bit addressable registers (which means you can access 8 individual bits inside a single byte), while some others are only byte addressable register FIGURE 2.17 IE and IP Function Registers a? 1 oe > 6 5 fe [-[e[e [eyo ee | 2° | ‘THE INTERRUPT ENABLE (IE) SPECIAL FUNCTION REGISTER Bit Symbol Function 7 & Enable interrupts bit. Cleared to 0 by program to disable all interrupts; set to to permit jindevidual interrupts to be enabled by their enable bits 6 = Not implemented 5 om Reserved for future use. a ots Enable seria port interrupt. Set 10 1 by program to enable seral port interrupt; cleared 10.0 to deable serial port interrupt 30 Enable timer 1 overflew interrupt. Set to 1 by program to enable timer 1 avertlow interrupt; cleared to 0 to disable timer 1 overflow interrupt. 2 x Enable exterralinterupt 1. Set to by program to enable THVT interupt: cleared to 0 to sable INT intertupt 1&0 Enable timer 0 overflow interrupt, Set to 1 by program to enable timer O overflow interrupt; ‘cleared to 0 to disable timer 0 overflow interrupt 0 BO Enable external interupt 0. Set to 1 by program to enable TNTD interrupt; cleared to O to sable INTO interrupt. Bit addressable as 16.010 16.7 p76 5 4 3 2 te - | - | re] ss m [mm | re] me ‘THE INTERRUPT PRIORITY (IP) SPECIAL FUNCTION REGISTER Bit Symbol Funetion 7 = Not implemented, 6 Not implemented 5 PR Reserved for future use a Priority of sevial port interrupt. Seticleared by program, 30m Priority of timer 1 overflow intercupt. Set/cleared by program. 2 PM Prioity of external interrupt 1, Set/cleared by program, a) Priority of timer 0 overtiow interrupt, Set/cleared by program 0 Pxo Priority of extemal interrupt 0, Setcleared by program, Note: Privity may be 1 (highest) or 0 lowest) Bit addressable as 1P.0 1018.7 - jones —$$$_$__$_______________ & As we. mention Byle carlier in this chapter, every | Jarece Bit address SFR register is assigned a bytc address and ports PO- | FF P3 are part of the SFR. For FO [F? F6 F5 F4 F3 Fe Fl FO|B example, PO is assigned byte address 80H, and PI has address of 90H as Do shown in Figure 5-2. While EO |E7 E6 ES E4 E3 —2 £1 £0] acc D7 D6 DS D4 D3 D2 D1 DO| PSW all of the SFR registers are | gg [>a BB BABS BE] IP byte-addressable some of them are also bit-address- BO |B? B6 BS Ba B3 B2 Bl £0] P3 able, The PO - P3 are among Co this category of SFR regis- | A8 [RF “=== AC AB AR AS AO | re ters, From Figure 5-2 we sce that the bit addresses for PO are 80H to 8711, and for AO [AT K6 AS Ad AJ Az Al AO] P2 Pl are 90H to 97H, and so | 99 [____notbitaddressable ——] saur ‘on. 9@ [9F SE 9D 9C 9B 9A 99 98] scon Notice that when 0 code such as “sera | 9° [97 56 95 9453 92 91 90] Pi P1.0" is assembled, it becomes “SETB 90H" sD THL since P1.0 has the RAM ec Not bit-addressable THO address of 90H. Also notice hot bit-addressable TLL from Figures 5-1 and 5-2 | 8% that bit addresses 00 - 7FH 89 belong to RAM byte 88 addresses 20 - 2FH, and bit | 87 addresses 80 - F7H belong to SFR of PO, TCON, PI, | 93 SCON, P2, cic. The bit | 82 addresses for PO - P3 ae | a1 shown in Table 5-3, and | go discussed next not bit-addressable OF 8E 8D 6C €B BA 69 Bb hot bit-addressable DPH DPL SP Po not bit-addressable hot bit-addressable 87 86 85 64 63 AD Bl BO Special Function Registers Figure 5-2. SER RAM Address (Byte and Bity Timer/Counter Microcontroller 8051 8051 has two 16-bit programmable UP timers/counters, TO and T1 respectively. we know 8051 processes on 8 bit data hence we have access to timer using 8-bit special function registers, TLO and THO for timer 0 and TL1 and TH1 for timer 1 respectively. We can use timer as an timer or counter. If we use timer as a timer then then clock source is on chip oscillator otherwise if we want to use timer as a counter; then clock source is external clock. « THO TLO B15 014 D13 D12 D11 D10 D9 valor D6 DS D4 D3 D2 D1 a Timer 0 THI Tu D15 D14 D13 D12 D11 D10 D9 DB|D7 DG D5 D4 D3 D2 D1 DO Timer 1 When we want to create delay using timer then we set some value in respective SFR's of timer. When timer is started the value of SFRi.e value of count gets incremented in every machine cycle. Thus, one can thinkof it as counting machine cycles. Hence we can say the clock rate for timeriis 1/12 th.of the oscillator frequency. When we use timer as a counter, the respective SFR is incremented in response to a 1 to 0 transition at its:corresponding external input pin (TO or T1). It requires 2 machine cycles to detect a high to’ low. transition. Hence maximum count rate is 1/24 th of oscillator frequency..To control operation of the timers/counter 2 special function registers, TMOD and TCON are used. OTe id Read. Onv Read wrte Poy clk eee System Bus Dire Mert dics Cea rere ora Cece na easier? ‘Microprocessor is heart of Computer system. ‘Micro Controller fs a heart of embedded system. It Is just a processor. Memory and 1/0 components have to be connected externally ‘Micro controller has external processor along with internal memory and i/O components Since memory and 1/O has to be connected externally, the circuit becomes large. Cannot be used in compact systems and hence inefficient Cost of the entire system increases Due to external components, the entire power consumption is high. Hence it is not suitable to used, with devices running on stored power like batteries. ‘Most of the microprocessors do not have power saving, features. ‘Since memory and 1/O components are all external, each instruction will need external operation, hence it is relatively slower. ‘Microprocessor have less number of registers, hence more operations are memory based. ‘Microprocessors are based on von Neumann model/architecture where program and data are stored in same memory module ‘Mainly used in personal computers Since memory and I/O are present internally, the circuit is small. Can be used in compact systems and hence it isan efficient technique Cost of the entire system is low Since external components are low, total power consumption is less and can be used with devices running on stored power like batteries. ‘Most of the micro controllers have power saving modes ike idle mode and power saving mode. This helps to reduce power consumption even further. Since components are internal, most of the operations are internal instruction, hence speed Is fast. ‘Micro controller have more number of registers, hence the programs arc easier to write. Micro controllers are based on Harvard architecture ‘where program memory and Data memory are separate Used mainly in washing machine, MP3 players —_— ee _— various modes of operation and SFR's used for sorial communication. na: SERIAL COMMUNICATION IN 8054 Merocontroters need to communicate with external devices such 38 sensors, computers and so con to collect data for processing. Data communication is generally done by means of two methods ~ Parallel and Serial mode. In paraile! mode data bits are transferred faster using more {ala pins. But when il comes to a Wicroconiraler, we eannat afford to dedicate many pins for ata transfer, UART or Serial communication in 8051 microcertrlier wil allow the controller to send anc receive data just by using tao pins Serial Communication uses only two cata pins to esiablish communication between Mecrocontioler and extemal devices. In this mode of communication dala is transterred one bit ‘at a time. This article desenbos Interfacing of 051 with PC to estabish communication ‘through is serial por S232, SERIAL COMMUNICATION MODES: Mode 0: In this mode serial port runs in synetwonous mode. The data is vansmitied and received through the RXO pin and TXD is used for clock output. In this mode the baud rate is 1/12 of ‘lock trequency. Mode: In this mose SBUF becomas a 10 bit full cuplex transceiver. The ten bits are 1 start bi, 8 ala bits and 1 stop bt. The interrupt flag T/RI wil be set once transmission or reception is ‘over. In this mode the baud rate is variable and is determined by the timer 1 oveiow rate, Boud rate = [2smodia2} x Timer 1 overfiow Rate * (2smod/32} x [Oscillator Clock Frequency]! [12 x [256 — [THI] Mose2: ‘This is similar to mode 1 except 11 bis are transmited or received. The 11 pts are, 1 sian bit, 8 ¢ata bts, a programmable Gtr data bit, 1 stop bit Moge 3: ‘This is simlar to mode 2 except baud rate is calculated as in mode t ‘Three special function registers support serial communicatio 1. SBUF Register: Serial Butter (SBUF) registers an 8 bit register Ithas separate SBUF registers for data transmission and for data reception. For a byte of dala lo be transferred via the TXD tine, must be placed in the SBUF register. SImiarly, SBUF holds the a-bit data received by the RXD pin and ready to accept the received dala 2. SCON register: The contents ofthe Serial Control (SCON) register are shown below, This, ‘ogister contans mode selection bts, seal port interrupt Dt (TT and RI) anc also the ninth dala bil for transmission and reception (TB8 and RBS) 3. PCON register: The SMOD bt (bit7) of PCON register controls the baud rate in ‘asynchronous mace transmvssion, land (on automate transmission cars) gear smirung. Characteristics of Embedded Computing Applications: 2. Complex Algorithms b. User Interface ©. RealTime d. Multirate EMBEDDED SYSTEMS-By BRN Page 6 ECE DEPARTMENT UNIT-1 EMBEDDED COMPUTING e. Manufacturing Cost £. Power Complex algorithms: The operations performed by the microprocessor may be very sophisticated. For example, the microprocessor that controls an automobile engine must perform complicated filtering functions to optimize the performance of the car while minimizing pollution > User Interfoce: Microprocessors are frequently used to control complex user Interfaces that may include mukiple menus and many options. The moving maps in Global Positioning System (GPS) navigation are good examples of sophisticated user Interfaces. To make things more difficult, embedded computing operations must often be performed to meet deadlines: Tomate things more difficult, embedded computing operations must often be performed to meet lines: > Reat tlme: Many embedded computing systems have to perform in real time— if the data fs not ready by & certain deadline, the system breaks. In some cases, failure to meet a deadline Is unsafe and can even endanger bves. In other cases, missing a deadline does not create safety problems but does create unhappy customers—missed deadiines in printers, for example, canrresutt in scrambled pages. ‘Multirate: Not only must operations be completed by deadlines, but many embedded computing systems have several real-time activities going on at the same tlme, They may simultaneously control some operations that run at slow rates and others that run at high rates, Multimedia applications are prime examples of multirate behaviour. The audio and video portions of a multimedia stream run at very different rates, but they must remain closely synchronized. Failure to meet a deadline on either the audia or video portions spoils the perception of the entire presentation. Costs of various sorts are also very important: > sanufocturing cost: The total cost of building the system is very important in many cases. Manufacturing cost ts determined by many factors, Including the type of microprocessor used, the amount of memory required, and the types of 1/0 devices, » power onxt energy: Power consumption directly affects the cost of the hardware, since a larger power supply may be necessary. Energy consumption affects kattery life, which is Important in many applications, as well 4s heat consumption, which can be important even in desktop applications. THE EMBEDDED SYSTEM DESIGN PROCESS ‘The embedded system design process aimed at two objectives. © First, it will give us. an introduction to the varlous steps in embedded system design EMBEDDED SYSTEMS-By BRN UNIT-1 EMBEDDED COMPUTING ECE DEPARTMENT © Second, Itwill allaw us to consider the destgn methodology itself Adesign methodology Is important for three reasons. © First, to ensure that we have done everything we need. © Seeand, It allows us to develop computer-aided detign tools, © Third, it makes member Ts of a design team to communicate easily Raétnntnm nan tee dene _ The program status word is shown in Figure 2.4. The PSW contains the math flags, user program flag FO, and the register select bits that identify which of the four general-purpose register banks is currently in use by the program. The remaining two user flags, GFO and GFT, are stored in PCON, which is shown in Figure 2.13. FIGURE 2.4 PSW Program Status Word Register 7 6 5 4 3 2 1 0 el

You might also like