Sie sind auf Seite 1von 118

ITT TECHNICAL INSTITUTE

ET2640
Microprocessors and Microcontrollers
Onsite Course

GRADED ASSIGNMENTS

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Graded Assignments
Unit 1 Assignment 1: Basic Concepts and Numerical Methods
Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Use numerical methods for processor-based systems to perform calculations and conversions
related to programming.

Draw and label block diagrams of microcontrollers showing the arithmetic logic unit (ALU),
internal bus structure, and registers and peripheral function blocks.

Describe the essential processor control, data, and address bus elements and timing cycles.

Examine fundamental processor I/O interfacing methods.

Summarize the history of 8051.

Identify advantages processors have over custom fixed-gate implementations.

Describe the function of the major elements in the 8051 CPU architecture.

Distinguish the major differences between microprocessors and microcontrollers.

Convert among base 10, hexadecimal, and binary numbering.

Compute addition and subtraction of hexadecimal, octal, and binary numbers.

Explain the use of carry bits in binary addition and subtraction.

Compare address bus, data bus, and control bus in terms of their function, direction, and bus
width.

Calculate the organization and capacity of memory chips.

Compare full and partial address decoding.

Compare PROM, EPROM, EEPROM, and flash-memory EEPROM.

Compare SRAM, NV-RAM, and DRAM.

Contrast Harvard vs. Von Neumann processor architectures of 8051 and Atmel AVR devices.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R.

Chapter 0: Problems 1-8, 21, 24-34, 37-40, 43, 44, 46, 51-55, 64-66

Chapter 1: Problems 1-5, 7, 8, 12, 15, 17-22, 28-30

Search the ITT Tech Virtual Library and find five applications for microprocessors and five
applications for microcontrollers. Record your findings in a Microsoft Word document.

-1-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Using the textbook and online resources as references, summarize the history of the 8051 family
of microcontrollers. The summary should be at least one page in length and written as a Microsoft
Word document. In your summary, be sure to list all your references.

Using Figure 0-31 in the text, describe the primary function of the following resources: ALU,
program counter, instruction decoder, and registers. Identify the type of bus that is interfaced to
each resource. Record your answers in a Microsoft Word document.

Be sure to include your name and Unit 1 on any submissions.

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. (2009). Microprocessors. New York: Pearson
Custom Publishing.

Notes from Unit 1

Computer with Internet connectivity

Submission Requirements

Submit written answers to all textbook problems making sure to include any formulas and
calculations when applicable.

Submit all other work in a Microsoft Word document.

All parts of this assignment are due at the beginning of Unit 2.

-2-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 2 Assignment 1: 8051 Assembly Language Programming Basics


Course Objectives and Learning Outcomes

Examine practical programming considerations encountered in real applications.

Draw and label block diagrams of microcontrollers showing the arithmetic logic unit (ALU),
internal bus structure, and registers and peripheral function blocks.

Apply common processor instructions in programs to demonstrate how they operate.

Demonstrate the processes of creating, assembling, and programming microcontrollers.

Describe the function of the program counter, data registers, and accumulators.

Define data blocks, variable names, and constants used in the 8051.

Explain a fetch/execute timing sequence for performing a typical instruction.

Compare the different branching and looping instructions.

Explain how execution cycles can be affected by branching conditions.

Program the 8051 using the stack pointer to access a stack data storage area.

Describe the PSW register bits and their usage.

Describe how individual instructions can affect the CY, AC, and P flags on the PSW register.

Describe the concept of subroutines and their advantages.

Explain how the stack is used during execution of subroutines.

Illustrate how RAM memory space is allocated on the 8051.

Compare the functions of Port 0, Port 1, Port 2, and Port 3 on the 8051.

Program the 8051 to access some or all of the 8 bits of a port.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R. Microprocessors.

Chapter 2: Problems 1-3, 6, 7, 11-15, 23, 37, 38, 42, 43, 48

Chapter 3: Problems 4-11,14, 17-20, 23, 33

Chapter 4: Problems 8, 11, 14

Chapter 8: Problems 37-40

Write and document a program to add 3BH and 9CH together using register R2 and accumulator
A. Determine the values of the CY, P, and OV flags in the PSW register after the program is
executed.

Write and document a program to toggle all 8 bits of I/O Port P2 every 300 ms. Assume the
crystal frequency is 11.0592 MHz and that there are 12 clock periods per machine cycle.

-3-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors

Notes from Unit 2

Computer with Internet connectivity

Submission Requirements

Be sure to include your name and Unit 2 on any submissions.

Submit written answers to all textbook problems making sure to include any formulas and
calculations when applicable.

Preferably submit all programs in a Microsoft Word document, although a neatly handwritten
program is acceptable.

All parts of this assignment are due at the beginning of Unit 3.

-4-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 3 Assignment 1: 8051 Assembly Language I/O Programming and Addressing

Course Objectives and Learning Outcomes

Select a processor addressing mode for a given scenario.

Apply common processor instructions in programs to demonstrate how they operate.

Describe the methods and instructions used for bit-level manipulations.

Describe Read-Modify-Write operations.

List the five addressing modes used in the 8051.

Compare the advantages of each of the five addressing modes.

Explain how the five different addressing modes access data.

Program the 8051 to use indirect addressing to access look-up table values.

Explain how addressing modes are used to reduce code size.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R. Microprocessors.

Chapter 4: Problems 16, 17, 27

Chapter 5: Problems 5, 7, 9, 17, 18, 24-29, 35, 37

Write 8051 Assembly programs as they are described in the PROBLEMS section of the text,
Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors.
o

Chapter 4: Problems 20, 24

Chapter 5: Problems 8, 10, 13, 20, 23, 67

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors

Notes from Unit 3

Computer with Internet connectivity

Submission Requirements

Be sure to include your name and Unit 3 on any submissions.

Submit written answers to all non-programming textbook problems making sure to include any
formulas and calculations when applicable.

Submit all programming problems as a Microsoft Word document.

All parts of this assignment are due at the beginning of Unit 4.

-5-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 4 Assignment 1: 8051 Assembly Language Arithmetic and Logic Instructions


Course Objectives and Learning Outcomes

Use numerical methods for processor-based systems to perform calculations and conversions
related to programming.

Apply common processor instructions in programs to demonstrate how they operate.

Write an assembly program to perform arithmetic operations in assembly (ADD, ADDC, DA,
SUBB, MUL, DIV).

Write an assembly program to perform BCD data conversions.

Explain how signed and unsigned math operations differ.

Write an assembly program to perform bit-wise logical operations (AND, OR, XOR, CPL).

Write an assembly program to perform compare operations.

Write an assembly program to perform shift operations.

Calculate the checksum byte for an ASCII message.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R. Microprocessors.
o

Chapter 6: Problems 1, 6, 16, 19, 20, 24, 28, 41, 44, 45

Write 8051 Assembly programs as they are described in the PROBLEMS section of the text,
Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors.
o

Chapter 6: Problems 2, 3, 4, 7-13, 18, 32, 37

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors

Notes from Unit 4

Computer with Internet connectivity

Submission Requirements

Be sure to include your name and Unit 4 on any submissions.

Submit written answers to all non-programming textbook problems making sure to include any
formulas and calculations when applicable.

Preferably submit all programming problems as a Microsoft Word document, although a neatly
handwritten program is acceptable.

All parts of this assignment are due at the beginning of Unit 5.

-6-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

-7-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 5 Assignment 1: 8051 C Programming Basics

Course Objectives and Learning Outcomes

Examine practical programming considerations encountered in real applications.

Describe important implementation differences when using C on PC's vs. microcontrollers.

Describe the RISC and CISC architectures.

Explain how functions and subroutines are utilized for embedded system programming using the
C programming language.

Explain how bits are manipulated using C notations.

Compare C data types used in embedded system programming.

Explain the basics of embedded C memory management.

Program the 8051 to generate a time delay using the C programming language.

Program the 8051 to perform I/O operations using the C programming language.

Program the 8051 to perform BCD data conversions using the C programming language.

Program the 8051 to perform logical and arithmetic operations using the C programming
language.

Program the 8051 to serially shift data using the C programming language.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R. Microprocessors:

Chapter 2: Problems 51-55

Chapter 7: Problems 1-7, 10, 13, 15, 25, 26

Write 8051 C programs as they are described in the PROBLEMS section of the text, Mazidi, M.
A., Mazidi, J., & McKinlay, R. Microprocessors:
o

Chapter 7: Problems 8, 11, 12, 17-20, 27

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors:

Notes from Unit 5

Computer with Internet connectivity

Submission Requirements

Be sure to include your name and Unit 5 on any submissions.

-8-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Submit written answers to all non-programming textbook problems making sure to include any
formulas and calculations when applicable.

Preferably submit all programming problems as a Microsoft Word document, although a neatly
handwritten program is acceptable.

All parts of this assignment are due at the beginning of Unit 6.

-9-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 6 Assignment 1: 8051 Timer Programming Using C


Course Objectives and Learning Outcomes

Describe the Timer operation of the 8051 Timer/Counter.

Describe the Counter operation of the 8051 Timer/Counter.

Explain the purpose of each operating mode used by the TMOD register.

Explain how the TCON register is used.

Program the 8051 to generate time delays using the C programming language.

Program the 8051 as an event counter using the C programming language.

Use numerical methods for processor-based systems to perform calculations and conversions
related to programming.

Examine practical programming considerations encountered in real applications.

Explain how function block features and interrupt usage are used in designing products.

Develop a C program for a microcontroller application.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R. Microprocessors:
o

Chapter 9: Problems 1-15, 20, 21, 25, 26, 43, 44, 45, 46, 50, 51

Write 8051 C programs as they are described in the PROBLEMS section of the text, Mazidi, M.
A., Mazidi, J., & McKinlay, R. Microprocessors:
o

Chapter 9: Problems 53, 54, 57, 58

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors:

Notes from Unit 6

Computer with Internet connectivity

Submission Requirements

Be sure to include your name and Unit 6 on any submissions.

Submit written answers to all non-programming textbook problems making sure to include any
formulas and calculations when applicable.

Preferably submit all programming problems as a Microsoft Word document, although a neatly
handwritten program is acceptable.

All parts of this assignment are due at the beginning of Unit 7.

-10-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 7 Assignment 1: 8051 Serial Communication Programming Using C


Course Objectives and Learning Outcomes

Use numerical methods for processor-based systems to perform calculations and conversions
related to programming.

Examine practical programming considerations encountered in real applications.

Examine fundamental processor I/O interfacing methods.

Explain how function block features and interrupt usage are used in designing products.

Develop a C program for a microcontroller application.

Explain the difference between synchronous and asynchronous serial communications.

Explain how a universal asynchronous receiver-transmitter (UART) is used to asynchronously


communicate with an external computer.

Explain the function of the MAX232 chip.

Explain the function of the 8051 SBUF, SCON, and PCON registers for serial communications.

Calculate the value stored in the THx register for a given baud rate.

Program the 8051 to transmit data from the serial port using the C programming language.

Program the 8051 to receive data from the serial port using the C programming language.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R. Microprocessors:
o

Chapter 10: Problems 1-16, 22, 25, 27, 29-36, 40-43, 45, 46, 52, 53

Write 8051 C programs as they are described in the PROBLEMS section of the text, Mazidi, M.
A., Mazidi, J., & McKinlay, R. Microprocessors:
o

Chapter 10: Problems 62, 63, 64, 65

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors:

Notes from Unit 7

Computer with internet connectivity

Submission Requirements

Be sure to include your name and Unit 7 on any submissions.

Submit written answers to all non-programming textbook problems making sure to include any
formulas and calculations when applicable.

-11-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Preferably submit all programming problems as a Microsoft Word document, although a neatly
handwritten program is acceptable.

All parts of this assignment are due at the beginning of Unit 8.

Unit 8 Assignment 1: 8051 Interrupt Programming Using C


Course Objectives and Learning Outcomes

Use numerical methods for processor-based systems to perform calculations and conversions
related to programming.

Examine practical programming considerations encountered in real applications.

Examine fundamental processor I/O interfacing methods.

Explain how function block features and interrupt usage are used in designing products.

Develop a C program for a microcontroller application.

Explain the difference between interrupts and polling.

List all the different interrupts in the 8051.

Explain the steps involved in executing an interrupt.

Configure the IE register to enable a specific interrupt.

Explain how the TCON register is used in interrupt programming.

Configure the IP register to set the priority of specific interrupts.

Define Interrupt Vector Table and Interrupt Service Routine.

Describe how interrupts and interrupt vectors compare to subroutines.

Compare polled I/O versus interrupt-driven I/O techniques.

Program the 8051 to perform Timer operations with interrupts using the C programming
language.

Program the 8051 to perform external hardware interrupts using the C programming language.

Program the 8051 to perform serial communications with interrupts using the C programming
language.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R. Microprocessors:
o

Chapter 11: Problems 1, 2, 4, 17, 18, 21, 22, 29, 30, 33-38, 45, 46, 49, 50, 57, 60, 66, 67

Write 8051 C programs as they are described in the PROBLEMS section of the text, Mazidi, M.
A., Mazidi, J., & McKinlay, R. Microprocessors:
o

Chapter 11: Problems 32, 47, 62

-12-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors

Notes from Unit 8

Computer with Internet connectivity

Submission Requirements

Be sure to include your name and Unit 8 on any submissions.

Submit written answers to all nonprogramming textbook problems, making sure to include any
formulas and calculations when applicable.

Preferably submit all programming problems as a Microsoft Word document, although a neatly
handwritten program is acceptable.

All parts of this assignment are due at the beginning of Unit 9.

-13-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 9 Assignment 1: 8051 LCD and Keypad Interfacing


Course Objectives and Learning Outcomes

Examine practical programming considerations encountered in real applications.

Examine fundamental processor I/O interfacing methods.

Develop a C program for a microcontroller application.

Explain how commands and data are passed between the 8051 and LCD.

Describe the functions of the RS, R/W, and E pins on the LCD.

Interface an LCD display to the 8051.

Program the 8051 to perform I/O operations using the C programming language.

Control an LCD with the 8051 using the C programming language.

Describe how to interface a keyboard to the 8051.

Explain reasons for and methods of software input signal debouncing.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R. Microprocessors:
o

Chapter 12: Problems 2-11, 13, 15, 17, 21-28

Write an 8051 C program to send the string Hello to the LCD by checking the busy flag.

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors

Notes from Unit 9

Computer with Internet connectivity

Submission Requirements

Be sure to include your name and Unit 9 on any submissions.

Submit written answers to all nonprogramming textbook problems, making sure to include any
formulas and calculations when applicable.

Preferably submit all programming problems as a Microsoft Word document, although a neatly
handwritten program is acceptable.

All parts of this assignment are due at the beginning of Unit 10.

-14-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 10 Assignment 1: 8051 ADC and DAC Interfacing


Course Objectives and Learning Outcomes

Examine practical programming considerations encountered in real applications.

Examine fundamental processor I/O interfacing methods.

Develop a C program for a microcontroller application.

Describe the functions of the CS, RD, WR, CLK, INTR, Vin, Vcc, and Vref/2 pins of an ADC chip.

Interface an ADC to the 8051.

Control an ADC with the 8051 using the C programming language.

Interface a DAC to the 8051.

Explain how to interface sensors to the 8051.

Assignment Requirements

Complete the following questions from the PROBLEMS section of the text, Mazidi, M. A., Mazidi,
J., & McKinlay, R. Microprocessors:
o

Chapter 13: Problems 1, 2, 6, 11, 13, 14, 18, 28, 37, 39, 47, 48, 52, 53, 54, 58, 59

Required Resources

Textbook: Mazidi, M. A., Mazidi, J., & McKinlay, R. Microprocessors

Notes from Unit 10

Computer with Internet connectivity

Submission Requirements

Be sure to include your name and Unit 10 on any submissions.

Submit written answers to all problems, making sure to include any formulas and calculations
when applicable.

All parts of this assignment are due at the beginning of Unit 11.

-15-

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Project
Unit 3 Project Part 1: Introduction and Research Assignment
Purpose
This is the first assignment for the Project where you will compile a list of potential project ideas. You must
be prepared to discuss the project ideas at the next class meeting.
Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Plan, design, implement, and debug at least one functional microcontroller student project.

Demonstrate how to break down embedded projects into separable software tasks and hardware
functions.

Identify advantages processors have over custom fixed-gate implementations.

Distinguish the major differences between microprocessors and microcontrollers.

Required Resources

Computer lab with Internet connectivity and word processing software

Project Logistics
The Project will continue until the end of the course and will consist of the following requirements:

Develop an original design concept based on a practical embedded system application.

Write a proposal of your design concept that describes the design features and specifies the
project deliverables.

Develop the processor software and construct a prototype hardware circuit.

Demonstrate the performance of your design.

Generate a written report and power point presentation.

The first deliverable is the Research Assignment where you must research embedded system
applications and come up with a list of at least ten potential project ideas. Keep in mind that you only have
until Unit 10 to complete your project. The embedded system design must be implemented with the 8051
microcontroller.
Suggested references for this assignment include:

ITT Tech Virtual Library

http://www.8051projects.info/projects.asp

http://www.hobbyprojects.com/microcontroller_tutorials.html

16

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Deliverables
The Research Assignment must be submitted as a Microsoft Word document at the beginning of Unit 4.
The project ideas will need to be approved by the instructor before you can begin work on the Project
Proposal.
Project deliverables for future units are as follows:

Project Proposal due at beginning of Unit 5

Design Plan due at end of Unit 6

Progress Report due at beginning of Units 7, 8, 9

Final Written Report due at end of Unit 10

Presentations given during Unit 11

17

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 4 Project Part 2: Project Proposal


Purpose
This is the second assignment for the Project where your entire group will write a proposal that provides
an overview of the application and design of the Project idea that was selected from the Project Research
Assignment.
Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Plan, design, implement, and debug at least one functional microcontroller student project.

Identify advantages processors have over custom fixed-gate implementations.

Distinguish the major differences between microprocessors and microcontrollers.

Required Resources

Computer lab with Internet connectivity and word processing software

Project Logistics
The Project Proposal must include the following:

The names of each group member and their assigned roles within the groupone member of the
group is appointed as group leader

An overview of the embedded system application

A rough block diagram/sketch of the projects major elements

A brief description of your proposed design methodology, including items such as:

Which programming language you will use

Using the 8051 Simulator to test separate segments of the code

Using Multisim to test hardware functionality

A timeline showing the major deliverables and any intermediate goals for the next 6 units.

You and your group must be prepared to discuss your proposal with the class at the next class meeting.
Deliverables
The Project Proposal must be at least two pages in length and submitted as a Microsoft Word document
at the beginning of Unit 5. Only one proposal per group is required. The Project Proposal will need to be
approved by the instructor before you can begin work on the Design Plan.

18

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 5 Project Part 3: Design Plan


Purpose
This is the third assignment for the Project where your entire group will write a description of your initial
design plan. This assignment is intended to help you get started with your projects design phase.
Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Examine practical programming considerations encountered in real applications.

Demonstrate how to break down embedded projects into separable software tasks and hardware
functions.

Plan, design, implement, and debug at least one functional microcontroller student project.

Identify advantages processors have over custom fixed-gate implementations.

Distinguish the major differences between microprocessors and microcontrollers.

Required Resources

Computer lab with Internet connectivity and word processing software

Project Logistics
Your Design Plan must include the following:

The title of your project and the names of each group member

A block diagram/sketch displaying the major elements of the proposed embedded systemthis is
an extended version of the block diagram submitted in your proposal

A basic list of components you will need to implement the proposed embedded systemthis list
need not be detailed at this point (i.e., part numbers and vendor names are not required)

The programming language used for programming the microcontrollerexplain the reason for
your decision

A design methodology describing your initial thoughts on how you will proceed with the design, for
example:

Describe what area you will research next

Describe the inputs and outputs expected by your code

Describe the functionality requirements of your code

A test plan describing how you will test your system along with a description of the expected
results

As you work on this assignment, keep in mind that this is an initial design of your proposed embedded
system. Expect to make ongoing modifications to your design over the next several units.

19

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

You and your group must be prepared to discuss your design plan with the class at the next class
meeting.
Deliverables
The Design Plan must be submitted as a Microsoft Word document at the end of Unit 6. Only one design
plan per group is required.

20

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 6 Project Part 4: Progress Report I


Purpose
This is the fourth assignment for the Project where your group will give an informal presentation to the
entire class on the current status of your embedded system design. It is intended to provide feedback that
will aid in your design efforts and keep your project on schedule. It will be conducted similar to the way a
status meeting is conducted in industry.
Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Plan, design, implement, and debug at least one functional microcontroller student project.

Identify advantages processors have over custom fixed-gate implementations.

Distinguish the major differences between microprocessors and microcontrollers.

Required Resources

Computer lab with Internet connectivity and word processing software

Project Logistics
Each group will present an informal progress report of their embedded design to the class. The progress
report must include:

An updated block diagram/sketch displaying a more detailed layout of the embedded system
(make copies for the entire class)

A progress update on the component list

A progress update on the software program

A progress update on the hardware circuit

A progress update on the test plan

Deliverables
The Progress Report is an informal presentation given during Unit 7. Each group member must
participate in the presentation in order to receive credit for this assignment. The Progress Report
assignment is graded as either satisfactory (100) or unsatisfactory (0).

21

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 7 Project Part 5: Progress Report II


Purpose
This is the fifth assignment for the Project where your group will give an informal presentation to the entire
class on the current status of your embedded system design. It is intended to provide feedback that will
aid in your design efforts and keep your project on schedule. It will be conducted similar to the way a
status meeting is conducted in industry.
Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Plan, design, implement, and debug at least one functional microcontroller student project.

Identify advantages processors have over custom fixed-gate implementations.

Distinguish the major differences between microprocessors and microcontrollers.

Required Resources

Computer lab with Internet connectivity and word processing software

Project Logistics
Each group will present an informal progress report of their embedded design to the class. The progress
report must include:

An updated block diagram/sketch displaying a more detailed layout of the embedded system
(make copies for the entire class)

A progress update on the component list

A progress update on the software program

A progress update on the hardware circuit

A progress update on the test plan

Deliverables
The Progress Report is an informal presentation given during Unit 8. Each group member must
participate in the presentation in order to receive credit for this assignment. The Progress Report
assignment is graded as either satisfactory (100) or unsatisfactory (0).

22

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 8 Project Part 6: Progress Report III


Purpose
This is the sixth assignment for the Project, in which your group will give an informal presentation to the
entire class on the current status of your embedded system design. It is intended to provide feedback that
will aid in your design efforts and keep your project on schedule. It will be conducted similarly to how a
status meeting is conducted in industry.
Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Plan, design, implement, and debug at least one functional microcontroller student project.

Identify advantages processors have over custom fixed-gate implementations.

Distinguish the major differences between microprocessors and microcontrollers.

Required Resources

Computer lab with Internet connectivity and word processing software

Project Logistics
Each group will present an informal progress report of their embedded design to the class. The progress
report must include the following:

An updated block diagram/sketch displaying a more detailed layout of the embedded system
(make copies for the entire class)

A progress update on the component list

A progress update on the software program

A progress update on the hardware circuit

A progress update on the test plan

Any troubles identified and workarounds

Deliverables
The Progress Report is an informal presentation you will give during Unit 9. Each group member must
participate in the presentation to receive credit for this assignment. The Progress Report assignment will
be graded as either satisfactory (100) or unsatisfactory (0).

23

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 9 Project Part 7: Final Report (PORTFOLIO)


Purpose
This is the seventh assignment for the Project, in which your group will submit a final report of your
embedded system design project.
Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Plan, design, implement, and debug at least one functional microcontroller student project.

Identify advantages processors have over custom fixed-gate implementations.

Distinguish the major differences between microprocessors and microcontrollers.

Required Resources

Computer lab with Internet connectivity and word processing software

Project Logistics
Each group will submit one final report that contains the following:

Design plan

Component list

Software program

Hardware circuit diagram

Test plan

Results

Conclusion

Deliverables
You should write your Final Report in the form of a Word document that includes a title page, table of
contents, and list of references. The Final Report assignment is worth 40% of the total project grade. The
assignment is due at the end of Unit 10.

24

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 10 Project Part 8: Final Presentations


Purpose
This is the last assignment for the Project, in which your group will give a formal PowerPoint presentation
of your embedded system design. After the presentation, your group will demonstrate your embedded
system design in the lab.
Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Examine practical programming considerations encountered in real applications.

Demonstrate how to break down embedded projects into separable software tasks and hardware
functions.

Plan, design, implement, and debug at least one functional microcontroller student project.

Identify advantages processors have over custom fixed-gate implementations.

Distinguish the major differences between microprocessors and microcontrollers.

Required Resources

Lab computers with Keil software for 8051 and either Brays or Tera Terminal

8051 Trainer

Power adapter for 8051 Trainer

USB adapter

Project Logistics
Your group will give a formal PowerPoint presentation of your embedded system design that includes the
following:

Design purpose

Design plan details

Software program explanation

Hardware circuit diagram

Test plan

Results

Deliverables
Groups will give their presentations and demonstrations at the conclusion of the final exam during Unit 11.
Each group member must participate to receive credit for this assignment.

25

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Laboratory Assignments
Unit 1 Lab 1: Assembling Programs and Using the Simulator (Part 1)
Course Objectives and Learning Outcomes

Use simulation and debugging techniques to verify that software is operational.

Use development tools to assemble and download code into a microcontroller.

Debug an assembler program using a simulator.

Examine a listing file to determine the mapping of memory locations to code and data segments.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Introduction
To program any microcontroller, you need to master software tools such as an assembler and a compiler.
The assembler/compiler provides a way to test a given program for syntax errors. The syntax errors are
listed in a file with an .lst extension. Once you examine the .lst file and locate the error, you can go back
to the source file, correct the errors, and reassemble it. This process continues until all the errors in the
.lst file are eliminated. Note that even if you receive zero errors in the .lst file, it does not mean that your
program will work properly.
To see if the program does what you intended, you will need to use a simulator. When simulating the
program, you execute it line by line and examine the registers, ports, and memory contents to verify the
operation of code. This lab introduces the process of assembling and simulating a program.
You will learn to use an 8051 assembler/simulator and complete activities to write, make, debug, and
execute programs. This assembler tool will be used throughout the course and in all lab activities.
Therefore, it is essential for you to master all aspects of this assembler tool for future lab activities.
Note: If you are not able to complete this lab by the end of class, you will need to complete the lab on
your own time prior to the start of Unit 2.

26

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Recommended Procedures
Activity 1: Use the Keil uVision 4.22 Integrated Development Environment.

Note: The Keil uVision 4.22 IDE

link should be on the desktop, if not it can be located at

C:\Keil\UV4\Uv4.exe.
1. Follow the directions in the Basic Tutorial for Keil Software handout (ET2640.U1.HO1) to
accomplish the following activities that you will use to complete all of the labs for this course.
a. Locate and open the Keil uVision IDE.
b. Create and save a new source code file.
c.

Configure the IDE to use with the 8051 trainer using the DS89C420 processor.

d. Write code in a source file that will toggle data between Port 1 & Port 2 (as explained in
Keil tutorial).
e. Import the source file into the project.
f.

Compile the source file turning it into a HEX file that can be executed by the simulator
and/or downloaded to the microprocessor and executed.

g. Use the debugger to simulate and test the program.


2. After completing the tutorial, examine the files created by program.
Activity 2: Write and Assemble a Program to Move the Values Between Registers.
You will write and assemble a program to move the value 99H to register A. Then move the value to all
registers R0 through R7 and PORT0, PORT1, and PORT2.
1. Create a new project and configure it to be used with the DS89C420 processor.
2. Create a source code file, enter the program below, and save it.
ORG

0000H

MOV

AL,#99H

MOV

R0,A

MOV

R1,A

MOV

R2,A

MOV

R3,A

MOV

R4,A

MOV

R5,A

MOV

R6,A

MOV

R7,A

MOV

P0,A

MOV

P1,A

27

04/19/2012

Microprocessors and Microcontrollers

MOV

GRADED ASSIGNMENTS

P2,A

END
3. Import the source file, compile it to HEX and execute the debugger.
4. Locate the Build Output window to see if it indicates an error. See Figure 1-1.

Figure 1-1
5. Correct the error in line 2. (AL is not a valid register. It should be A)
a.
b.

Save the changes and rebuild the project.


You will need to replace the existing source file with the corrected version of the source
file.

6. Again, execute the debugger.


7. Select the Peripherals and open Ports 1, 2 & 3.
8. Use the simulator to single-step (F11) through the program and examine the registers and ports.
9. As you step through the program, the number 99H should appear in the specified register or port after the
appropriate step is made.
Activity 3: Write, Assemble, and Simulate a Program
1. Write, assemble, and simulate a program with following parts:
a. Clear register A by moving the value 0 (zero) into it.
b. Move each digit of your birth date into registers R0 through R7. If you do not want to use your
birth date, use the example provided or todays date (for example: 11-21-2012).
c.

Add the registers R0-R7 to register A.


ORG

0000H

MOV

A,#0

MOV

R0,#0 ; 01 for January

MOV

R1,#1

MOV

P0,R0

MOV

P1,R1

MOV

R2,#1 ; 15th

MOV

R3,#5

MOV

P1,R2

MOV

P2,R3

28

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

MOV

R4,#1 ; 1929

MOV

R5,#9

MOV

R6,#2

MOV

R7,#9 ; is Martin Luther Kings birth date

MOV

P0,R4

MOV

P1,R5

MOV

P2,R6

MOV

P3,R7

ADD

A,R0

ADD

A,R1

ADD

A,R2

ADD

A,R3

ADD

A,R4

ADD

A,R5

ADD

A,R6

ADD

A,R7

MOV

P0,A ;this will be the sum of the registers

END
2. Start the simulator and open the Ports 0, 1, 2 & 3 windows.
3. Use the simulator to single-step through the program and examine the registers. You should see the
dates entered into the registers and then the sum of the numbers in the accumulator.
Note: If the sum is more than FFH, as limited by 8 bits, the number will roll over from 00H.
4. Terminate the program.
5. Start Debug again.
6. Select View and open the Register window.
7. View registers as you single-step through the program and examine how the registers update with
relationship to the program.

29

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Activity 4: Examine a .lst File (list file)


1. Examine the .lst file (list file) for the previous activity by right clicking on the source file in the Project
window.
2. The screen should appear similar to Figure 1-2.

Figure 1-2

30

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

3. The list file should appear as follows.

Figure 1-3
4. Notice the headings LOC, OBJ, LINE, and SOURCE. Note that LOC and OBJ values are presented in
hexadecimal (base 16).
5. Carefully examine the OBJ column and relate it to the SOURCE column.
6. 7400H is the op-code to move a value to the accumulator. Use Appendix A in the textbook to identify
some of the other op-codes.
Activity 5: Create, Make, and Execute a Program
1. Create, make, and execute one or both of the following programs:
a. Make the ACC register read 0FH, R0 read FFH, R1 read ABH, and P1 read DAH.
b. Write a program that stores 10H in R0 and another value in R1. The program should add
those two numbers together and store the result in Port 3. Port 3 must read AAH. Calculate a
value for R1 that, when added to the contents of R0, will result in P3 reading AAH.

31

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Deliverables

Completed Unit 1 Lab 1 Worksheet (ET2640.U1.HO2)

Due by the end of class

32

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 1 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Demonstrate the processes of creating, assembling, and programming microcontrollers.

Use simulation and debugging techniques to verify that software is operational.

Use development tools to assemble and download code into a microcontroller.

Debug an assembler program using a simulator.

Examine a listing file to determine the mapping of memory locations to code and data segments.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective Explain the purpose of the lab.

Setup Provide a complete list of all required equipment and materials.

Explanation of experimental procedure Provide a detailed summary of how you performed the
lab.

Conclusions Provide an analysis of what you learned from the lab.

Deliverables

Completed Unit 1 Lab 1 Report

Typed up with a word processor

Due at the beginning of Unit 2

33

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 2 Lab 1: 8051 Registers, Stack, Ports, Trainer, and Program Download (Part
1)
Course Objectives and Learning Outcomes

Apply common processor instructions in programs to demonstrate how they operate.

Demonstrate the processes of creating, assembling, and programming microcontrollers.

Use simulation and debugging techniques to verify that software is operational.

Use development tools to assemble and download code into a microcontroller.

Debug an assembler program using a simulator.

Examine a listing file to determine the mapping of memory locations to code and data segments.

Describe the function of the program counter, data registers, and accumulators.

Identify the opcodes and operands in a list file.

Program the 8051 using the stack pointer to access a stack data storage area.

Describe the PSW register bits and their usage.

Describe how individual instructions can affect the CY, AC, and P flags on the PSW register.

Program the 8051 to access some or all of the 8 bits of a port.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Bray Terminal or TeraTerm Terminal

MDE 8051 Trainer

Introduction
While assemblers/compilers allow you to assemble a given program, you must run the program on an
actual microcontroller to test its operation. The assembler creates an executable file with the .hex
extension. This hex file must be downloaded into a microcontroller. In older systems, the microcontroller
had to first be taken out of the system board and placed into an eraser to erase its contents. After the
contents were erased, a PROM burner was used to burn the hex file into the chip.
With the advent of Flash memory in recent years, microcontrollers are equipped with a loader that
enables a program to be downloaded into the chip without removing it from the system board. The
DS89C450 chip used in the 8051 Trainer has a built-in serial boot-loader that allows the hex file to be
downloaded into the chip with the use of an x86 PC serial port. Windows HyperTerminal software is used
to access the chips contents via the serial port of the x86 PC. The HyperTerminal enables you to both
delete and program the chips contents.

34

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

This lab shows the process of accessing the Flash contents of the 8051 Trainer chip, deleting the old
contents, and downloading a new hex file into it. You will use a simple program such as toggling bits to
verify the operation of the 8051 Trainer. This will ensure the port is operating properly before you connect
the port to devices such as an LCD or a stepper motor.
Note: Before connecting a microcontroller to any device, first run a toggle program to make sure the CPU
and ports are working properly.
Recommended Procedures
Activity 1: Examine the Program Counter, Accumulator and the Program Status Word (PSW)
1. Open the Keil IDE and create a new project. Write and assemble the following program. The program
will add three pairs of numbers. At each operation, the PC will increment and the PSW will update
based on the contents of accumulator A and the changes to it:
o

PSW.CY bit is high when there is a carry from accumulator A bit 7.

PSW.AC bit is high when there is a carry from ACC bit 3 to ABB bit 4.

PSW.P bit is high when ACC has an odd number of ones.

ORG
MOV
ADD
MOV
ADD
MOV
ADD
NOP

0000H
A, #38H
A, #2FH
;A=67H, CY=0, AC=1,
A, #9CH
A, #64H
;A=00H, CY=1, AC=1,
A, #88H
A, #93H
;A=1bH, CY=1, AC=0,
;No operation- helps with

P=1
P=0
P=0
debugging

2. Use the simulator to single-step and examine the registers, paying close attention to the PSW
registers.
a. Start a Debug session and make sure the Registers window is open.
i. View > Registers Window.

35

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Locate the PSW near the bottom of the list, expand


the psw tree. It should appear as follows.

The LSB is at the top, MSB is on the bottom.

Initially, the PSW should read 0 because the


accumulator (Sys.a) is 0.

Note: Register A is the accumulator and is identified as the Sys.a register in the Keil IDE. From this point
forward the accumulator labelled as Sys.a will be identified by ACC. Also, the program counter is
identified as PC $ and will be identified as the PC.
3. The PSW should update as the value in the ACC register) change. Use Figure 2-4 on page 52 of the
text for reference.
4. Also the PC should increment as every program step is executed.
5. Step past the first MOV instruction: MOV A, #38H so the step pointer is pointing to the next
instruction: ADD A, #2FH

;A=67H, CY=0, AC=1, P=1.

6. The previous instruction moved 38h into the ACC. In binary, 38h is: 0011 1000.
7. The PSW register should display 0x01 because the parity bit or PSW.1 is set high due to the odd
number of 1s in the ACC.
8. Step through the program while carefully examining and comparing the ACC and the PSW registers.
Also, notice the PC increments at each step.
9. Repeat this activity until you understand the relationship between the contents of the ACC and PSW.
Activity 2: Examine memory, the program counter (PC), the stack pointer (SP) and stack operations
1. Create a working project by following these steps.

36

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

a.

Create New Project

b.

Select Processor Dallas DS89C450 (do not copy startup code)

c.

Create New Source Code File (name as .a51, .src or .c)

d.

Write Source Code

e.

Add File to Source Group

f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g.

Build All Target Files

h.

Start Debug

2. The correct code follows:

ORG 0000H
MOV R0, #18H
MOV R1, #12H
MOV R2, #99H
MOV R3, #10H
MOV R4, #0FFH
MOV R5, #0FFH
MOV R6, #0FFH
MOV R7, #0FFH
PUSH 3
PUSH 1
PUSH 0
PUSH 2
POP 4 ; top of
POP 5 ; top of
POP 6 ; top of
POP 7 ; top of
NOP

;SP=07
; R3 to
; R1 to
; R0 to
; R2 to
stack to R4stack to R5stack to R6stack to R7-

Stack- SP=08
Stack- SP=09
Stack- SP=0A
Stack- SP=0B
SP=0A
SP=09
SP=08
SP=07

3. Build and start the debugger and open the Register window.

37

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

4. Open the Memory 1 and Memory 2 Windows.

5. The Memory Windows should be located at the bottom of the screen.

6. Close the Command Window.

38

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

7. Enter C: 00h in the Address box to display the CPU program memory space. Expand the Memory 1
window to display a few lines of program memory.

8. Locate the Disassembly Window. Notice C: 0x0000 7818 MOV

R0, #0x17.

9. Notice the Disassembly Window displays the op-code 7818 located a memory location 0000h. Op-code
78 means move data to register R0, 18 is the value of the data.
10. Notice that the first line in Memory 1 Window begins with the following:

11. The program source code starts with instruction ORG 0000H which starts the program at memory location
0000H, hence the first instruction, 7818, is stored in that memory location. The instructions are stored
serially starting at address 0000H,
o

78 18 is the first instruction and moves 18h into R0, MOV R0, #18h

79 12 is the next instruction and moves 12h into R1, MOV R1, #12h

7A 99 moves 99h into R2, MOV R2, #99h

7B 10 moves 10h into R3, MOV R3, #10h

39

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

7C FF moves FFh into R4, MOV R4, #0FFh

7D FF moves FFh into R5, MOV R5, #0FFh

7E FF moves FFh into R6, MOV R6, #0FFh

7F FF moves FFh into R7, MOV R7, #0FFh

12. The next instruction that follows the instruction that moves data into register 7 is pushing the contents of
register 3 onto the stack.
o

C0 03 pushes the contents of register 3 onto the stack, PUSH 3

C0 01 pushes the contents of register 1 onto the stack, PUSH 1

C0 00 pushes the contents of register 0 onto the stack, PUSH 0

C0 02 pushes the contents of register 2 onto the stack, PUSH 2

13. The next instruction that follows the instruction that pushes register 2 onto the stack is popping the top of
the stack into register 4.
o

D0 04 pops the top of the stack into register 4, POP 4

D0 05 pops the top of the stack into register 5, POP 5

D0 06 pops the top of the stack into register 6, POP 6

D0 07 pops the top of the stack into register 7, POP 7

14. Start Debug and notice that the PC is initially C: 0x0000h which is the address of the first instruction to be
executed. Locate memory location 0000h, it is op-code 78, location 0001h is the data 18.
15. Press F11 to single step and execute the first instruction. Notice that 18h is moved into R0 and the PC
updates to 0x0002h which is the memory location of the next instruction.
16. Single step through the program, notice that the PC will always point to the memory location that holds
the next op-code.
17. Select Memory Window 2 and enter D: 00h in the Address box to display the CPU data memory space.

18. Notice that the first line in Memory 2 Window begins with the following:

40

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

19. Sixteen memory locations are displayed. The first location is data memory address 0000h and is register
0. Registers 1 through 7 follow at memory addresses 0001h through 0007h. The 9th location is data
memory address 0008h and is the top of the stack. Data memory 0008-001Fh is the stack.
20. Step through the program while carefully examining the values of R0 through R7, SP, 00, and 08.
21. This program initially loads four values into registers. The values are placed on the stack in a random
order.
22. Then the stack is emptied and the values are placed in a different set of registers.
23. SP increments when data is pushed onto the stack and decrements when data is pulled from the stack.
24. Notice the order of the values is different.
25. Repeat the program until you understand how the memory is used.
Activity 3: Examine the trainer and its features
1. Examine the Trainer Figure carefully. You should observe the following features:

The 8051 Trainer

POWER LED5on the left and PRG LED6 program mode on the right

PRG / RUN switch to select run or program mode

RESET button

Bank of eight DIP switches

Bank of eight LEDs

5VDC jack

Two 9-pin DIN ports labeled Serial 0 and Serial 1

41

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Two 20-pin male/female combination of connectors labeled from left to right: J1, J3, J4,
J2

Two 8-pin male/female combinations of connectors, one set connected to the DIP
switches and the other to the LEDs

Two 2-pin jumpers labeled S1-RXD and S2-TXD (These are for serial communication and
will be covered later.)

Maxim DS89C450 microprocessor, 74HC244 tri-state buffer (to drive the LEDs), and
MAX232 serial interface along with an 11-MHz crystal and various components

2. Examine the left-side 20-pin male/female combination of connectors J1 and J3. They are labeled P1.0
through P1.7 and P3.0 through P3.7. These are connected to the microprocessor ports 1 and 3,
respectively. Notice that Port 3 has additional labels such as RXD and TXD. These are for serial
communication signals and will be covered later.
3. Examine the right-side 20-pin male/female combination of connectors J4 and J2. They are labeled P0.0
through P0.7 and P2.0 through P2.7. These are connected to the microprocessor ports 0 and 2,
respectively. Notice that these ports also have additional labels such as AD0 and A15. Port 0 acts as
both an 8-bit address bus and an 8-bit data bus. Port 2 can also function as the MSB of a 2-byte
external address bus. These will be covered in more detail later.
4. Examine the 8-pin male/female combination labeled J6 LED CONNECTORS. Pin 1 is connected to LED
1, pin 2 to LED 2, and so on. Applying VCC on any pin of J6 will illuminate the related LED. These
pins will be connected to the ports to view the output of the microprocessor and to verify the program
operation.
5. Examine the 8-pin male/female combination labeled J5 DIP SWITCH CON. Pin 1 is connected to switch
1, pin 2 to switch 2, and so on. Each pin has either GND or VCC available, depending on the switch
setting. These pins will be connected to the ports to provide input to the microprocessor to verify your
program operation.
6. The PRG / RUN switch transfers the Trainer from program to run mode. Leave the Trainer in RUN mode
by default.
7. The reset button resets the Trainer.
8. The 9-pin din connector labeled SERIAL 0 will be connected to the PC. The other serial port will be
discussed later.
9. At this point, you should be ready to establish a connection between the PC and the Trainer.
Activity 4: You will learn to interface the Trainer to the x86 PC and establish a terminal connection.
1. Attach or verify that the interface (RS232 cable or USB-to-RS232 cable) is connected at J10- SERIAL
0 and the correct port on the PC. Your instructor will verify the connection.
2. NOTE: Some PC systems will not have a COM port and will use a USB-to- RS232 cable.

42

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

3. Make sure the PRG / RUN switch is in the RUN position.


4. Using the supplied transformer, apply power to the Trainer. Make sure the POWER LED illuminates.
5. Complete the Trainer tutorial How to Test, Download, and Run a Program on the MDE8051 Trainer
Board using the Bray terminal.
Or
6. Complete the Trainer tutorial How to Test, Download, and Run a Program on the MDE8051 Trainer
Board using the TeraTerm terminal.
After completing this activity, you should be able to download and execute programs.
Activity 5: Test the operation of the ports of your 8051 Trainer as follows:
1. Ensure the Trainer is interfaced correctly to the PC.
2. Prepare the Trainer by connecting eight wires from Port 0 to the LED bank as follows:
J4

J8

P0.0

to

-1

P0.1

to

-2

through
P0.7

to

-8

3. Create the test program by following these steps:

Create New Project

Select Processor Dallas DS89C450 (do not copy startup code)

Create New Source Code File (name as .a51, .src or .c)

Write Source Code

Add File to Source Group

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

Build All Target Files

Start Debug and verify that the program. Locate the port memory locations.

4. The code follows:

ORG
0000H
MAIN: MOV P0, #55H
MOV
P1, #66H
MOV
P2, #33H
ACALL DELAY
MOV
P0, #0AAH
MOV
P1, #099H
MOV
P2, #0CCH
ACALL DELAY
SJMP
MAIN
;-----------------------------DELAY:

43

04/19/2012

Microprocessors and Microcontrollers

MOV
LOOP3:
LOOP2:
LOOP1:
NOP
NOP
DJNZ
DJNZ
DJNZ
RET
END

R5, #250
MOV R4, #29
MOV R3, #100
NOP

GRADED ASSIGNMENTS

;Maximum value for R5 is 255


;Change to 44, 88, 176
;NOTE THESE NUMBERS ARE DECIMAL (NO H)

R3, LOOP1
R4, LOOP2
R5, LOOP3
MAIN

5. Establish a connection to the Trainer and download the hex file to the Trainer.
6. Move the slide switch to the RUN position and press the RESET button to run the test program.
7. The program is alternately updating Port 0s even and odd bits. LED bits 0, 2, 4, 6 should be
alternately flashing with bits 1, 3, 5, 7.
8. Examine the program closely. You can see that Ports 0, 1, and 2 are alternately loaded with 55H and
AAH. Reviewing the binary values of each should help you understand what is happening on the
Trainer.
9. The Trainer LEDs are demonstrating what is happening at Port 0. Port 1 and 2 have different
patterns. You can rewire the LED bank to those ports. Power the Trainer off, move the wires, re-apply
power, and press reset.
10. Examine the program closely. You can see three nested loops at LOOP3, LOOP2, and LOOP1.

LOOP1 will repeat the six instructions from LOOP1: To the RET until R3 is decremented
down to 0, which are 100 repetitions.

LOOP2 will repeat LOOP1 until R4 is decremented down to 0, which is 29 times, for a total of
29 times 100, or 2900 total repetitions.

LOOP3 will repeat LOOP2 until R5 is decremented down to 0, which is 250 times, for a total
of 250 times 29 times 100, or 735000 total repetitions.

You can figure out the time it takes for the ports to update by understanding the length of a
clock cycle and the number of cycles within the loop. Multiply that value by the total
repetitions to obtain the frequency of the port update.

11. Change the value of R3 on the line of code at LOOP3. Save and remake the changes. Download to
the Trainer. You may need to power cycle the Trainer first. Run the new program. What changed?
12. Can you determine what value of R3 would yield a frequency of 1 Hz? Try it and see if you can obtain
1 Hz flashing at the LEDs.
Deliverables

Complete the Unit 2 Lab 1 Worksheet (ET2640.U2.HO3)

Due at the end of class

44

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 2 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Apply common processor instructions in programs to demonstrate how they operate.

Demonstrate the processes of creating, assembling, and programming microcontrollers.

Use simulation and debugging techniques to verify that software is operational.

Use development tools to assemble and download code into a microcontroller.

Debug an assembler program using a simulator.

Program the 8051 using the stack pointer to access a stack data storage area.

Program the 8051 to access some or all of the 8 bits of a port.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective Explain the purpose of the lab.

Setup Provide a complete list of all required equipment and materials.

Explanation of experimental procedure Provide a detailed summary of how you performed the
lab.

Conclusions Provide an analysis of what you learned from the lab.

Deliverables

Complete the Unit 2 Lab 1 Report

Typed up with a word processor

Due at the beginning of Unit 3

45

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 3 Lab 1: Performing I/O Operations on 8051 Ports and Transferring Data in
Memory (Part 1)
Course Objectives and Learning Outcomes

Demonstrate the processes of creating, assembling, and programming microcontrollers.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Plan, design, implement, and debug at least one functional microcontroller student project.

Use development tools to assemble and download code into a microcontroller.

Debug an assembler program using a simulator.

Program the 8051 to use indirect addressing to access look-up table values.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Bray Terminal or TeraTerm Terminal

MDE 8051 Trainer

Oscilloscope

Logic probe

Introduction
The simplest test of operation for a given microcontroller is performed by accessing its I/O (input/output)
ports. In Lab 2, you tested the operation of the Output port by toggling the bits. In this lab, you will test the
operation of the Input port by connecting the port to DIP switches and writing a program to bring the
status of the switched into the CPU. This will ensure the Input port is operating properly before you
connect the port to devices such as a keypad or ADC. More importantly, you will test the software
algorithm for BCD-to-ASCII and binary-to-ASCII programs, which are widely used in data acquisition
engineering, using a DIP switch as an input.
Recommended Procedures
Activity 1: Simulate I/O port operations and trace subroutine CALL program operations
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

46

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

ORG 0000H
MAIN:
MOV
P0, #55H
MOV P1, #55H
MOV P2, #55H
ACALL DELAY
MOV P0, #0AAH
MOV P1, #0AAH
MOV P2, #0AAH
ACALL DELAY
SJMP MAIN
DELAY:
MOV
R3, #3
LOOP1:
NOP
DJNZ R3, LOOP1
RET
END MAIN

;
;
;
;
;
;
;
;
;

toggles 55 to Port
toggles 55 to Port
toggles 55 to Port
jumps to DELAY
toggles AA to Port
toggles AA to Port
toggles AA to Port
jumps to DELAY
jumps to MAIN

0
1
2
0
1
2

; stores 3 to R3 for 3 loops


; no operation, wastes time
; if R3 <> 0 then jump to LOOP1
; return to previous CALL if R3 = 0

3. Notice this program has three program blocks: MAIN, DELAY, and LOOP1.
4. The MAIN block toggles the ports from 55H to AAH (01010101b to 10101010b).
5. After each toggle, the DELAY block is called. The DELAY block consists of a single loop that repeats
three times. Three was chosen because it is small enough to demonstrate loops, but not so large as
to waste your time. This value could be up to 255. In a previous lab, three loops were nested to create
a longer time delay that allowed the LED update to be visible.
6. After the repetition, the program returns to the step immediately after the ACALL statement that called
the loop.
7. The program does not have a termination point and will loop until you manually terminate it.
8. Start Debug and make sure the following windows are open:
o

Ports 0, 1, 2, & 3

Registers

Memory 1, set to C: 0000h

Memory 2, set to D: 0000h

9. The program counter should be at Step 3. Press F11 to step through the instruction.
10. Examine the Registers window. The ports should reflect the following values:

47

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

P0 = 55H, P1 = FFH, P2 = FFH, and P3 = FFH


11. Examine the data using the Memory 2 view. Locate address 80H.
a. You can locate 0x68 line and count over to address 80h (remember to count in hexidecimal)
b. Or you can enter 80h into the Address: box to start the window display at address 0x0080h.
c.

Remember to return the window to D: 0000h after you check a specific memory location.

12. Address 80h is Port 0 and it should read: 55H


13. Carefully examine the Registers and Memory 2 windows while stepping through the program. You
should see Ports 1 and 2 update (addresses 90H and A0H).
14. When you reach the ACALL DELAY, the program will transfer to the DELAY block and R3 will be
loaded with the value of three. Also, the stack pointer will change from 7 to 9 and the ACALL
statement will load the address for the statement immediately following it. This is called the return
point.
15. As you step, the program will loop and R3 will decrement until it reaches 0. At that point the program
will reach the RET statement and return to the statement after the call statement. SP will change from
9 to 7 because program flow has returned to the address that was stored in the stack. That address is
no longer needed.
16. Step through the program repeatedly until you can identify each register update and explain the
reason behind the change. Watch these registers carefully:
o

PC, SP, R3, P0, P1, and P2

17. Change the value stored to R3 from 3 to 10 or some other value. Reassemble and run the program.
What changed?
Activity 2: Perform I/O Port Operations
1. Create a working project by following these steps.
a.

Create New Project

b.

Select Processor Dallas DS89C450 (do not copy startup code)

c.

Create New Source Code File (name as .a51, .src or .c)

d.

Write Source Code

e.

Add File to Source Group

f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g.

Build All Target Files

h.

Start Debug

2. The correct code follows:

ORG
MOV
MOV
HERE:
MOV

0000H
A,#0FFH
P1,A

;A=FFH
;make P1 an input port

A,P1

;get data from P1

48

04/19/2012

Microprocessors and Microcontrollers

MOV P2,A
SJMP HERE
END

GRADED ASSIGNMENTS

;send it to P2
;keep doing this

3. Connect each pin of P1 of the 8051 (P1.0 through P1.7 on J3) to the DIP switches of the 8051
Trainer, P1.0 to J7-1, P1.1 to J7-2, etc.
4. Connect each pin of P2 to an LED on the LED bar of the 8051 Trainer.
5. The program will read the data applied to P1 from the DIP switches and transfer that data to P2. The
data at P2 will illuminate the applicable LED.
6. Build and save the executable hex code.
7. Establish a connection, download the program, and run the program.
8. Any change of status of the switches connected to P1 will be instantly reflected (within a fraction of a
microsecond)on LEDs connected to P2. Change the DIP switches to a variety of settings and verify
the LED reflects the change correctly.
9. Use the Oscilloscope and or logic probe to verify the voltage levels applied to the input port and
delivered by the output port.
Activity 3: Perform I/O Port Operations on Specific Port Bits
1. Without changing any existing wire connections, create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

ORG
MOV
SETB
HERE:
MOV
MOV
SJMP
END

0000H
P2, P1
P1.7

;make P1 pin 7 an input port

C, P1.7
P2.7,C
HERE

;get data from P1 bit 7


;send it to P2 bit 7
;keep doing this

3. The program will initially transfer the setting of P1 to P2.


4. After the initial transfer, the program will read individual bits from P1 bit 7 and update an individual bit
at P2.7.

49

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

5. Build and save the executable hex code.


6. Establish a connection, download the program, and run the program.
7. Any change of switch 8 will be reflected in LED 8.
Activity 4: Simulate Memory and Addressing Operations
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

ORG 0000H
;burn program into ROM at addr 0000h
MOV DPTR, #200H
;load 200h into DPTR
CLR A
;clear ACC
MOVC A, @A+DPTR ;move contents of ACC + DPTR to ACC
MOV R0, A
;move ACC to R0, first letter
INC DPTR
;increment to addr of next letter
CLR A
;clear ACC
MOVC A, @A+DPTR ;repeat twice more
MOV R1, A
INC DPTR
CLR A
MOVC A, @A+DPTR ;@ is indirect addressing
MOV R2, A
HERE: SJMP HERE
;you have transferred the first 3
;letters of your last name
ORG 200H
MYDATA: DB "LASTNAME"
END

3. The program stores your last name in ASCII in the code space starting at address 200H.
4. Notice that direct and indirect addressing modes are used.
5. It then transfers the first three letters of your last name to R0, R1, and R2.
6. Open the Memory 2 Window at address D: 0000h.
7. Look up your last name in the ASCII table.
8. Modify the program to move the last three letters of your name to R0, R1, and R2.
9. Modify the program to move the first three letters of your name to addresses 40H, 41H, and 42H.

50

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

10. Modify the program to reverse the order of the contents of 40H, 41H, and 42H and store them starting
at 60H.
11. Watch the Register and Memory 2 windows as you step through the program, notice that the registers
and memory locations update.
12. Make sure to identify each memory location and verify that the first three letters of your name are
stored in the correct locations.
Activity 5: Design, Simulate, and Test the Lookup Table, Memory, and Addressing Operations
1. Write a program to accept an input y from Port 1 (your DIP switches), calculate (i.e., look up) x2 for
any number between 0 and 9, and output the result to Port 2.
2. The lookup table for x2 is located at the address (code space) of 200H.
3. Register R0 should hold the value of x, and, at the end of the program, R2 should hold the value of y.
4. Use the simulator to change the x value and single-step through the program, examining the registers
as you go.
5. Once the program works correctly, download and run on the Trainer. No wiring changes should be
necessary. The LEDs should show the squared value of the DIP switch settings (0-9).
6. The lookup table code should look like this:

ORG 200H
XSQR_TABLE:
DB 0, 1, 2, 9, 16, 25, 36, 49, 64, 81
END

Deliverables

Complete the Unit 3 Lab 1 Worksheet (ET2640.U3.HO1)

Due at the end of class

51

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 3 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Demonstrate the processes of creating, assembling, and programming microcontrollers.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Plan, design, implement, and debug at least one functional microcontroller student project.

Use development tools to assemble and download code into a microcontroller.

Debug an assembler program using a simulator.

Program the 8051 to use indirect addressing to access look-up table values.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective Explain the purpose of the lab.

Setup Provide a complete list of all required equipment and materials.

Explanation of experimental procedure Provide a detailed summary of how you performed the
lab.

Conclusions Provide an analysis of what you learned from the lab.

Deliverables

Completed Unit 3 Lab 1 Report

Typed up with a word processor

Due at the beginning of Unit 4

52

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 4 Lab 1: Data Manipulation and Arithmetic Operations (Part 1)


Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Use numerical methods for processor-based systems to perform calculations and conversions
related to programming.

Apply common processor instructions in programs to demonstrate how they operate.

Demonstrate the processes of creating, assembling, and programming microcontrollers.

Use simulation and debugging techniques to verify that software is operational.

Plan, design, implement, and debug at least one functional microcontroller student project.

Use development tools to assemble and download code into a microcontroller.

Debug an assembler program using a simulator.

Write an assembly program to perform arithmetic operations in assembly (ADD, ADDC, DA,
SUBB, MUL, DIV).

Write an assembly program to perform bit-wise logical operations (AND, OR, XOR, CPL).

Write an assembly program to perform compare operations.

Write an assembly program to perform shift operations.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Bray Terminal or TeraTerm Terminal

MDE 8051 Trainer

Oscilloscope

Logic probe

Introduction
Microcontrollers are commonly used as counters. Some examples of products that use microcontrollers
as counters are copiers, microwave ovens, and answering machines. Many of these counters use an
input device, such as a keypad, to set the final counter value. In the absence of a keypad, DIP switches
can be used to input the value that sets the maximum count. This lab explores counters by using realworld examples.
Recommended Procedures
Activity 1: Create a Manually Programmable Up-Counter Using the 8051

53

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

In many systems, an up-counter is used to keep track of an action. For example, a copier must count the
number of copies it makes. In this activity, you will set up a manually programmable up-counter using the
8051 microcontroller. This activity reviews I/O operations and loops and uses an ADD statement instead
of an increment statement (INC).
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

ORG 0000H
MAIN: MOV P2, #0H
;make the P2 an output port
MOV P1, #0FFH
;make P1 an input port
BACK: MOV A, P1
;get the maximum count from P1
MOV B, A
CLR A
AGAIN: MOV P2, A
ACALL DELAY
CJNE A, B, OVER
;if a <> B goto over
SJMP BACK
OVER: ADD A, #1
;same as INC A
SJMP AGAIN
;-----------------------------DELAY:
MOV R5, #30
HERE3: MOV R4, #100
HERE2: MOV R3, #200
HERE1: NOP
NOP
NOP
DJNZ R3, HERE1
DJNZ R4, HERE2
DJNZ R5, HERE3
RET
END MAIN
3. Connect Port 1 to the DIP switches. Connect Port 2 to the LED bank. Note: Do not remove the wiring,
you will use it again later in activity 4.
4. Set the dip switches to 0FH, binary 00001111. This setting will cause the counter to count from 0 to
255. The LEDs should cycle through and display binary 0 through 255.

54

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

5. Build and save the executable hex code.


6. Establish a connection, download the program, and run the program.
7. Observe the LEDs counting up from 0 to 255. Remember, you can decrease or increase the time
between counts by changing the values of R3, R4, or R5.
8. Manually change the programs maximum count value by changing the DIP switch settings. Make the
Trainer count from 0 to 10 by setting the DIP switch to the equivalent of decimal 10.
9. Press reset and observe.
10. Can you devise a method to count to 64 by:

Even numbers only?

Odd numbers only?

100 by fives?

Activity 2: Manipulate Multi-Byte Numbers and Learn to Use the Carry Flag
Until now, you have worked exclusively with single-byte data. Most actual operations require numbers
larger than 0 to 255.
1. Create a working project by following these steps.
a.

Create New Project

b.

Select Processor Dallas DS89C450 (do not copy startup code)

c.

Create New Source Code File (name as .a51, .src or .c)

d.

Write Source Code

e.

Add File to Source Group

f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g.

Build All Target Files

h.

Start Debug

2. The program that demonstrates how to set the carry flag. The correct code follows:

ORG
MOV
ADD
NOP
END

0000H
A, #0FFH
A, #1H

;ACC equals FF
;add 1 to it

3. Start Debug and make sure the following windows are open:

Ports 0, 1, 2, 3, & 4

Registers

Memory 1, set to C: 0000h

55

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Memory 2, set to D: 0000h

4. Use the Simulator to step through while carefully examining the Register window, specifically the
Accumulator (Sys.a) and the Program Status Word Carry bit (Sys.psw.cy). Notice that address E0h is
the memory address where the accumulator is stored and D0h is the memory address where the
PSW is stored.
5. Repeat this until you understand when 0FFH and 01H are added.
6. Once you understand what happens when a carry is created at the accumulator, modify the program
to take two numbers, add them, and store the result. The correct code follows:

ORG
MOV
MOV
MOV
ADD
MOV
CLR
ADDC
MOV
NOP
END

0000H
R0, #250
R1, #10
A, R0
A, R1
R3, A
A
A, #0
R2, A

;R0 equals 250


;R1 equals 10
;move 250 to ACC
;add 250 + 10 equals 260
;store LSB 04h to R3
;add Carry flag + 0 to ACC
;store MSB to R2

7. Build and debug the program.


8. Single step through the program to see how the least significant bytes are added, create a carry and
they the carry is added to the sum of the significant bytes. Adding 250 and 10 results in 260, a
number greater than 255. The result must be stored in two bytes.
9. Modify the program to take two 16-bit numbers, 8186 and 2147, add them, and store the result
(1FFAH+863H). The correct code follows:

ORG
MOV
MOV
MOV
MOV
MOV
ADD
MOV
CLR
MOV
ADDC
MOV
NOP
END

0000H
R0, #01FH
R1, #0FAH
R2, #08H
R3, #63H
A, R1
A, R3
R7, A
A
A, R0
A, R2
R6, A

;number 1 MSB
;number 1 LSB
;number 2 MSB
;number 2 LSB
;load ACC with number 1 LSB
;add both LSBs
;store LSB result in R7
;load ACC with number 1 MSB
;add both MSBs and carry
;store MSB result in R6

10. Build and debug the program.


11. Single step through the program and verify the hexadecimal result.

56

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Activity 3: Explore operations on signed binary numbers


With signed binary numbers, you must keep track of the MSB. If the MSB bit of the result is different than
that of the operands, then a math error has occurred and the program must make a correction. For
example by adding 96 and 70 equals 166. 166 is A6h and Is a negative number! When -2 is added to
-128 the result is -130. -130 is 82h which is a positive number! The overflow flag indicates this error
condition.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The following program that demonstrates how to set the overflow flag:
96

0110 0000

+70

0100 0110 (equals)

166

1010 0110 (which is a negative signed number!)

3. The correct code follows:

ORG
MOV
MOV
ADD
ADD
NOP
END

0000H
R0, #+96
R1, #+70
A, R0
A, R1

4. Start Debug and make sure the following windows are open:

Ports 0, 1, 2, 3, & 4

Registers

Memory 1, set to C: 0000h

Memory 2, set to D: 0000h

57

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

5. Step through while carefully examining the Register window, the Data Memory view, and the psw.ov.
A review of PSW indicates that the OV bit is bit 3 of address D0. You should see that the ov bit is high
when an overflow condition occurs.
6. The following program that demonstrates how to set the overflow flag using negative numbers:

-2,

1111 1110

-128,

1000 0000

(equals)

-130,

0111 1100

(which is a positive signed number!)

7. The correct code follows:

ORG
MOV
MOV
ADD
ADD
NOP
END

0000H
R0, #-2
R1, #-128
A, R0
A, R1

8. Step through while carefully examining the Register window, the Data Memory view, and the
PSW.OV. A review of PSW indicates that the OV bit is bit 3 of address D0. You should see that the ov
bit is high when an overflow condition occurs. You should observe the OV flag set.
Activity 4: Examine Shift Operations
Shift operations are typically used to transfer data digitally. In this activity, you will enter a bit pattern and
watch it rotate at the output using the 8051 Trainer.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. This activity will use the same wire configuration from Activity 1.
3. Set all DIP switches to off except switch 1.
4. The correct code follows:

ORG
MAIN: MOV

0000H
P2, #0H

;make the P2 an output port

58

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

MOV P1, #0FFH


;make P1 an input port
BACK: MOV A, P1
;get the bit pattern from P1
AGAIN: MOV P2, A
;output bit pattern to P2
ACALL
DELAY
;delay loop to watch progress
RL
A
;rotate left
SJMP AGAIN
DELAY: MOV R5, #10
HERE3: MOV R4, #100
HERE2: MOV R3, #200
HERE1: NOP
NOP
NOP
DJNZ R3, HERE1 ; decrement Register#
DJNZ R4, HERE2 ; and jump to HERE#
DJNZ R5, HERE3 ; if Register# <> 0
RET
END MAIN

5. Build and save the executable hex code.


6. Establish a connection, download the program, and run the program.
7. Observe the LEDs changing as the bit rotates from LSB to MSB.
8. Change the bit pattern by setting the DIP switches as follows: 1000 0001.
9. Reset, and watch the new bit pattern.
10. Experiment until you understand the program operation. For a greater challenge, experiment with
rotate right and left commands to make the LED display a back and forth pattern similar to the KnightRider dash display or a Cylons eye display.
Activity 5: Examine Logic Operations
Logic operations are typically used to test data against a known standard or set point. In this activity, you
will enter a set point using switches and watch its output when compared to another value using the 8051
Trainer.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files

59

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

h. Start Debug
2. This activity will use the same wire configuration from Activity 1.
3. Set the DIP switches to 55h or 0101 0101b.

60

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

4. The correct code follows:

ORG 0000H
MOV R0, #0A5H
MOV P2, #0H
MOV P1, #0FFH
BACK: MOV A, P1
ANL A, R0
SJMP BACK
END

;
;
;
;
;

R0 the set point or compare value


P2 an output port
P1 an input port
get the bit pattern from P1
Logic compare of P1 & R0

5. Build and save the executable hex code.


6. Establish a connection, download the program, and run the program.
7. This program does a logic AND comparison of P1 and R0.

P1 R 0 = 01010101b
10100101b
00000101b
8. Observe that the LED output should be 05h or 0000 0101b.
9. Experiment by changing the dip switch settings and discover the new output value.
10. Change the ANL instruction to OR.
11. This program does a logic OR comparison of P1 and R0.

P1+ R 0 = 01010101b
10100101b
11110101b
12. Observe that the LED output should be F5h or 1111 0101b.
13. Experiment by changing the dip switch settings and discover the new output value.
14. Change the OR instruction to XOR.
15. This program does a logic OR comparison of P1 and R0.

P1 R 0 =

01010101b
10100101b
11110000b

16. Observe that the LED output should be F0h or 1111 0101b.
17. Experiment by changing the dip switch settings and discover the new output value.
Activity 6: Design, Simulate, and Test Logic Operations
Use Section 6.3 of the textbook, The 8051 Microcontroller and Embedded Systems. Design and simulate
one or more programs that will perform logic functions comparing the values stored in P1 and R0. Output
the result to P0.

61

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

1. Test the operation using the 8051 Trainer. The Trainer should already be wired correctly from the
previous activities.
Deliverables

Complete the Unit 4 Lab 1 Worksheet (ET2640.U4.HO1)

Due at the end of class

62

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 4 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Describe contemporary wide-ranging microprocessor and microcontroller product applications.

Use numerical methods for processor-based systems to perform calculations and conversions
related to programming.

Apply common processor instructions in programs to demonstrate how they operate.

Demonstrate the processes of creating, assembling, and programming microcontrollers.

Use simulation and debugging techniques to verify that software is operational.

Plan, design, implement, and debug at least one functional microcontroller student project.

Use development tools to assemble and download code into a microcontroller.

Debug an assembler program using a simulator.

Write an assembly program to perform arithmetic operations in assembly (ADD, ADDC, DA,
SUBB, MUL, DIV).

Write an assembly program to perform bit-wise logical operations (AND, OR, XOR, CPL).

Write an assembly program to perform compare operations.

Write an assembly program to perform shift operations.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective Explain the purpose of the lab.

Setup Provide a complete list of all required equipment and materials.

Explanation of experimental procedure Provide a detailed summary of how you performed the
lab.

Conclusions Provide an analysis of what you learned from the lab.

Deliverables

Completed Unit 4 Lab 1 Report

Typed up with a word processor

Due at the beginning of Unit 5

63

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 5 Lab 1: Testing 8051 I/O Ports Using C (Part 1)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Develop a C program for a microcontroller application.

Program the 8051 to generate a time delay using the C programming language.

Program the 8051 to perform I/O operations using the C programming language.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Bray Terminal or TeraTerm Terminal

MDE 8051 Trainer

Oscilloscope

Logic probe

Power supply

7447 Decoder

7-Segment Display COMMON ANODE

Transistor NPN 2N3904

Speaker

100 & 330 ohm resisters

Introduction
Microcontrollers are designed to accept inputs and control external components. In this lab you will use
ports to control LED and sound devices. Also, you will use switches to obtain input from an external
device causing a change in program operation.
Recommended Procedures
Activity 1: Create a C Program that Sends an Output to 8051 Ports
This activity repeats some of the activities in earlier labs except now C is the language used to program.
In this activity you will use the C compiler to test the operation of the ports of the MDE8051 trainer and get
ready for C programming of the 8051 for peripherals. After verifying that the program toggles an output to

64

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

ports 1 & 2, you will interface the trainer board LEDS to Port 2. Through experimentation, you will create a
toggle pattern that lasts exactly 1 second.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

#include <reg51.h>
void MSDelay(unsigned int);
void main()
{
P1=0x0;
P2=0x0;
for(;;)
{
P1= 0x55;
P2= 0x55;
MSDelay(0); // During simulation use a delay of 0
P1= 0xAA;
P2= 0xAA;
MSDelay(0); // During simulation use a delay of 0
}
}
void MSDelay(unsigned int itime)
{
unsigned int i, j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}

//Modify the delay to see


//the rate of toggling

3. Notice that the MSDelay value is set to 0. During the simulation, the MSDelay function will be
skipped! This value will be increased when the ports are connected to the LEDs.

65

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

4. Notice the header file reg51.h included in the C program code. This header file defines the address
location for the various registers and ports used by 8051 microprocessors. If you locate the file
(Project Window: Target 1 Source Group 1 C5.c reg51.h) and examine it, you will see
something similar to the following:
/*------------------------------REG51.H
Header file for generic 8051
microcontroller. */
#ifndef __REG51_H__
#define __REG51_H__
/*

BYTE Register

sfr P0

= 0x80;

sfr P1

= 0x90;

sfr P2

= 0xA0;

sfr P3

= 0xB0;

sfr PSW

= 0xD0;

sfr ACC

= 0xE0;

sfr B

= 0xF0;

sfr SP

= 0x81;

sfr DPL

= 0x82;

sfr DPH

= 0x83;

*/

/*

BIT Register

/*

PSW

*/

*/

sbit CY

= 0xD7;

sbit AC

= 0xD6;

sbit F0

= 0xD5;

sbit RS1

= 0xD4;

sbit RS0

= 0xD3;

sbit OV

= 0xD2;

sbit P

= 0xD0;

#endif

sfr PCON = 0x87;


sfr TCON = 0x88;
sfr TMOD = 0x89;
sfr TL0

= 0x8A;

sfr TL1

= 0x8B;

sfr TH0

= 0x8C;

sfr TH1

= 0x8D;

sfr IE

= 0xA8;

sfr IP

= 0xB8;

sfr SCON = 0x98;


sfr SBUF = 0x99;
5. Build and save the executable hex code.
6. Start Debug and make sure the following windows are open:

Ports 1 & 2

Registers

66

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Memory 2, set to D: 0000h

7. As you step through the program, observe that Port 1 & Port 2 each toggle between:
0x55h 0101 0101
0xAAh 1010 1010
8. Also observe how the registers and ports update in memory.
9. Connect the trainer LEDs to Port 2.
10. Change the MSDelay argument from 0 to 250.
11. Build and save the executable hex code.
12. Establish a connection, download the program, and run the program.
13. Observe the LEDs toggling between 0x55h and 0xAAh.
14. Experiment with the MSDelay argument to see the affect of chaning the delay value. Increasing the
value should slow the time between the toggle; likewise, decreasing the value will speed up the
frequency of toggles.
15. Use the Oscilloscope to determine the actual delay between toggles. Determine the exact value of
MSDelay that will result in a 1-second delay between toggles. Write this value down; you will use it
again.

Activity 2: Create a C Program that Obtains an Input from an 8051 Port


Now you will simulate the input into a port. The input will be used to establish the value of one of the
toggled outputs. After verifying the program works, youll connect the trainer switch to Port 1.
1. Create a working project by following these steps.
a.

Create New Project

b.

Select Processor Dallas DS89C450 (do not copy startup code)

c.

Create New Source Code File (name as .a51, .src or .c)

d.

Write Source Code

e.

Add File to Source Group

f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g.

Build All Target Files

h.

Start Debug

67

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

2. The correct code follows: (you may want to copy and paste the previous code and modify it)

#include <reg51.h>
void MSDelay(unsigned int);
void main()
{
unsigned char mybyte;
P1=0x0FF;
//P1 as input
P2=0x0;
//P2 as output

for(;;)
{
P2= 0x55;
MSDelay(0);
mybyte = P1;
P2= mybyte;
MSDelay(0);
}

//reset output to 01010101


//get data from P1
//and send it to P2

void MSDelay(unsigned int itime)


{
unsigned int i, j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}

//Modify this delay to see


//the rate of toggling

3. Start Debug and make sure the following windows are open:
o

Ports 0, 1, 2, 3, & 4

Registers

Memory 2, set to D: 0000h

4. Single step through the program until Port 1 configured as an input (after the port is set to 0x0FF).
5. Manually change the Port 1 window toggle switches to 0X33h.

6. Use the Simulator to step through while carefully examining Port 2; it should toggle between 0x55h &
0x33h.
7. Change the value of Port 1 to experiment with different values. Notice that the switch update doesnt
affect the values. Why? For now, restart the simulation as you check different values at Port 1.
8. After you understand how the program works, connect the trainer switches to Port 1. Set the switches
to 0x33h.
9. Change the MSDelay argument to the value that will cause a 1-second toggle time.

68

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

10. Build and save the executable hex code.


11. Establish a connection, download the program, and run the program.
12. Observe the LEDs toggling between 0x55h and 0x33h.
13. Change the value of the switches. Again, the switch update doesnt affect the values. Why?
14. Press the reset button. Did the new toggle value update?
15. What must be done to force Port 1 to accept a new input? Hint: Port 1 must be set to read again.
16. Modify the program so that Port 1 reads from the switches during every cycle. Hint: you will need to
enter the following code at the correct point in the for loop: P1= 0x0FF;
17. When you have this issue resolved, demonstrate to your instructor.
Activity 3: Connect a 7-Segment Display to the Trainer
Although the trainer board LEDs is a useful tool, a 7-segment display is a superior output device.
1. Use the same program from Activity 2.
2. Remove power from the trainer and connect the 7447 decoder and the 7-segment display as follows:

3. Apply power to the trainer and reset the trainer.


4. Experiment with the dip switch settings and watch the 7-segment display update.

69

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Activity 4: Connect a buzzer or Speaker to the Trainer


Sound is a great output device. Connect a speaker and use a single port bit to control the output.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

#include <reg51.h>
sbit mybit = P3^7;
void MSDelay(unsigned int);
void main(void)
{
while(1)
{
mybit=1;
MSDelay(250);
mybit=0;
MSDelay(250);

//Modify this delay to


//hear different buzzer sound

void MSDelay(unsigned int itime)


{
unsigned int i, j;
for(i=0;i<itime;i++)
for(j=0;j<12
}

70

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

3. Remove power from the trainer and connect the speaker as follows: (note: do not remove the wiring
from activities 1 and 2; you will use them again)

4. Apply power to the trainer and reset the trainer.


5. Experiment with the MSDelay argument to change the output of the speaker.
6. Determine the MSDelay value required to deliver a 1kHz tone.

Activity 5: Design, simulate, and test input/output operations


Combine the programs in Activity 1 and 2 to use the trainer switch connected to Port 1 to set the length of
the MSDelay argument. For an additional challenge, use multiple timers to create a sequence of tones.
1. Test the operation using the 8051 Trainer. The Trainer should already be wired correctly from the
activities 1 and 2, except now the switch will establish the delay time instead of the value of the
second toggle number.
Deliverables

Complete the Unit 5 Lab 1 Worksheet (ET2640.U5.HO1)

Due at the end of class

71

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 5 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Develop a C program for a microcontroller application.

Program the 8051 to generate a time delay using the C programming language.

Program the 8051 to perform I/O operations using the C programming language.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective Explain the purpose of the lab.

Setup Provide a complete list of all required equipment and materials.

Explanation of experimental procedure Provide a detailed summary of how you performed the
lab.

Conclusions Provide an analysis of what you learned from the lab.

Deliverables

Completed Unit 5 Lab 1 Report

Typed up with a word processor

Due at the beginning of Unit 6

72

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 6 Lab 1: Timer Programming (Part 1)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Develop a C program for a microcontroller application.

Describe the Timer operation of the 8051 Timer/Counter.

Explain the purpose of each operating mode used by the TMOD register.

Explain how the TCON register is used.

Program the 8051 to generate time delays using the C programming language.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Bray Terminal or TeraTerm Terminal

MDE 8051 Trainer

Oscilloscope

Logic probe

Introduction
Timers provide one of the most important microcontroller functions. One timer application is to produce
square waves of different frequencies. In this lab, you will use timer modes 1 and 2 to generate square
waves at different frequencies.
Recommended Procedures
Activity 1: Use Timer Functions
In this activity you will use Timer 0 to create precise delays. During the last lab, the MSDelay function was
used to create time delays. The following will create and simulate a timer delay.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

73

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

#include <reg51.h>
void T0Delay(void);
void main()
{
P2=0x0;
while(1)
{
P2=0x55;
T0Delay();
P2=0xAA;
T0Delay();
}
}
void T0Delay()
{
TMOD=0x01;
TL0=0x00;
TH0=0xFF;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

//P2 as output

//Timer0 16-bit mode


//change this
// and this number to increase or
// decrease the delay size

3. If you examine the code, you should observe that Port 2 will toggle between 0x55h and 0xAAh using
T0Delay(). Examine the T0Delay() code.
5. In the Project Window, open the reg51.h file and locate the following variables.

TMOD

TCON

TL0

TH0

TR0

TF0

6. TMOD, TL0 & TH0 are part of the special function registers. TR0 & TF0 are part of the TCON register.
7. Build and save the executable hex code.

74

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

8. Start Debug and make sure the following windows are open:

Port 2

Registers

Memory 2, set to D: 0000h

Open the Timer 0 window (Peripherals Timer Timer 0)

9. Initially the timer flags will all be cleared at 0x00 and the status will be stop.
10. Single step through the program until TMOD updates to 0x01; this indicates the timer is in 16 bit
mode. The Mode box should update to 1: 16 Bit Timer/Counter.
11. The next line of code clears the timer low byte TL0 to 0x00. Single step again.
12. The next line of code sets the timer high byte TH0 to 0xFF. Single step again.
13. The next line of code sets TR0, the timer timing flag to a 1. Single step again .
14. Status should change to Run, indicating that the timer is timing.
a. The timer timing flag TR0 is checked which indicates that it is a 1.
b. TCON will also update to 0x10, which indicates the TCON bit 4 is set to 1; this indicates that
timer 0 is turned on.
15. Single step repeatedly; you should notice the program pointer remains at while(TF0==0) and
that the TL0 register is increasing upon every step.
a. This means that the TL0 will count up from 0 to FF until it carries over to TH0 and causes an
overflow condition, which should stop the timer.
16. Quickly and repeatedly press the F11 key and rapidly increase TL0 until you notice the value of TL0
reach D# or E#.
17. Slowly press F11 and watch TL0 approach FF.
18. Continue pressing F11 until TL0 increases above 0xFF.
a. TH0 should toggle to 0x00 and the timer finished flag TF0 should set.

75

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

b. TF0 should be checked indicating that it is set at 1.


c.

TCON should update to 0x30, which indicates that TCON bits 4 & 5 are both set to 1; this
indicates that timer 0 is on and has reached an overflow condition.

19. Single step until the program pointer leaves the while(TF0==0) line of code and is pointing at
TR0=0;.
20. The next line of code clears the timer timing TR0 flag to a 0.
a. Single step again.
b. Status should change to Stop, indicating that the timer is no longer timing.
c.

TR0 is unchecked, which indicates that it is a 0.

d. TCON updates to 0x20, which indicates that TCON bit 4 is now cleared (timer stopped) and
bit 5 is still set (overflow condition).
21. The next line of code clears the timer timing TF0 flag to a 0.
a. Single step again.
b. TR0 is unchecked, which indicates that it is a 0.
c.

This sets up the timer for its next use.

d. Single step again.


22. The program pointer jumped out of the T0Delay() function and should be pointing at the P2=0xAA
line of code.
23. Repeat stepping through the program until you understand how the timer works.
24. Hold down the F11 key down to rapidly progress through the delays until you should notice that Port 2
toggles between 0x55 and 0xAA.
25. Repeat this process until you can state the purpose of each of the following:

TMOD

TCON

TL0

TH0

TR0

TF0

Activity 2: Use the Timer Function to Generate a Square Wave


In this activity you will use a bit output to provide a square wave and determine the highest and lowest
frequency that can be generated. Program Port 2 bit 7 as an output that toggles between a high and a
low.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)

76

04/19/2012

Microprocessors and Microcontrollers

c.

GRADED ASSIGNMENTS

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows: (you may want to copy and paste the previous code and modify it)

#include <reg51.h>
void T0Delay(void);
sbit mybit = P2^7;
void main()
{
P2=0x0;
while(1)
{
mybit=1;
T0Delay();
mybit=0;
T0Delay();
}
}
void T0Delay()
{
TMOD=0x01;
TL0=0x00;
TH0=0xFF;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

//P2 as output

//Timer0 16-bit mode


//change this
// and this number to increase or
// decrease the delay size

3. Start Debug and make sure the following windows are open:

Port 2

Registers

Timer 0

4. Single step through the program and verify that the code works correctly and toggles port 2 pin 7.
5. Build and save the executable hex code.
6. Establish a connection, download the program, and run the program.
7. Connect an oscilloscope to Port 2 pin 7 and measure the pulse width and determine the frequency of
the output. Write down this information:
o

TL0 & TH0

Pulse width & frequency

77

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

8. Modify the values of TL0 and TH0 that will provide the highest output frequency.
9. Build and save the executable hex code.
10. Establish a connection, download the program, and run the program.
11. Connect an oscilloscope to Port 2 pin 7 and measure the pulse width and determine the frequency of
the output. Write down this information.
o

TL0 & TH0

Pulse width & frequency

12. Modify the values of TL0 and TH0 that will provide the lowest frequency.
13. Build and save the executable hex code.
14. Establish a connection, download the program, and run the program.
15. Connect an oscilloscope to Port 2 pin 7 and measure the pulse width and determine the frequency of
the output. Write down this information.
o

TL0 & TH0

Pulse width & frequency

Activity 3: Overcome the Delay Size Limitation of the Previous Activity


Modify the for loop and TH/TL values to get an exact 1msec delay. Use the oscilloscope to verify that the
frequency is exactly 1 kHz.
1. Modify the program used in activity 2.

#include <reg51.h>
void T0BigDelay(unsigned int);
sbit mybit = P2^7;
void main()
{
P2=0x0;
//P2 as
while(1)
{
mybit=1;
T0BigDelay(10); //modify the
mybit=0;
// or larger
T0BigDelay(10); //modify the
}
// or larger

output

value
delay
value
delay

to see smaller
size
to see smaller
size

}
void T0BigDelay(unsigned int itime)
{
unsigned int x;
for (x=0;x<itime; x++)
{
TMOD=0x01;
//Timer0 16-bit mode
TL0=0x00;
//change this to increase

78

04/19/2012

Microprocessors and Microcontrollers

TH0=0xFF
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

GRADED ASSIGNMENTS

// or decrease the delay size

}
2. Start Debug and make sure the following windows are open:
o

Port 2

Registers

Timer 0

3. Single step through the program and verify that the code works correctly and toggles port 2 pin 7.
4. Determine the values you need to create a 1kHz pulse. Hint: 1 millisecond per cycle. Or 500 microseconds per delay. Refer to the textbook starting at page 278 for more information.
5. Modify the program.
6. Build and save the executable hex code.
7. Establish a connection, download the program, and run the program.
8. Connect an oscilloscope to Port 2 pin 7 and measure the pulse width and determine the frequency of
the output.
9. Experiment until your output is correct.
10. Record this information once the output is correct.
o

TL0 & TH0

Pulse width & frequency

Activity 4: Use timer mode 2 (auto reload) to generate a square wave.


In this activity you will use Timer 0 Mode 2 to generate a square wave output. Mode 2 is easier to use in
most cases, but it has some limitations.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug

79

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

2. The correct code follows:

#include <reg51.h>
void T0Delay(void);
sbit mybit = P2^7;
void main()
{
P2=0x0;
while(1) {
mybit=1;
T0Delay();
mybit=0;
T0Delay(); }
}
void T0Delay()
{
TMOD=0x02;
TH0=0xAA;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}

//P2 as output

//Timer0 8-bit mode


// this number changes the
// reset size

3. Start Debug and make sure the following windows are open:
o

Port 2

Registers

Timer 0

4. Single step through the program and watch the Timer 0 window. Notice that TL0 resets to the value of
TH0 whenever the timer resets.
5. Connect an oscilloscope to Port 2 pin 7 and measure the pulse width and determine the frequency of
the output. Write down this information.
o

TH0

Pulse width & frequency

6. Modify the values of TL0 and TH0 that will provide the highest output frequency.
7. Build and save the executable hex code.
8. Establish a connection, download the program, and run the program.
9. Connect an oscilloscope to Port 2 pin 7 and measure the pulse width and determine the frequency of
the output. Write down this information.
o

TH0

Pulse width & frequency

10. Modify the values of TL0 and TH0 that will provide the lowest frequency.
11. Build and save the executable hex code.

80

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

12. Establish a connection, download the program, and run the program.
13. Connect an oscilloscope to Port 2 pin 7 and measure the pulse width and determine the frequency of
the output. Write down this information.
o

TH0

Pulse width & frequency

14. The waves created so far should have a duty cycle of 50%. Can you find an easy way to create a
25% duty cycle waveform? How about 80% duty cycle (4 high cycles followed by 1 low)? Use the
oscilloscope to verify your results and show your instructor.
Activity 5: Design, Simulate, and Test Input/Output Operations
Use the information in activities 1 through 4 to use the trainer to create a perfect 1 (one) Hz output
frequency.
1. Determine the values of TL0 and TH0 that will provide a 1 Hz frequency.
2. Test the operation using the 8051 Trainer.
3. Verify that the pulse width and frequency of the output are correct.
4. Record this information.
o

TL0 & TH0

Pulse width & frequency

Deliverables

Complete the Unit 6 Lab 1 Worksheet (ET2640.U6.HO1)

Due at the end of class

81

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 6 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Develop a C program for a microcontroller application.

Describe the Timer operation of the 8051 Timer/Counter.

Explain the purpose of each operating mode used by the TMOD register.

Explain how the TCON register is used.

Program the 8051 to generate time delays using the C programming language.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective Explain the purpose of the lab.

Setup Provide a complete list of all required equipment and materials.

Explanation of experimental procedure Provide a detailed summary of how you performed the
lab.

Conclusions Provide an analysis of what you learned from the lab.

Deliverables

Completed Unit 6 Lab 1 Report

Typed up with a word processor

Due at the beginning of Unit 7

82

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 7 Lab 1: 8051 Serial Port Programming (Part 1)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Develop a C program for a microcontroller application.

Explain the function of the 8051 SBUF, SCON, and PCON registers for serial communications.

Calculate the value stored in the THx register for a given baud rate.

Program the 8051 to transmit data from the serial port using the C programming language.

Program the 8051 to receive data from the serial port using the C programming language.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Bray Terminal or TeraTerm Terminal

MDE 8051 Trainer

Oscilloscope

Power supply

7447 Decoder

7-Segment Display Common Anode

330 ohm resister

Introduction
The serial port is a widely used method of transferring data. Although USB has diminished the use of the
serial COM port, its use has not been eliminated. Many devices still provide output via the serial port. One
reason is due to the simplicity of the hardware and ease of programming in both assembly and C
languages. In this lab, you will program the serial port of the microcontroller.
Recommended Procedures
Activity 1: Simulate Serial Port I/O communications
In this activity you will use the Serial I/O to simulate communications to the terminal.
1. Create a working project by following these steps.

83

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

a. Create New Project


b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

#include <reg51.h>
void SerTx(unsigned char);
void main(void)
{
TMOD=0x20;
// Timer 1 mode 2
TH1=0xFD;
// 9600 baud
SCON=0x50;
// 8 bit, 1 stop, REN enabled
TR1=1;
// start timer
while(1)
{
SerTx('H');
SerTx('E');
SerTx('L');
SerTx('L');
SerTx('O');
SerTx(' ');
}
}
void SerTx(unsigned char x)
{
SBUF=x;
// transfer character
while(TI==0);
// do until transfer interrupt = 1
TI=0;
// clear TI for next character
}
3. If you examine the code, you should observe the message HELLO will repeatedly send to the serial
port. If you examine the code you will see that timer 1 is set to mode 2 (auto reload), the baud rate is
9600, and SCON is set to 01010000 or 0x50. This means 8 bits, 1 stop with REN (receive enable)
enabled. Notice that the SerTx) function will send the transferred character to the buffer continuously
until it successfully transfers to the terminal. The successful transfer to the terminal is acknowledged
when the TI (transfer interrupt) flag is set.
4. In the Project Window, open the reg51.h file and locate the following variables.
o

TMOD

SCON

TH1

84

04/19/2012

Microprocessors and Microcontrollers

TR1

SBUF

TI

GRADED ASSIGNMENTS

5. TMOD, SCON, SBUF and TH1 are part of the special function register. TR1 is part of the TCON
register. TI is part of the SCON register.
6. Build and save the executable hex code.
7. Start Debug and make sure the following windows are open:
o

Registers

Memory 2, set to D: 0000h

Timer 1

Open the Serial 0 window (Peripherals Serial Serial 0)

8. Initially the serial flags will all be cleared at 0x00 and the Baudrate will be 921600.
9. Single step through the program until SCON updates to 0x50, this indicates serial channel 0 is 8 bit
and 1 stop bit. The Mode box should update to 8 bit variable baudrate. REN_0 will be set (indicated
by the box being checked).
10. The next line of code starts the timer. Single step again.
11. The program pointer should now be inside the loop and pointing at the SerTx(H) line of code.
a. This will call the SerTx() function and transfer the ASCII character H to the function.
b. Single step again.
12. The program pointer should now be inside the SerTx() function and pointing at SBUF=x line of code.
a. This will transfer the value of the variable x to the serial buffer.
b. Single step again.

85

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

13. The program pointer should be pointed at the while loop. This loop will repeat until the TI (transfer
interrup) flag is set. The TI occurs when the receiving buffer acknowledges receipt of the transferred
character. Press F11 several times, the program pointer will not move.
14. Set the TI flag by checking the TI_0 box.
15. Press F11, the program pointer should move to the TI=0 line of code.
a. This clears the TI flag, preparing for the next character.
b. Single step again. This will take you to the end of the loop.
c.

Single step again.

16. The program pointer should have transferred out of the function to the next instruction, which should
be SerTx(E).
17. Single step through the program reviewing the the various windows until you understand how the
program works. Remember that SCON is a memory location. Find that location in the header file and
then use Memory window 2 to watch that location update.
Activity 2: Use Serial Port I/O Communications
In this activity you will use the previous program to send an output to the serial port and to the terminal.
1. The correct code follows: (you may want to copy and paste the previous code and modify it)

#include <reg51.h>
void SerTx(unsigned char);
void main(void)
{
TMOD=0x20;
// Timer mode 2
TH1=0xFD;
// 9600 baud
SCON=0x50;
// 8 bit, 1 stop, REN enabled
TR1=1;
// start timer
while(1)
{
SerTx('H');
SerTx('E');
SerTx('L');
SerTx('L');
SerTx('O');
SerTx(32);
SerTx('W');
SerTx('O');
SerTx('R');
SerTx('L');
SerTx('D');
SerTx('!');
SerTx(' '); // SerTx(10); or SerTx(13);
}
}

86

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

void SerTx(unsigned char x)


{
SBUF=x;
// transfer character
while(TI==0);
// do until transfer interrupt = 1
TI=0;
// clear TI for next character
}
2. Build and save the executable hex code.
a. What is the purpose of ASCII codes 32, 10, and 13?
3. Establish a connection, download the program, and run the program.
4. You should see the phrase HELLO WORLD! repeated constantly.
5. Modify your program to try these different output formats:
o

Repeating on the same line

Repeating on different lines

Activity 3: Use Serial Port I/O Communications with Different Outputs


In this activity you will send character streams to the terminal; however, you will choose the character
stream based upon a switch setting.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

#include <reg51.h>
sbit MYSW=P2^0;
//input switch
void SerTx(unsigned char);
void main(void)
{
unsigned char z;
unsigned char fname[]="ALI";
unsigned char lname[]="SMITH";
TMOD=0x20;
//use Timer 1,8-BIT auto-reload
TH1=0xFD;
//9600 baud rate
SCON=0x50;
TR1=1;
//start timer

87

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

if(MYSW==0)
//check switch
{
for(z=0;z<3;z++) SerTx(fname[z]);
SerTx(' ');
}
else
{
for(z=0;z<5;z++) SerTx(lname[z]);
SerTx(' ');
}
while (1==1);

//write name

//write name

}
void SerTx(unsigned char x)
{
SBUF=x;
// transfer character
while(TI==0); // do until transfer interrupt = 1
TI=0;
// clear TI for next character
}
3. Start Debug and make sure the following windows are open:
o

Registers

Memory 2, set to D: 0000h

Timer 1

Serial 0

4. Single step through the program and verify that the code works correctly. Remember, you must
manually change port 2 pin 0 and TI_0.
5. When you understand the program, build and save the executable hex code.
6. Establish a connection, download the program, and run the program.
7. Toggle (change) switch 1 to change the input at port 2 pin 0. Remember to press the reset button to
send a new message.
Activity 4: Use Serial Port I/O Communications to Obtain Input from the Terminal
In this activity you will use the terminal to send serial communications to the microcontroller.
1. Create a working project by following these steps.
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

88

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

g. Build All Target Files


h. Start Debug

89

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

2. The correct code follows:

#include <reg51.h>
void main (void)
{
unsigned char mybyte;
TMOD=0x20;
//use Timer 1,8-BIT auto-reload
TH1=0xFD;
//9600 baud rate
SCON=0x50;
TR1=1;
//start timer
while(1)
//repeat forever
{
while(RI==0);
//wait to receive
mybyte=SBUF;
//save value
P2=mybyte;
//write value to port
RI=0;
}
}

3. Remove power from the trainer and connect the 7447 decoder and the 7-segment display as follows:

4. Apply power to the trainer and reset the trainer.


5. Start Debug and make sure the following windows are open:
o

Port 2

Registers

Timer 0

Serial 0

6. Single step through the program and verify that it works correctly. Remember, you must manually
update the RI_0 flag.

90

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

7. Notice that the output will be sent to Port 2 and the 7-segment display. What will be displayed, the
ASCII character or the lower 4 bits of the ASCII code? (Note: the 7447 decoder will decode numbers
0 through 9.) What must be done to display the character?
8. Apply power, establish a connection, download the program, and run the program.
Activity 5: Design, Simulate, and Test Input/Output Operations
Use the information in activities 1 through 4 to use the trainer to select one of four outputs to the terminal.
1. Use two DIP switches on P1 to send one of the following messages to the terminal:
P1.1

P1.0

first name

last name

year you graduated from high school

year you started ITT Tech

2. For an added challenge, create a program that accepts input from the keyboard and uses that
information to determine which message is sent to the terminal.
Deliverables

Complete the Unit 7 Lab 1 Worksheet (ET2640.U7.HO1)

Due at the end of class

91

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 7 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Develop a C program for a microcontroller application.

Explain the function of the 8051 SBUF, SCON, and PCON registers for serial communications.

Calculate the value stored in the THx register for a given baud rate.

Program the 8051 to transmit data from the serial port using the C programming language.

Program the 8051 to receive data from the serial port using the C programming language.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective Explain the purpose of the lab.

Setup Provide a complete list of all required equipment and materials.

Explanation of experimental procedure Provide a detailed summary of how you performed the
lab.

Conclusions Provide an analysis of what you learned from the lab.

Deliverables

Completed Unit 7 Lab 1 Report

Typed up with a word processor

Due at the beginning of Unit 8

92

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 8 Lab 1: 8051 Interrupt Programming and Counters (Part 1)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Plan, design, implement, and debug at least one functional microcontroller student project.

Develop a C program for a microcontroller application.

Program the 8051 to perform Timer operations with interrupts using the C programming
language.

Program the 8051 to perform external hardware interrupts using the C programming language.

Program the 8051 to perform serial communications with interrupts using the C programming
language.

Configure the IP register to set the priority of specific interrupts.

Configure the IE register to enable a specific interrupt.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Bray Terminal or Tera Term Terminal

MDE 8051 Trainer

Oscilloscope

Power supply

330 ohm resistor

SPST push button (TP11CG)

10k ohm resistor

100 nF capacitor

Introduction
Microcontrollers must react to sensor and user inputs while still processing their programs. When an
external device needs attention, it will send a signal to the microcontroller. An example would be when a
car triggers a traffic light. Another example would be counting events, such as the number of bottles
moving past a sensor on a conveyor. When a sensor detects something, it sends a pulse to the
microcontroller, which generates an interrupt. In the case of the stop light, the interrupt routine will change

93

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

the light. In the case of the counter, the interrupt routine will update the count. In this lab, you will simulate
both types of events.
Recommended Procedures
Activity 1: Use the 8051 to Count Events
In this activity, you will use Timer/Counter 0 to count pulses. Square wave pulses will be applied from an
external source to the microcontroller via Port 3 pin 4. The microcontroller will detect the pulses, and the
counter will be updated.
1. Create a working project by following these steps:
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src, or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

#include <reg51.h>
void main()
{
TMOD=0x06; //Timer/counter 0, mode 2, counter
TH0=0;
//Clear the counter
TL0=0;
while(1)
{
TR0=1;
//Start Timer/Counter 0
while(TF0==0)
//Count until rollover
{
ACC=TL0;
P2=ACC;
}
TR0=0;
//Stop Timer/Counter
TF0=0;
//Clear Timer/Counter 0 flag
}
}

94

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

3. If you examine the code, you should observe the TL0 register will be continuously transferred to Port
2 until the counter counts pass FFh or 255.
4. The program does not reference P3.4 because once the counter is configured, any high to low
transition on P3.4 will automatically update the counter TL0 register.
5. During every loop, TL0 is transferred to the accumulator, which is then transferred to P2.
6. In the Project Window, open the reg51.h file, and locate the following variables:

ACC

TMOD

TL0

TH0

TR0

TF0

7. ACC is the accumlator; TMOD, TL0, and TH0 are part of the special function registers; and TR0 and
TF0 are part of the TCON register covered in previous units.
8. Build and save the executable hex code.
9. Start Debug, and make sure the following windows are open:

Port 2

Port 3

Timer 0

Registers

Memory 2, set to D: 0000h

10. Initially, the timer will be set to mode 0.


11. Single step through the program until TMOD updates to 0x06, which indicates the timer is in 8-bit
auto-reload counter mode. The Mode box should update to 2: 8-bit auto-reload.
12. The next line of code clears the timer high byte TH0 to 0x00. Single step again.
13. The next line of code clears the timer low byte TL0 to 0x00. Single step again.
14. The next line creates a continuous loop. Single step again.
15. The next line starts the counter by setting the TR0 flag to 1. Single step again.
a. Status should change to Run, indicating that the counter is counting.
b. The timer timing flag, TR0, is checked, which indicates that it is a 1.
c.

TCON also will update to 0x10, which indicates the TCON bit 4 is set to 1, and that indicates
counter 0 is turned on.

16. The next line of code starts a loop that continuously transfers the contents of the counter, TL0, to the
accumulator, ACC, and then from the accumulator to Port 2, P2.
a. This loop will repeat until the counter, TL0, rolls over from 0xFF to 0x00.

95

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

17. Single step repeatedly. You should notice the program pointer remains in the loop, but nothing else
changes. Neither TL0 nor ACC nor P2 indicates any change.
18. Click P3.4 and uncheck the box. TL0 immediately will increment from 0x00 to 0x01.
19. Single step repeatedly. You should notice that both the Accumulator and Port 2 update to the value of
the counter, TL0.
20. Toggle P3.4 by checking and unchecking the box. The counter will update every time P3.4 transitions
from a high to a low, regardless of when the transition occurs.
21. Continue to single step through the program while toggling P3.4.
22. You will notice that TL0 updates and then updates ACC and P2.
23. Once you are satisfied that you understand how the counter is working, manually change the value of
TL0 to 0xFD. Then toggle P3.4 until TL0 equals 0xFF.
24. Toggle P3.4. Notice that the counter finished flag, TF0, sets and TL0 has rolled over to 0x00.
25. Notice that the TF0 flag is equal to 0; hence, the condition of the while statement is now false. The
loop will terminate, and the program pointer should pass to stop the counter by clearing the TR0 flag.
Also, the counter will be prepared again by clearing the TF0 flag.
26. Single step a few more times, and notice that the counter will be enabled again by setting the TR0
flag, and the process will start over again.
27. Repeat this process until you understand how the counter works.
Activity 2: Use the Counter Function to Count and Display Input Pulses
In this activity, you will use a counter to track the number of input pulses provided by an external source.
1. You will use the program you created in Activity 1.
2. Connect the function generator to pin P3.4 using a 330 ohm resistor in series. Make sure you are
connected to the TTL output signal. Set the function generator to provide a square wave output at 1
or 2 Hz.
3. Connect Port 2 to the LED bank.
4. Connect an oscilloscope to Port 3 pin 4, and set the oscilloscope to measure the 1 or 2 Hz pulse
train.
5. Build and save the executable hex code.
6. Establish a connection, download the program, and run the program.
7. You should see the LED bank updating about once or twice per second. The LED bank should count
from 0 to 255 repeatedly.
Activity 3: Use Timer and External Hardware Interrupts

96

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Internal timer interrupts are used to cause periodic actions, such as creating pulses or time-driven events.
External hardware inputs are used to signal events to a microprocessor. In this activity, you will use a
timer to create a continuous 5 kHz signal at Port 1 pin 0 while an external user input signal can be applied
to INT1 at Port 3 pin 2, causing a counter to update. The program will react to the input while continuously
providing the 5 kHz signal.
1. Create a working project by following these steps:
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src, or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

#include <reg51.h>
sbit WAVE5kHZ = P1^0;
sbit EDGE = TCON^0;
short int count = 0;
void timer0setup(int mode, int offset)
{
TMOD = mode;
TH0 = offset; //TH0 = -92
TL0 = offset; //
}
void timer0(void) interrupt 1
{
WAVE5kHZ = ~WAVE5kHZ; //toggle P1.0
}
void external0(void) interrupt 0
{
count++; //count times button pushed
}
void main()
{
timer0setup(0x02, 0xA4);
//0x02 timer 0 mode 2

97

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

//0xA4 100uS/1.085uS = 92, 256-92=164 or 0xA4


EDGE=1;
//enables edge-triggered interrupt
IE = 0x83; //enables interrupts for ext 0 and timer 0
TR0=1;
//start timer 0
P2=0x00;
//initialize port 2
while(1)
{
P2=count;
}

3. Examine the program. A bit variable called WAVE5kHZ represents the value of the 5 kHz signal. A bit
variable called EDGE will allow the TCON register bit 0 to be set to enable an edge-triggered
hardware interrupt. A short integer called count will store the number of times that the external
interrupt is triggered.
4. Function timer0setup will configure the timer to create a 5 kHz waveform. The timer will toggle every
100 microseconds. This represents the half cycle of the waveform. The function timer0(void) interrupt
1 will trigger whenever timer 0 reloads. The function external0(void) interrupt 0 will trigger whenever
an external interrupt INT0 is detected at Port 3 pin 2. (See Table 11-4 on page 340 to review the
interrupt numbers used by C.)
5. Examine the main function. It begins by calling the timer0setup function. This is followed by setting
the TCON.0 bit to 1 (enables an edge-triggered interrupt) and enabling the interrupt enable register IE
(allows both INT0 and TF0 to trigger interrupts). Timer 0 is started, and Port 2 is initialized. Finally, a
continuous loop constantly updates Port 2 with the value of the count.
6. Start Debug and make sure the following windows are open:

Port 1

Port 2

Port 3

Registers

Timer 0

7. Continuously single step through the program by holding the F11 key. Notice that Port 1 pin 0 toggles.
8. Simulate an external input by unchecking (clearing) Port 3 pin 2. Single step the program until the
program pointer completes the external0 function and is returned to the main loop. Notice that Port 2
updates.
9. Practice simulating the program until you understand how the interrupts are triggered and how the
interrupt functions act independently of the main function. Toggle Port 3 pin 2 several more times, and
watch that Port 2 updates as you single step through the program.
10. When you understand how the interrupts are triggered, continue to the next step.
11. Ensure that Port 2 is connected to the LED bank.
12. Connect an oscilloscope probe to Port 1 pin 0 and configure it to measure a 5 kHz signal.

98

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

13. Connect a manual momentary press to make switch and debounce the circuit to Port 3 pin 2 (INT0).

14. Build and save the executable hex code.


15. Establish a connection, download the program, and run the program.
16. Notice that the oscilloscope displays a 5 kHz waveform.
17. Press the SPST push button, and notice that the LED bar updates each time the button is pressed.
Deliverables

Complete the Unit 8 Lab 1 Worksheet (ET2640.U8.HO1)

Due at the end of class

99

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 8 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Develop a C program for a microcontroller application.

Program the 8051 to perform Timer operations with interrupts using the C programming
language.

Program the 8051 to perform external hardware interrupts using the C programming language.

Program the 8051 to perform serial communications with interrupts using the C programming
language.

Configure the IP register to set the priority of specific interrupts.

Configure the IE register to enable a specific interrupt.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective: Explain the purpose of the lab.

Setup: Provide a complete list of all required equipment and materials.

Explanation of Experimental Procedure: Provide a detailed summary of how you performed the
lab.

Conclusions: Provide an analysis of what you learned from the lab.

Deliverables

Completed Unit 8 Lab 1 Report

Typed using word processor software

Due at the beginning of Unit 9

100

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 9 Lab 1: Interfacing and Programming LCDs with the 8051 (Part 1)
Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Program the 8051 to perform I/O operations using the C programming language.

Interface an LCD display to the 8051.

Control an LCD with the 8051 using the C programming language.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Bray Terminal or Tera Term Terminal

MDE 8051 Trainer

Power supply

2 x 16 Dot Matrix LCD Module Datasheet (ET2640.U9.HO2)

2 x 16 Dot Matrix LCD Module

10K Potentiometer

Introduction
Providing user information can be accomplished using several methods. Indicator lights can be used to
provide basic status information; however, this provides very limited information. Using seven-segment
LEDs to display ASCII messages requires significant circuitry for addressing and decoding. For example,
how would you connect 10 seven-segment displays? Serial communications can provide terminal
messages to a computer, but PCs are not always available, cost effective, or practical.
The LCD is more commonly used in todays embedded systems than the LED. Declining prices and ease
of interfacing make LCDs ideal for displaying prices for items in grocery and other retail stores. In contrast
to laptop computers, most embedded systems use a small LCD, such as 20x2 or 40x4 lines, to display
data. In this lab, you will interface an LCD to a microcontroller and program the system to send messages
to the LCD display.

101

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Recommended Procedures
Activity 1: Interface the LCD Display
In this activity, you will examine your LCD module and correctly interface it to the microcontroller.
1. The following image is an example of how the display will appear when in use. Compare your LCD
module to the image. They should be similar (except for the message).

2. The following image is the back of the LCD module.

3. Examine the back of the LCD module. You should see the pin description to the right. Also, pin 1 and
pin 16 should be identified.
4. The pins should be as follows:

102

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

5. Use Table 12-1, Pin Descriptions for LCD, on page 352 to identify the pin descriptions.
a. Remember that to enable pin E requires a High to Low transition.
6. If your module is different from the images, use its datasheet to identify the pin out and the values for
VCC and VSS.
7. Examine the following connection diagram.

8. Notice that:
a. Port 1 is used to provide the data.
b. Port 2 is used to provide the control signals.
c.

VSS is ground.

d. VCC should be 5 VDC.


e. VEE provides background contrast.
f.

Pins 15 and 16 are not required; however, they can be used to apply backlighting.

9. Connect the VCC and VSS. Connect the 10K potentiometer to provide contrast required. Preset the
potentiometer to its center value, 5K ohms.
10. Verify the VCC power supply is set to the correct value (should be 5 VDC), and apply power.
11. If your display shows very dark solid blocks, then VEE is too high; adjust the 10K potentiometer until
the contrast is correct.
12. Remove power.

103

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

13. Connect Port 1 to D4 through D7 to use the 4-bit option. You can connect D0 thru D7; however, the
test program only requires D4 thru D7.
14. Connect Port 2 to RS, R/W, and E.
15. The LCD should be ready to program and use.
Activity 2: Test the LCD Display Program
Once the LCD is properly connected and the contrast is correct, you should use a test program to verify
operation. This activity will display YES on the LCD.
1. Create a working project by following these steps:
a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src, or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug
2. The correct code follows:

#include <reg51.h>
#include <reg51.h>
sfr Port1 = 0x90; //P1=LCD data pins (Fig. 12-2)
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
sbit busy = P1^7;
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void lcdready();
void MSDelay(unsigned int);
void main()
{
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x0F);
lcdcmd(0x38);
lcdcmd(0x85);
lcddata('L');
lcddata('C');
lcddata('D');
lcddata('s');

//clear LCD display


//cursor to home
//display & cursor on, blinking
//8-bit, 2-line, 5x10 matrix
//line 1, position 5

104

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

lcddata('!');
while(1); //do it once and stop
}
//functions on next page

void lcdcmd(unsigned char value)


{
lcdready(); //check the LCD busy flag
Port1 = value; //put the value on the pins
rs = 0;
rw = 0;
en = 1; //strobe the enable pin
MSDelay(1);
en = 0;
return;
}
void lcddata(unsigned char value)
{
lcdready(); //check the LCD busy flag
Port1 = value; //put the value on the pins
rs = 1;
rw = 0;
en = 1; //strobe the enable pin
MSDelay(1);
en = 0;
return;
}
void lcdready()
{
busy = 1; //make the busy pin an input
rs = 0;
rw = 1;
while(busy==1) //wait here for busy flag
{
en = 0; //strobe the enable pin
MSDelay(1);
en = 1;
}
return;
}
void MSDelay(unsigned int milliseconds)
{//each loop is 1 millisecond
unsigned int i;
for (i=1;i<=milliseconds;i++)
{
TMOD=0x10;//1 millisecond

105

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

TH1=0xFC;
TL1=0x67;
TR1=1;
while (TF1==0);
TR1=0;
TF1=0;
}

3. Notice:
a. Port1 points to the address of Port 1.
b. Command bits RS, RW, and E are assigned to Port 2 bits 0, 1, and 2.
c.

Notice the lcdcmd4 values passed to the function; use the text to determine the purpose of
each command.

d. Function lcdcmd configures the command bits and assigns data to Port1.
e. Function lcddata configures the command bits and assigns data to Port1.
4. Build and start Debug, and make sure the following windows are open:

Port 2

Port 3

Registers

Memory 1, set to D:0x90 to view the contents of Port 1 and Port 2

5. Single step through the program by holding the F11 key and notice:
a. The enable signal must toggle from high to low with a small delay to latch the data into the
LCD module.
b. The MSDelay value will cause a specific number of milliseconds to be used.
c.

When entering the MSDelay function, save time by pressing ctrll-F11 to step out of the
function.

6. Single step through the program repeatedly until you understand the purpose of each command and
can explain how the data port is used to cycle instructions and data to the LCD module.
Activity 3: Program the LCD Module
In this activity, you will download the previous program and examine the function of the LCD module.
1. You will use the program you created in Activity 2.
2. Build and save the executable hex code.
3. Establish a connection, download the program, and run the program.
4. You should see the LCD module display the message LCDs!

106

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Activity 4: Modify and Improve the LCD Program


Use the information in Activities 1 through 3 to modify the displayed message. Save each version of the
following programs for reference.
1. Change the message to something more complex. Think about using an array and string messages.
2. Change the program to start the message at different locations on the line, on other lines, or on
multiple lines.
Deliverables

Complete the Unit 9 Lab 1 Worksheet (ET2640.U9.HO1)

Due at the end of class

107

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 9 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Program the 8051 to perform I/O operations using the C programming language.

Interface an LCD display to the 8051.

Control an LCD with the 8051 using the C programming language.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective: Explain the purpose of the lab.

Setup: Provide a complete list of all required equipment and materials.

Explanation of Experimental Procedure: Provide a detailed summary of how you performed the
lab.

Conclusions: Provide an analysis of what you learned from the lab.

Deliverables

Completed Unit 9 Lab 1 Report

Typed using word processor software

Due at the beginning of Unit 10

108

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 10 Lab 1: Interfacing with A/D and D/A Converters (Part 1)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Interface an ADC to the 8051.

Control an ADC with the 8051 using the C programming language.

Explain how to interface sensors to the 8051.

Required Setup and Resources

PC with Windows 7, 32-bit/64-bit version

Keil Vision 4.22 software

Bray Terminal or Tera Term Terminal

MDE 8051 Trainer

Power supply

Function Generator

Oscilloscope

ADC0809

ADC0808/0809 Data Sheet (ET2640.U10.HO3)

1k ohm resistor

10K Potentiometer

LM34 or LM35

LM34 or LM35 Data Sheet (ET2640.U10.HO4)

Introduction
Real-world physical quantities, such as temperature, pressure, and moisture, are analog in nature. A wide
variety of sensors exist to convert these natural quantities to analog signals. To use a microcontroller to
monitor and control processes, the signals fed into it need to be converted from analog to digital (binary).
The use of an ADC (analog-to-digital converter) for digitizing natural quantities is the first step in the field
of data acquisition and control.
In this lab, you will interface an ADC and sensors to the microcontroller. These sensors will provide an
analog input to the ADC; the input will be digitized and displayed on the LED bank.

109

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Reference the ADC0808/0809 Data Sheet (ET2640.U10.HO3) and LM34 or LM35 Data Sheet
(ET2640.U10.HO4) as needed while performing the lab.

110

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Recommended Procedures
Activity 1: Interface an ADC 0808/09 to the 8051
1. In this activity, you will examine the datasheet for the ADC0808/09 and correctly interface it to the
microcontroller.
2. Obtain a datasheet of the ADC0808/09 Analog to Digital Converter for reference.
3. Examine Figure 10-1. You will apply an adjustable DC level to the ADC Input Channel 1. The
ADC808/809 is a single chip that can accommodate up to eight analog inputs. These eight inputs are
called channels, and each is selected by an address.
4. A 5V reference is applied to ensure the correct step sizesee page 380 for the reason. This will
provide an output of 0x00 with a 0 V input and 0xFF with a 5 V input.
5. The 8051 Port 2 provides the addressing and control signals. To understand the function of the
control signals, review the ADC0808/09 datasheet.
6. The 8051 Port 1 will receive the digital signal from the ADC.
7. The 8051 Port 3 will output the signal to the LED bank.
8. The ADC requires a clock pulse.

Figure 10-1
9. Set the function generators TTL/CMOS output to 5 V at 25 kHz. Use the oscilloscope to verify the
waveform, set to DC coupling, to ensure no negative (destructive) voltages are sent to the trainer.
Give the function generator time to stabilize. Do not connect the function generator signal to the ADC
input until power has been applied to the circuit.

111

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

10. Build the circuit indicated in Figure 10-1.


11. Set the potentiometer to the 5K-ohm position (midpoint).
12. Make sure the 8051 trainer is in Program mode (the switch is not in RUN mode).
13. Apply power to the circuit, and connect the function generators TTL/CMOS squareware output
through a 1 k ohm resistor to the ADC clock input. The 1K-ohm resistor in series between the
generator and chip will help prevent accidental destruction! Make sure the clock is a TTL/CMOS 5 V
signal at 25 kHz.
Activity 2: Test the ADC Program and ADC Circuit
Once you have built the ADC circuit, a program must send control signals to the ADC. The control signals
will define the ADC Input Channel and will create the beginning of scan and end of scan timing. You will
apply an adjustable DC level to the ADC, which will be converted to a binary signal and displayed on the
LED bank.
1. To correctly program the ADC0808/09, you must complete the following steps:
a. Select an analog channel by providing bits to A, B, and C (see Table 13-3, page 380).
b. Activate the ALE (address latch enable) pin. It needs an L-to-H pulse to latch in the address.
The minimum pulse width for ALE = 200 sec and OE = 250 sec.
c.

See Figure 13-6 on page 381 to understand the required timing.

d. Activate SC (start conversion) by an L-to-H pulse to initiate conversion.


e. Monitor EOC (end of conversion) to see whether conversion is finished. H-to-L output
indicates that the data is converted and is ready to be picked up. If we do not use EOC, we
can read the converted digital data after a brief time delay. The delay size depends on the
speed of the external clock we connect to the CLK pin.
f.

Activate OE (output enable) to read data out of the ADC chip. An L-to-H pulse to the OE pin
will bring digital data out of the chip.

2. Create a working project by following these steps.


a. Create New Project
b. Select Processor Dallas DS89C450 (do not copy startup code)
c.

Create New Source Code File (name as .a51, .src, or .c)

d. Write Source Code


e. Add File to Source Group
f.

Add Files to Source Group (to set speed to 11.0592 and to set output to Hex)

g. Build All Target Files


h. Start Debug

112

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

3. The correct code follows:

#include <reg51.h>
sbit ADDR_A = P2^0;
sbit ADDR_B = P2^1;
sbit ADDR_C = P2^2;
sbit ALE = P2^4;
sbit OE = P2^5;
sbit SC = P2^6;
sbit EOC = P2^7;
sfr Port1_IN = 0x90; //Port 1
sfr Port3_OUT = 0xB0; //Port 3
void MSDelay(unsigned int);
void main()
{
//Initial Conditions
Port1_IN = 0xFF; //make P1 an input
EOC = 1; //make EOC an input
ALE = 0; //clear ALE
OE = 0; //clear OE
SC = 0; //clear SC
while(1)
{
ADDR_C = 0; //C=0
ADDR_B = 0; //B=0
ADDR_A = 1; //A=1 (Select Channel 1)
MSDelay(1); //delay for fast DS89C4x0
ALE = 1;
MSDelay(1);
SC = 1;
MSDelay(1);
ALE = 0;
SC = 0; //start conversion
while(EOC==1); //wait for data conversion
while(EOC==0);
OE = 1; //enable RD
MSDelay(1);
Port3_OUT = Port1_IN; //get the data
OE = 0; //disable RD for next round
}
}

//MSDelay- millisecond delay function on next page

113

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

void MSDelay(unsigned int milliseconds)


{//each loop is 1 millisecond
unsigned int i;
for (i=1;i<=milliseconds;i++)
{
TMOD=0x10;//1 millisecond
TH1=0xFC;
TL1=0x67;
TR1=1;
while (TF1==0);
TR1=0;
TF1=0;
}
}

4. Notice:
a. The command bits are assigned to Port 2 bits.
b. Port 1 and Port 3 are defined as DATA_IN and DATA_OUT.
c.

The MSDelay function will delay in milliseconds (approximately). If you want a 1 millisecond
delay, enter MSDelay(1); if you want a 100 millisecond delay, enter MSDelay(100).

5. Examine the program, and identify where each of the following steps were implemented.

Initial conditions are set.

The analog input channel is programmed.

ALE is activated, L-to-H; the delay is 1 millisecond.

SC is activated, L-to-H; the delay is 1 millisecond.

EOC is monitored. While high, the conversion is in progress. When low, it is ready to be

latched into the output buffer. When it toggles high again, it is ready to output.

OE is activated; L-to-H pulse to the OE pin will bring digital data out of the chip.

6. Build and start Debug and make sure the following windows are open:

Port 1

Port 2

Port 3

Registers

Memory 1 set to D0x90 to view the contents of Port 1, Port 2, and Port 3.

7. Single step through the program by pressing the F11 key.


8. After DATA_IN is initially set to 0xFF, manually change the value of Port 1 to 0x55.
9. When entering the MSDelay function, save time by pressing cntl-F11 to step out of the function.
10. You will need to change EOC signal at Port 2.7; Port 3 should update to the value at Port 1.
11. Single step through the program repeatedly until you understand the purpose of each command and
can explain how the input signal is converted to a binary signal displayed on the LED bank.

114

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

12. Establish a connection, download the program, and run the program.
a. Note: Port 3 also interfaces with the MAX232 serial controller. If you cannot establish serial
communications, disconnect the LED bank from Port 3 until the program is downloaded to the
processor. You can then reconnect the LED bank.
13. The LED bank should illuminate. As the 10K pot is adjusted, the LED bank should track. As the
voltage into the ADC increases, the binary value should increase; as the voltage into the ADC
decreases, the binary value should decrease.
Activity 3: Use the LM34/35 Temperature Sensor with the ADC
In this activity, you will connect the LM34/35 Celsius temperature sensor to the ADC channel 1.
1. Obtain the datasheet for the LM34/35 sensor, and verify the sensors range (-55 to 150C). The sensor
changes 10 mv for every degree of temperature change, with its maximum output at 2.56 V.
2. Remove power from the circuit, and replace the potentiometer with the sensor, per Figure 10-2. Use the
LM34/35s datasheet to determine proper connections.
3. Change the Vref+ signal from 5 VDC to 2.56 VDC to scale the ADC output from 0x00 with a 0 V input and
0xFF with a 5 V input.
4. Nothing else should change.

Figure 10-2
5. You will use the program you created in Activity 2.

115

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

6. Reapply power and you should see the LED bar illuminate.
7. Use a cup of ice to cool the sensor; the LED bar should indicate a smaller binary number. Use a heat gun
or soldering iron (apply quickly to prevent damage) to heat the sensor; the output should increase.
Deliverables

Complete the Unit 10 Lab 1 Worksheet (ET2640.U10.HO1)

Due at the end of class

116

04/19/2012

Microprocessors and Microcontrollers

GRADED ASSIGNMENTS

Unit 10 Lab 2: Report (Part 2)


Course Objectives and Learning Outcomes

Examine fundamental processor I/O interfacing methods.

Use simulation and debugging techniques to verify that software is operational.

Demonstrate the ability to use oscilloscopes, other test equipment, and external inputs for
troubleshooting and verification purposes.

Program the 8051 to perform I/O operations using the C programming language.

Interface an ADC to the 8051.

Control an ADC with the 8051 using the C programming language.

Required Setup and Resources

None

Recommended Procedures
Write a lab report that contains each of the following topics:

Objective: Explain the purpose of the lab.

Setup: Provide a complete list of all required equipment and materials.

Explanation of Experimental Procedure: Provide a detailed summary of how you performed the
lab.

Conclusions: Provide an analysis of what you learned from the lab.

Deliverables

Completed Unit 10 Lab 1 Report

Typed using word processor software

Due at the beginning of Unit 11

117

04/19/2012

Das könnte Ihnen auch gefallen