You are on page 1of 39

ECE-362 Microprocessor Systems and Interfacing

Dr. Abdelrahman Abdelazim


1

Module 1 Microcontroller Programming Techniques

Module 1
Learning Outcome: An ability to program a microcontroller to perform various tasks
A. Microcontroller Architecture and Programming Model B. Microcontroller Instruction Set Overview C. Assembly Language Programming Techniques Control Structures

Module 1
D. Assembly Language Programming Techniques Control Structure Applications E. Assembly Language Programming Techniques Parameter Passing

Module 1-A Microcontroller Architecture and Programming Model

Reading Assignment: Lecture Note Week 1


Learning Objectives: List differences in world views regarding the role of microprocessors Define characteristics that distinguish microprocessors Describe the PIC16F87XA architecture and programming model

Reading Assignment: Lecture Note Week 1


Learning Objectives: List differences in world views regarding the role of microprocessors Define characteristics that distinguish microprocessors Describe the PIC16F87XA architecture and programming model

Outline
Characteristics that distinguish microprocessors Taxonomy of microprocessors from an application viewpoint Basic architecture of the PIC16F877A Instruction formats and data types of the PIC16F877A

Introduction
Two basic world views regarding the role of microprocessors are applicable
general-purpose view :a microprocessor is an integral part of a machine that runs shrink-wrapped software (or on which user-programmed applications can be shrinkwrapped software (or on which user-programmed applications can be developed and run) user programmable embedded view : a microprocessor is a basic digital system building block that can be used to build intelligent products non-user-programmable
9

Introduction
Why this distinction is important:
different architectural/organizational characteristics of

microprocessors can make them more/less suited for a given application the goodness or badness of a particular microprocessor can only be evaluated in the context of the intended application

10

Microprocessor Control Systems


Digital control systems are designed to allow a particular set of logical operations to be carried out. Digital electronic circuits, using logic gates, can be used to control many devices.

Next >

Hardwired Systems
Systems using logic gates are simple to design and are cheap and easy to assemble in circuits. Individual chips can be interconnected to provide complex control functions.
For example, D-type latches on their own are limited in their capabilities, but with other identical chips can be made to produce binary counters, shift registers and latches. Drawback is that once a system is designed and manufactured, it cannot be changed without redesigning the hardware used.

This type of circuit is known as Hardwired. Hardwired systems can be made either by using individual components (Integrated Circuits or ICs) on a Printed Circuit Board (PCB) or produced directly in a customised IC.
Next >

Software Controlled Systems


Software Controlled system can have its function changed without altering the hardware. Achieved by a microprocessor system, which can be programmed and re-programmed to perform different functions.

For example: A microprocessor system can be programmed to perform exactly the same functions as a number of D-type latches (binary counter, shift register or latch). Modifications can be made without altering the physical configuration or layout of the circuit. The system is therefore more versatile and can be modified to be used in a number of different applications.
Next >

Microprocessor Control Systems


Consider a customer buying a cup of coffee from a vending machine. The customer pays, chooses the type of drink and places an empty cup underneath the dispenser.

The machine detects the cup and fills it with coffee, dispensing the exact amount to fill the cup. This ensures that the cup is not overfilled and that deliberate attempts to fill larger cups are prevented.

Next >

Hardwired & Software Controlled System


Consider that the manufacturer of the vending machine has decided that the cup size being used is too small. All the vending machines need to be updated to use the new size cups.

If a hardwired design had been used, replacement or modification of the hardware in each machine would be required. This would be expensive.

If the machines are software controlled, the software could simply be replaced or modified at minimal cost.
Next >

Hardwired & Software Controlled System


Below is a list of advantages and disadvantages of hardwired systems:

Simple to make, quickly and cheaply. Relatively easy to understand and gives a predicable output.

Hardwired systems usually have faster speeds of operation than


software controlled systems.

Hardwired systems cannot easily be upgraded or modified without


changing components.

Next >

Hardwired & Software Controlled System


Below is a list of advantages and disadvantages of software controlled systems:

Versatile and can be used in a number of different applications. Function can be modified by changing its program code in situ. Can be more expensive to produce than hardwired systems
for simple projects.

Can contain errors (bugs) which cause unpredictable results. Require greater amounts of testing due to the added complexity
of the system.

Next >

Question

Which of the following is a disadvantage of hardwired systems?

A) Speed is slower than software systems B) Expensive to make C) Difficult to change function D) Slow to assemble

Question

Which of the following is an advantage of software based control systems?

A) Versatile
B) Less expensive to produce than hardwired systems C) Does not require extensive testing D) Works reliably first time

Structure of a Microprocessor System


This diagram represents a very simple microprocessor system.

As you can see, this is similar to the simple Input - Process - Output system diagram:

Next >

Structure of a Microprocessor System


Microprocessor systems have the ability to connect to several input and output devices at the same time.
Inputs might include: mouse, keyboard, scanner. Outputs might include: screen, loudspeaker, printer. Some devices that are plugged into computers are both inputs and outputs: a modem for example both transmits and receives data. Some of these input and output devices are built into the system. Others have to be plugged in to the system. Where an input or output device is plugged in, it is accessed by the computer through a port.

There are several different types of port. Some transmit data serially while others transmit data in parallel, for example, RS232 (serial), Centronics (parallel), USB (Serial).
Next >

Structure of a Microprocessor System


The processor connects to several input and output ports, as well as memory, at the same time.

This requires a more complex connection system. The processor needs to be able to select which sub-system it needs to talk to, decide whether it is sending or receiving, and then send or receive data.

Next >

Structure of a Microprocessor System


The connection system uses three buses. The address bus goes from the CPU to the memory and input / output ports.
Each sub-system that the CPU connects to has a unique address. The CPU sends the address on the address bus to identify the subsystem it needs to connect to. The control bus determines whether the data is to be sent or received. The data can then be transmitted along the data bus. A bus is just one or more conductors connecting the sub-systems together.

Next >

Question

Which connection system carries the signal that determines whether data is to be written to or read from, memory?

A) Address bus B) Serial Port C) Control bus D) Data bus

Single Chip Microprocessor Systems


A microcontroller is a single IC containing a central processing unit, memory, input / output ports and internal clock. Microcontrollers provide a onechip design instead of requiring several separate components. Microcontrollers are used in domestic appliances, automobiles, electronic locks, security devices, smart cards, timers, and serial communication.

Next >

Microcontrollers - PICs
In the 1980s Arizona Microchip Inc. produced a simple microcontroller that they called the Peripheral Interface Controller, or PIC.

Originally it was little used but in the early 1990s Arizona Microchip released the 16C5X series PIC. These new devices were astonishingly fast, efficient and easy for engineers to understand and program. They were also inexpensive, readily available and obtainable in a wide range of different designs.

PICs are now among the most widely used microcontrollers in the world, with billions having been sold.
Next >

Question

What do the initials PIC stand for?

A) Peripheral Intelligent Connector B) Peripheral Interface Connector

C) Peripheral Interface Controller


D) Peripheral Intelligent Connector

Question

Approximately, when did PIC use increase dramatically?

A) 2000 - 2003 B) 1997 - 2000

C) 1995 - 1997
D) 1990 - 1995

Microprocessor Architectures
Two types of architectures used in modern processors. Von Neumann architecture used in the Z80 to the modern Pentium chips.

Von Neumann system stores data and program code together in one memory space. Disadvantage of only allowing the CPU to access either data or the program memory at any one time.
PIC devices use the Harvard architecture. Differs from the Von Neumann type by having separate memories for program code and data, so can be accessed independently and simultaneously. Advantage of the Harvard architecture is that it reduces the time taken to retrieve the instructions, and so is more efficient.

Next >

Question

What is the name of the architecture used in PICs?

A) Z80 B) Harvard

C) Von Neumann
D) Pentium

Question

Which architecture system stores program code and memory code in different locations?

A) Harvard B) Von Neumann C) Z80

D) Pentium

Question

Which is the more efficient architecture for microcontrollers?

A) Von Neumann B) Pentium C) Z80

D) Harvard

Instruction Sets
Language used by the microcontroller is divided into a number of instructions.

This list of instructions is called the instruction set.


The Instruction Set determines what functions the microcontroller can perform and how instructions need to be written. Architecture of microcontrollers may be further classified into the types of instruction sets they use.

Next >

Question

In order to get a microcontroller to do something, what must we give it?

A) A notice B) An instruction C) A message D) A function

Instruction Sets
CISC (Complex Instruction Set Computer) Microcontrollers and microprocessor systems which use CISC systems, have a large quantity of very detailed instructions.

RISC (Reduced Instruction Set Computer) A reduced instruction set is made up of a small number of key instructions. PICs use this type of instruction set and have about 35 instructions.

Next >

Question

10

CISCs have a large number of detailed instructions. Is this true or false?

Answer True or False.

Question

11

Approximately how many instructions can a PIC chip programmed using RISC understand?

Social and Economical Benefits


Microcontrollers have many advantages over microcomputers, primarily because of the reduction in external components. This provides the following benefits:

Reduction in costs - smaller number of components required. Increased system reliability - fewer components mean a smaller
likelihood of the system failing.

Reduced power consumption - fewer components mean less power


required for the system.

Reduced Electromagnetic emissions - having fewer components


reduces the electromagnetic emissions produced by a device.

Program Code can be upgraded, in situ, - programs can be written to


the PIC while in a system.

Size - the small size of a microcontroller enables it to be used


in small devices.
Next >

Question

12

A microcontroller has one main advantage over a microcomputer, which gives rise to many benefits. What is it?

A) Increased reliability
B) Reduced costs C) Increased portability D) Reduced number of components

You might also like