Tutorial 1

OBJECTIVE: To test the 8051 system and its ports. REFERENCE: Mazidi and Mazidi, “The 8051 Microcontroller and Embedded Systems,” Chapter 4, Appendix B, and Appendix C.2. MATERIALS: 8051 trainer Logic probe DIP switches with pull-up resistors 8051 Assembler You can either buy a pre-built 8051 trainer or wire-wrap your own trainer. Details on wire-wrapping an 8051 trainer are given in Appendix B of the textbook. We will use such a trainer in all subsequent labs. ACTIVITY 1 Test the operation of the ports of your 8051 trainer as follows. Assemble and run the test program given in Appendix B. The test program toggles the ports of the 8051. Use a logic probe or the LEDs of your digital trainer to watch the bits of the ports toggle on and off. Make sure that the time delay in between the "on" and "off" states is long enough that you can observe each state clearly. ACTIVITY 2 Test the 8051's ports for input operation as follows. Connect each bit of P1 (P1.0 P1.7) of the 8051 to DIP switches of your digital trainer. Make sure that the switches have either pull-up resistors or are buffered as shown in Appendix C.2. Read Appendix C.2 very carefully to make sure that you do not damage the port. Then write and run a program to get data from P1 and send it to P2. Any change of status of the switches connected to P1 will be instantly reflected on LEDs connected to P2. The testing program could look like this. MOV MOV MOV MOV SJMP A,#0FF P1,A A,P1 P2,A HERE ;A=FFH ;make P1 an input port ;get data from P1 ;send it to P2 ;keep doing this

HERE:

1

Name:

Date:

Class:

1. Upon reset, all ports of the 8051 are configured as _____________ (output, input).

2. Which ports of the 8051 have internal pull-up resistors?

3. Which ports of the 8051 require the connection of external pull-up resistors in order to be used for I/O? Show the drawing for the connection.

4. In the 8051, explain why we must write "1" to a port in order for it to be used for input.

5. Explain why we need to buffer the switches used as input in order to avoid damaging the 8051 port.

2

“The 8051 Microcontroller and Embedded Systems. Then write and run a program to display your name on line 1 of the LCD (first name followed by last name with a space in between). When you run your program. 3 . Note: If you are not monitoring the busy flag of the LCD.” Chapter 12. the LCD should show (for example): Alex Young Graduated in 1978 ACTIVITY 3 Write an LCD program to display your last name on the first line and the current year on the second line.1 of the textbook. ACTIVITY 1 Connect the LCD to your 8051 trainer as shown in Section 12. ACTIVITY 2 Repeat Activity 1 while also putting the year you graduated from high school on the second line. REFERENCES: Mazidi and Mazidi. Dot Matrix LCD Module: Character-type DMC Series User's Manual by Optrex Corp. or a compatible one.Tutorial 2 OBJECTIVES: To understand the operation modes of an LCD. To interface and program an LCD. Both should be in the middle of the line. See the discussion in Chapter 12. MATERIALS: 8051 Assembler 8051 Trainer 20x2 LCD DMC20261 from Optrex DMC series. put a few milliseconds delay in your program.

When is the information (code or data) on the LCD pin latched into the LCD? 4 . 4. What is the purpose of the E line? Is it an input or an output as far as the LCD is concerned? 5. To send the instruction code 01 to clear the display.Name: Date: Class: 1. 3. we must make RS = ____. To send letter 'A' to be displayed on the LCD. we must make RS = ___. How does the LCD distinguish data from instruction codes when receiving information at its data pin? 2.

In each case. 5 . The next lab will build upon the connections you have made in this lab.Tutorial 3 OBJECTIVE: To interface an ADC to the 8051. C=150 pF You can test the ADC804 before you connect it to the 8051.html MATERIALS: 8051 trainer 8051 assembler ADC804 R=10 K ohms. As you change the potentiometers. ACTIVITY Connect the ADC804 to the 8051 as shown in Figure 12-7 or 12-8 in the textbook. Then assemble and run a program to display the data on the LCD or send it to a PC screen through the serial port of the 8051. “The 8051 Microcontroller and Embedded Systems.” Chapter 12." Set the potentiometer at different points and see the digital binary output of the ADC indicated on the LEDs. set up the circuit shown in Figure 12-5 of the textbook. make sure that you use at least three or four D flip-flops to bring down the frequency. In that figure. This setup is called free running test mode and is recommended by the manufacturer.national. or (2) use the XTAL frequency from the 8051 trainer as shown in Chapter 12 for the ADC804. For the clock source of the ADC804 you have two more options beside the RC circuit: (1) use an external clock source (square wave TTL). use the voltmeter to measure the POT voltage and verify the result. where FFH is for a full-scale input. we use a potentiometer to apply a 0-to-5 V analog voltage to the input Vin (+) of the ADC804 and the binary outputs are monitored on the LEDs of the digital trainer. indicating the value of the analog input.com/catalog/AnalogDataAcquisition. web site: www. Look for the ADC804 data sheet in The National Semiconductor Corp. REFERENCES: Mazidi and Mazidi. On the breadboard. However. It must be noted that in free running test mode the CS input is grounded and the WR input is connected to the INTR output. Notice that the ADC output is between 0 to FFH. according to National Semiconductor's databook "the WR and INTR node should be momentarily forced to low following a power-up cycle to guarantee operation. this must be converted to decimal and then to ASCII in order to be displayed on the LCD. the output should change. However. If you use the XTAL frequency from the 8051.

INTR. State the status of the CS.1. and INTR from the point of view of the 8051. and WR pins in each step. Find the following. RD. Assume that Vref/2 is connected to 1.2 V (d) Vin if D7 . 3. (a) step size (b) maximum range for Vin (c) D7 . The ADC804 is a(n) ____-bit converter.7 V (d) Vin if D7 . To get step size of 2 mV. 2. 6. Assume that Vref/2 is connected to 1.D0 = 11011101 5.D0 values if Vin = 1. RD. what is the value for Vref/2? 6 .28 V.D0 = 10011100 4. Indicate the direction of pins WR. Give the three steps for converting data and getting the data out of the ADC804. Find the following.9 V.D0 = 11111111 (e) Vin if D7 . (a) step size (b) maximum range for Vin (c) D7 .D0 = 11111111 (e) Vin if D7 .D0 values if Vin = 2.

ACTIVITY In place of a potentiometer.” Chapter 12. “The 8051 Microcontroller and Embedded Systems.national. 7 . For the sensor's data sheet. Then write a program to display the temperature on the LCD (or PC monitor) continuously.Tutorial 4 OBJECTIVE: To interface an LM35 (or LM34) temperature sensor to the 8051 trainer. REFERENCES: Mazidi and Mazidi. use the LM34 sensor and set up the circuit shown in Figure 12-10 of the textbook. see National Semiconductor’s web site: www.com MATERIALS: 8051 trainer 8051 assembler LM35 (or LM34) ADC804 LM336-2. and 10K resistors You need to complete Lab 3 to experiment with the temperature sensors before performing this lab. 1.5 10K POT 1K. Heat up or cool down the sensor and observe the temperature.5K.

6. The LM35/LM34 is a ____________ (linear.Name: Date: Class: 1. 5. What is the form of the transducer output? 3. Explain signal conditioning and its role in data acquisition. What is a transducer? 2. 8 . The LM35 and LM34 produce a _______ mV output for every degree of change in temperature. What is preprocessing of transducer signals to be fed into an ADC called? 4. Discuss the advantages of linear devices and of nonlinear devices. nonlinear) device.

Then examine the frequency using the oscilloscope. To generate a square wave using the 8051 timer. “The 8051 Microcontroller and Embedded Systems.” Chapter 9. REFERENCE: Mazidi and Mazidi. Modify the count value to make sure that the frequency is exactly 1 kHz. MATERIALS: 8051 trainer 8051 assembler Oscilloscope ACTIVITY 1 Write a program using timer 0 to generate a 500 Hz square wave frequency on one of the pins of P1. 9 .Tutorial 5 OBJECTIVES: To program the 8051 timer. Modify the count value to make sure that the frequency is exactly 500 Hz. ACTIVITY 2 Write a program using timer 1 to generate a 1 kHz square wave frequency on one of the pins of P1. Then examine the frequency using the oscilloscope.

0592 MHz? Show your calculation. 3. when is TFx set to high? 6. What is the lowest frequency that can be generated using Mode 1 if the crystal frequency is 11. 5. In mode 1. What is the maximum frequency that can be generated using Mode 2 if the crystal frequency is 11. In mode 2. 2.0592 MHz? Show your calculation. What is the maximum frequency that can be generated using Mode 1 if the crystal frequency is 11.0592 MHz? Show your calculation. 4. What is the lowest frequency that can be generated using Mode 1 if the crystal frequency is 11. when is TFx set to high? 10 .Name: Date: Class: 1.0592 MHz? Show your calculation.

5. connect your 8051 system to the PC's COM 2 port. 8 bit data. 11 . Type a dummy name. Then write a program to transfer your last name to the PC continuously. choose "NO"). Change the "Flow Control" to NONE or Xon/Xoff and click OK (definitely do not choose the hardware option). write a program to get data from the PC and display it on an LCD. 3. click on Hyperterminal (if you get a modem installation option. 2. As you press a key on the PC's keyboard. connect P1 to LEDs of your digital trainer and observe the incoming characters (or use a logic probe). the character is sent to the 8051 serially and is displayed on LEDs. ACTIVITY 3 Modify and run the program in Activity 1 to transfer the data at the rate of 56K. “The 8051 Microcontroller and Embedded Systems. Here are the steps to set up Hyperterminal: 1. www. ACTIVITY 2 After making sure that Activity 1 works properly. For "Connect Using" select COM2 and click OK. After running your 8051 serial program. no parity bit.maxim-ic. you should see your last name fill the PC screen.x) which comes with MS Windows 95 and 98. On the PC side you need to use the Hyperterminal program (or Terminal in Windows 3.com MATERIALS: 8051 trainer 8051 assembler MAX233 (or MAX232) DB-9 RS232 connector with serial cable IBM PC/compatible computer with COM2 port ACTIVITY 1 After connecting (wire wrapping) the MAX233 to the 8051 as shown in Figure 10-8 in the textbook. and 1 stop bit. If you do not have an LCD connected to the 8051.Tutorial 6 OBJECTIVES: To interface the MAX233 (or MAX232) to the 8051. The characters displayed on LEDs are in ASCII (binary). Pick 9600 (or whatever baud rate you programmed the 8051). We use COM2 since COM1 is normally used by the mouse. and click OK.” Chapter 10. In Windows Accessory. To write a program to transfer data to a PC serially. To write a program to receive data from a PC serially. REFERENCES: Mazidi and Mazidi. 4.

0592 MHz. For full duplex. 7. With XTAL=11. 5. what is the maximum baud rate for the 8051? 4. what is the role of the MAX233 (MAX232) chip? 3. 12 . 2. are not) TTL-compatible. True or false. The 8051 TxD and RxD signals ________ (are. What is the role of TI and RI? 6. what are the absolute minimum signals needed between the 8051 and the PC? Give their names. Show how to achieve the maximum baud rate in Question 3.Name: Date: Class: 1. In this lab. The 8051 can transfer data in full-duplex.

national. indicating the value of the analog input.com web site.” Chapter 12. 1. The ADC808/809 is a single chip that can accommodate up to 8 analog inputs. 13 . Read about this chip in Chapter 12 and also download the data sheets from the www.Tutorial 7 OBJECTIVE: To interface an ADC809 to the 8051. 3. you can either use an external clock source (square wave TTL). (b) Activate START (200 µsec). REFERENCES: Mazidi and Mazidi. The ADC808/809 clock frequency is between 10 kHz and 1250 kHz and must be a minimum of 3V peak. (d) Send low to OE (for a minimum of 250 µsec). or use the XTAL frequency from the 8051 XTAL as shown in Chapter 12 for the ADC804. this must be converted to decimal and then to ASCII in order to be displayed on the LCD. Read data from the ADC808/809 and follow these steps. For the clock source of the ADC808/809. As you change the potentiometers. These 8 inputs are called channels and each is selected by an address. 2. (c) Poll EOC for high. which is preferable. (e) Read the data from the data pin. Notice that the ADC output is between 0 to FFH where FFH is for a full-scale input. Thank you to John Maddux for his input on this lab. “The 8051 Microcontroller and Embedded Systems. However. Make sure that you use at least three or four D flip-flops to bring down the frequency. Notice the following points when interfacing the 8051 to the ADC808/809. Connect the ADC808/809 to the 8051 and write a program to display data input from at least two of the channels. The minimum pulse width for ALE = 200 µsec and OE = 250 µsec.national. the output should change. (a) Select the channel. Each channel can be connected to separate potentiometers to examine the data displayed.html MATERIALS: 8051 assembler and trainer ADC808/809 TTL square wave and TTL square wave clock source ACTIVITY 1 In many applications we need to have multiple analog-to-digital converters.com/catalog/AnalogDataAquisition. www.

3.D0 = 11111111 (e) Vin if D7 . In the ADC809 assume that Vref is connected to 2. and OE from the point of view of the 8051. In connecting ADC808/809 to an 8051. B.D0 = 10011100 5. A. 14 .2 V (d) Vin if D7 . and C in selecting the ADC channel. EOC. In the ADC809 assume that Vref is connected to 5V. indicate the direction of pins ALE. Find the following. and OE from the point of view of the ADC808/809.56 V.D0 = 11111111 (e) Vin if D7 – D0 = 11011101 6. 2. State the status of the SC and EOC pins in each step. Give the role of signals ALE. SC.D0 values if Vin = 1. (a) step size (b) maximum range for Vin (c) D7 .Name: Date: Class: 1. (a) step size (b) maximum range for Vin (c) D7 . EOC. SC. Indicate the direction of pins ALE.D0 values if Vin = 2. 4.7 V (d) Vin if D7 . Give the steps for converting data and getting the data out of the ADC809. Find the following.

com/catalog/AnalogDataAcquisition. REFERENCES: Mazidi and Mazidi. change the POT value and monitor the output sine wave on the scope.” Chapter 13. www. Write and run a program to create the sine wave on the oscilloscope. Then set up a circuit like the one shown in Figure 13-7.Tutorial 8 OBJECTIVES: To interface a DAC to the 8051.html MATERIALS: 8051 assembler and trainer DAC0808 from National Semiconductor (or its equivalent MC1408 from Motorola) 100 pF capacitor Resistors: 2 of 1K.national. Change the delay values and state your conclusions.5K 5 K potentiometer ACTIVITY First generate (calculate) a table similar to Table 13-5 of the textbook for sine values of 4-degree increments. 15 . 2 of 1. Put a delay in between each outputting of values to DAC and observe the sine wave on the scope. “The 8051 Microcontroller and Embedded Systems. To generate a sine wave on the scope using the DAC. Also in your circuit.

Define the following terminology in DAC. less) data bit inputs. (a) 11001100 (b) 10001111 3. find Vout for the following inputs. Calculate Vout for the following binary inputs. we need DAC with ________ (more. 4. (a) 11000010 (b) 01000001 (c) 00101100 (d) 11111111 16 .Name: Date: Class: 1. To get a smaller step size. In Figure 13-7 of the textbook.5 K ohms. For your circuit. (a) resolution (b) full-scale voltage output (c) settling time 2. assume that R = 2.

Tutorial 9 OBJECTIVES: To program the timer interrupt of the 8051. In this activity you can also use INT1 17 . ACTIVITY 4 Write an 8051 program to get data from one port and send it to another port continuously while an interrupt will do the following: A square wave is connected to the INT0 (pin 3. ACTIVITY 2 Write an 8051 program to get data from a single bit of P1. MATERIALS: 8051 trainer 8051 assembler Square wave generator ACTIVITY 1 Write an 8051 program to get data from one port and send it to another port continuously while an interrupt will do the following: One of the timers will toggle the PX. To program the hardware interrupt of the 8051. (Either connect LEDs to this port to examine the data coming in or display the received data on an LCD).2) and any time a H-to-L pulse comes in a single LED is turned on. a single LED is turned on.Y bit every 100 microseconds.2 and send it to P1. The rate of "On" and "Off" is the rate of the square wave. REFERENCE: Mazidi and Mazidi. To program the serial interrupt of the 8051. ACTIVITY 3 Write an 8051 program to get data from one port and send it to another port continuously while an interrupt can do the following: Connect the INT0 (or INT1) pin to a normally high debounce SW and any time the switch is pressed. “The 8051 Microcontroller and Embedded Systems.7 continuously while an interrupt will do the following: A serial interrupt service routine will receive data from a PC and display it on one of the ports.” Chapter 11.

4. Name all of the interrupts in the 8051 and their vector table addresses. 18 . On reset. INT0 (and INT1) are _________ (edge. which interrupt has the highest priority? 6. On reset. indicate when TF0 causes the interrupt. In timer mode 2. indicate when TF0 causes the interrupt. True or False. 2.Name: Date: Class: 1. In timer mode 1. There is only a single interrupt for the serial data transfer. level) triggered. 3. 5.

To gain an understanding of printer handshaking signals. Connect the data bus and handshaking signals of the printer to your 8051 as shown in Figure C-20. In the code section put the following data: Last name. MATERIALS: 8051 assembler and trainer Centronics printer 74LS244 ACTIVITY 1 Examine the Centronics cable pins and their description in Chapter 15 of the textbook.” Chapter 15. "OK IT WORKS !" ACTIVITY 2 Make the following modifications in the program of Activity 1. Write and run a program to print the message. as shown below: MYDATA: ORG 200 DB "Smart Alex".Tutorial 10 OBJECTIVES: To interface a Centronics printer to the 8051. “The 8051 Microcontroller and Embedded Systems. Use the ASCII code OA (hex) for line feed and OD (hex) for carriage return to make sure that each line is printed on a separate line.OAH. Make sure you have buffered the signals with 74LS244 chips.0DH 19 . First name Date Course number Each of the above must be printed on a separate line. REFERENCE: Mazidi and Mazidi. plus Figure C-20.

the strobe pins needs a ______________ (H-to-L. L-to-H) signal. Direction Signal D0-D7 STROBE ACK 3. To make the printer latch in data at its data pins. Printer's Handshake Signal Normal State Active State Strobe ACK 4. 5. indicate its normal status (high or low) and the activation level for each (active low or active high). For each of the following signals. low) before issuing the next byte of data to the printer. 6. 20 . In monitoring the busy signal. the 8051 looks for _______ (high. Indicate the direction of the following signals from the printer's point of view. Signal Direction D0-D7 STROBE ACK 2. Explain the role of the strobe and busy signals in the handshaking between the 8051 and the printer.Name: Date: Class: 1. Indicate the direction of the following signals from the 8051's point of view.

Since this ROM chip is for code. REFERENCES: Mazidi and Mazidi.” Chapter 14 and Appendix B.1 if you have never done any wire wrapping.Tutorial 11 OBJECTIVE: To interface an 8031 to external ROM. study the basics of wire wrapping in Appendix B.A ACALL DELAY CPL A SJMP BACK BACK: For the delay subroutine see Chapter 3. The size of the ROM chip (UV-EPROM or EEPROM) should be 8K or higher. See Chapter 4 for the crystal and reset connection. MATERIALS: 8031 microcontroller 27XX UV_EPROM (or 28XX EEPROM) 74LS373 Wire wrapping tools Study Chapter 14 and examine the 8031 connection to external memory. That is important since some people try to use the unused portion of P2 for I/O.#55H MOV P1. test the system by running a test program burned into the ROM. “The 8051 Microcontroller and Embedded Systems. 21 . Notice that in connecting the 8031(8051) to external memory we cannot use P2 for I/O ports. ACTIVITY 1 First. The test program simply toggles P1 continuously with a delay in between the "on" and "off" states. Then wire wrap the 8031 connection to a ROM chip according to Figure 14-11. make sure that the crystal and reset circuits are also included in your design. The following test program can be burned into the ROM. ACTIVITY 2 After the wire wrapping is done in Activity 1. ORG 0 MOV A. In the following activities you can also use any of the 8051 chips.

Name: Date: Class: 1.P2. only P2. What is the role of the PSEN pin in the 8031/51 connection to external ROM? 4. In connecting the 8031/51 to external ROM.0 .7 for I/O? 22 . how do we make sure that program code is fetched from external ROM? 3. 5. In connecting the 8031 to an external memory. explain the difference between the RD and PSEN signals and where each one is used. Capacity: Number of address pins: Organization: Number data pins: 2. Give the following information for the ROM used in this experiment. can we use P2. In the 8031/51. explain the role of the following: P0 P2 74LS373 6. What is the size of this external memory? 8. In Question 7.5 are used. In connecting the 8031/51 to external ROM. What is the maximum external memory that can be connected to the 8031? For code space: For data space: 7.6 and P2.

The toggle program is given in Chapter 15. The test program simply toggles ports A. If you do not want to use an inverter. Wire wrap the 8031 connection to an 8255 chip according to Figure 15-4 of the textbook. ACTIVITY 1 If you have not done any wire wrapping before. ACTIVITY 2 After wire wrapping the circuit in Activity 1.” Chapter 15. In the following activities you can also use any of the 8051 chips.1. 23 . B. Appendix B. connect the CS (chip select) pin to ground.1. MATERIALS: 8031(or 8051) microcontroller 8255 74LS373 Wire wrapping tools Study Chapter 15 and examine the 8031/51 connection to the 8255 chip. study Appendix B. and C of the 8255 continuously with a delay in between the "on" and "off" states.Tutorial 12 OBJECTIVE: To interface an 8031 to the 8255. test the 8255. REFERENCES: Mazidi and Mazidi. “The 8051 Microcontroller and Embedded Systems.

" Is the 8255 connection in this experiment a memory mapped I/O? 24 . 4. Explain the term "memory mapped I/O. 5. explain the role of the RD and WR signals. PA PB PC CR Port 2. In connecting the 8031/51 to the 8255. explain the role of the following and indicate if its use is optional.Name: Date: Class: 1. Write a program to get data from PA and send it to both PB and PC. In connecting the 8031/51 to the 8255. Why do we use the "MOVX" instruction to access the 8255 in this experiment? 3. Give the addresses assigned to each of the following ports in this experiment. P0 P2 74LS373 6.

Sign up to vote on this title
UsefulNot useful