• No results found

354 39 Solutions Instructor Manual 11 Hardware Features 8051 Chapter 11

N/A
N/A
Protected

Academic year: 2021

Share "354 39 Solutions Instructor Manual 11 Hardware Features 8051 Chapter 11"

Copied!
8
0
0

Loading.... (view fulltext now)

Full text

(1)

Chapter 11 

Hardware features of 8051 

Solution to Numerical/DESIGN‐BASED EXERCISE:  1. Show the circuit connections for interfacing 16K of EPROM IC 27128 and 8 K of RAM IC  6264 with the 8051.    The first step in interfacing is to select or fix the address range for the chips to be used. As the  27128 has 16 KB of memory registers, it requires 14 address lines to select one memory location  in  it.  The  address  map  of  the  27128  is  fixed  as  0000H–3FFFH.  The  address  range  for  the  8KB  RAM chip 6264 is selected as C000H–DFFFH. 

The  most  significant  bits  A14  and  A15  are  used  to  decode  and  select  the  chip.  For  decoding  purposes, a 2‐to‐4 decoder chip, the 74139, is used. The 74319 has a dual 2‐to‐4 decoder and  one of them is used for selecting the EPROM chip. Bits A14 and A15 are at logic 0 for the EPROM  chip  and  the  Y0  output  is  made  active  low  for  the  corresponding  A14  and  A15  inputs.  This  Y0  signal is used as the active low chip select input of the IC 27128. 

(2)

 Bits A14 and A15 are at logic 1 for the RAM chip and the Y3 output is made active low for the  A14 and A15 inputs as logic high. This Y3 signal is used as the active low chip select input of the  IC 6264.  The connection diagram is shown in Figure. The 8‐bit latch or register IC 74373 is used  to de‐multiplex the lower‐order address and data bus. OE is the data read enable line of the  27128 and is connected to the PEN signal output of the 8051. The data read enable line of the  6264 is OE, which is connected to the P3.7 port output of the 8051. Similarly, the write enable  input 6264 is connected to the port line P3.6 of the 8051.  Solutions to THINK AND ANSWER Exercises  1. What are the conditions for external memory access in the 8051? 

Connecting the EA pin of the 8051 to logic 1 or +5 V will program the

microcontroller to use the internal program memory for the addresses starting at 0000H.

After the available internal memory is addressed, then the external memory is accessed.

Connecting EA pin to logic 0 will make the microcontroller use only external

memory for all the addresses starting from 0000H.

2. What is the purpose of multiplexing the lower‐order address bus with the data bus for  external memory access? 

The purpose of multiplexing is to reduce the pin count and reduce the number of

pins required.

3. What are the advantages of separate data and program memory (Harvard architecture)? 

The separate data and program memory increases the memory addressing

capability of the microcontroller. Moreover, as the program and data are separate, the

chance of erasing of program memory by mistake as data is removed.

(3)

The clock frequency to counter is 12MHz/12; the counter will get the clock pulses

at the 1 MHz rate. So, the counter will be incremented every 1 µs. The program

uses bit counter mode. The timer should produce a delay of 1000 µs. So, the

16-bit counter must be initialized to 64535 (i.e., 65535 - 1000). The hexadecimal

equivalent of this decimal value is FC17. Therefore, the lower-order eight bits of

the timer are initialized to 17H and the higher-order eight bits to FCH.

The following DELAY subroutine uses the polled method of waiting for 1msec and

then returns to main program.

DELAY: MOV TMOD, #00000001B

; Set Timer 0 in mode 1 (16-bit operation). CLR TF0 ; Clear the Timer 0 overflow flag.

LOOP: MOV TH0, #0FCH ; Initialize the 16 bits of Timer 0 with the appropriate value. MOV TL0, #17H

SETB TR0 ; Start or run Timer 0 by setting the TR0 bit.

WAIT: JNB TF0, WAIT ; Read, check, and loop until the overflow bit TF0 in TCON register is set.

CLR TR0

CLR TF0 ; Clear the overflow flag. RET

 

5. Write a routine using a timer of the 8051 to count the cars moving on a road and to give  a signal when the count value reaches 100.  

To  count  the  external  pulses,  Timer  1  is  initialized  as  a  counter  by  setting  the  D6  bit  of  TMOD. Mode 1 of Timer 1 is used in this example, as 100 objects are to be counted and  this can be accomplished by the 8‐bit timer auto reload mode. Timer 1 is loaded with the  value 155 (i.e., 255 ‐ 100), which in hexadecimal form is 9B. This gives an interrupt after  100 counts.  The program is written in two parts. The main program initializes the timer and  runs it. After that, the main program does nothing. Detecting the count value of 100 is 

(4)

done automatically, by generating an interrupt and then giving logic 1 output on port pin  is done in the Interrupt service routine.  

Main program: 

 

MAIN: MOV TMOD, #01110000B   ; Set Timer 1 in mode 1 (counter operation).

MOV TH1, #09BH     ; Load the Timer 1 count. 

MOV IE, #10001000B   ; Enable Timer/Counter 1 interrupt  

SETB TR1     ; Start Timer/Counter 1. 

LOOP: LJMP LOOP   ; Loop and do nothing. 

Interrupt service routine:  ISR_TIMER1: CLR TR1       ; Stop Timer 1 to be safe.  SETB P1.0       ; Set high LSB of P1.  RETI     ; Return from interrupt.    6. Write the Interrupt Priority word for making serial port and external interrupt 1 as high  priority and other interrupts as low priority ones.  Interrupt Priority word format  Bit  D7  D6  D5  D4  D3  D2  D1  D0 

(5)

position   Name  EA  ‐  ‐  PS  PT1  PX1  PT0  PX0    1  0  0  1  0  1  0  0  Explanatio n Enable Interrupt s — Made 1 to enable all interrupt s Undefine d Undefine d Set Serial interrup t as high priority Timer 1 interrup t priority Set Extern al 1 interrup t as high priority Timer 0 interrup t priority Extern al 0 interrup t priority Corresponding Interrupt priority word is 94H.  7. Write the control word for masking external interrupts in an 8051‐based system.  Interrupt Enable Register format  Bit  position   D7  D6  D5  D4  D3  D2  D1  D0 

Name  EA  ‐  ‐  ES  ET1  EX1  ET0  EX0 

  1  0  0  1  1  0  1  0  Explanatio Global  interrupt  enable/  disable  Undef ined  Undefine d  Enable  serial  interru pt  Enable  Timer 1  interru pt  Disable  externa l 1  interru pt  Enable  Timer 0  interru pt  Disable  externa l 0  interru pt    8. Write the control word format for setting the serial port in mode 1.  

(6)

Bit patterns for SCON register 

Bit  Name  Value  Explanation of function 

D7  SM0  0  D6  SM1  1  Serial port mode select bits  D5  SM2  0  Multiprocessor communications enable bit  D4  REN  1  Receiver enable — This bit must be set, to receive characters.  D3  TB8  0  Transmit bit 8 — The 9th bit to transmit in modes 2 and 3  D2  RB8  0  Receive bit 8 — The 9th bit received in modes 2 and 3  D1  TI  0  Transmit Interrupt flag — Set when a byte has been completely transmitted D0  RI  0  Receive Interrupt flag — Set when a byte has been completely received  Corresponding SCON value is 01010000B i.e. 50H.   9. Calculate the reload value of Timer 1 for achieving a baud rate of 4800 in the 8051, for a  crystal frequency of 11.0592 MHz.  The relation between the baud rate and the TH1 timer reload value is given below.  TH1 = 256 ‐ ((Clock frequency/384)/Baud) if SMOD in PCON SFR is 0.  TH1 = 256 ‐ ((Clock frequency/192)/Baud) if SMOD in PCON SFR is 1  Accordingly, for 4800 baud rate, the reload value is F9H if SMOD bit is 0 and F3H if SMOD bit  is 1. 

(7)

10. Write an 8051 ALP to transmit ‘Hello World’ serially at 9600 baud for a crystal frequency  of 11.0592 MHz. 

Following program assumes that the ASCII code for the characters ‘Hello World’ are stored consecutively in the internal memory 40H onwards.

MAIN:        ; Set up Timer 1 to drive baud rate of 9600.  

MOV TMOD, #00100000B; Set Timer 1 in mode 2 (8‐bit timer). 

MOV TH1, #0FDH     ; Time Timer 1 for 9600 baud. 

SETB TR1       ; Enable Timer 1 for free run. 

MOV SCON, #01000000B; Initialize serial port for mode 1 operation.

MOV R0, #40H    ; Initialize memory pointer. 

MOV R1, #0BH    ; Intialize a counter for the number of  characters in the words ‘Hello World’. 

SEND: MOV SBUF,@R0  ; Get the data from memory and send it to SBUF for  transmission.  

LOOP: JNB TI, LOOP   ; Test TI flag to check whether data has been sent. 

CLR TI     ; Clear TI. 

INC R0    ; Point to the next data. 

DJNZ R1, SEND  ; Loop again to send data, if not completed. 

(8)

       

References

Related documents

The key segments in the mattress industry in India are; Natural latex foam, Memory foam, PU foam, Inner spring and Rubberized coir.. Natural Latex mattresses are

b In cell B11, write a formula to find Condobolin’s total rainfall for the week.. Use Fill Right to copy the formula into cells C11

○ If BP elevated, think primary aldosteronism, Cushing’s, renal artery stenosis, ○ If BP normal, think hypomagnesemia, severe hypoK, Bartter’s, NaHCO3,

The PROMs questionnaire used in the national programme, contains several elements; the EQ-5D measure, which forms the basis for all individual procedure

• Speed of weaning: induction requires care, but is relatively quick; subsequent taper is slow • Monitoring: Urinary drug screen, pain behaviors, drug use and seeking,

Online community: A group of people using social media tools and sites on the Internet OpenID: Is a single sign-on system that allows Internet users to log on to many different.

Date Established Number of Offices Total Employees S Corp (Yes/No) Total Assets ($000) ROAA (%) ROAE (%) Alamerica Bank Birmingham Alamerica BancCorp, Inc.. Bank Listing

It is the articulation of these specific elements listed above and the strategies for their deployment in the context of Morrison’s cultural politics of difference and the