You are on page 1of 21

CSCC85 Summer 2004

Chapter 1 Introduction to Microcontrollers

What are microcontrollers?


Central component in many industrial, automotive, and consumer products. Perform 'control' functions by interfacing with the 'real world' to turn devices on and off and to monitor conditions.

Background & Terminology


Computer
Able to run a program that operates on data. Able to store and retrieve data.

Computer System
Includes peripheral devices for communicating with people, as well as programs that process data. Hardware (equipment) Software (program)
3

Computer System Components


Address bus (16 lines) Data bus (8 lines)

CPU

Control bus (6 lines)

RAM

ROM

Interface Circuitry

Peripheral Devices

Figure 1-2 Block diagram of a microcomputer system

Central Processing Unit (CPU)


Registers Program Counter (PC) Instruction Register

Arithmetic and logic unit (ALU)

Instruction decode and control unit

Figure 1-3 Simplified view of the inside of CPU

Fetch Cycle
CPU

1 3

5
N Program counter

Address bus Data bus


RAM

4
Opcode Instruction register Control bus Clock Read

Opcode

N+2 N+1 N N-1 N-2

2
FIGURE 1-4 Bus activity for an opcode fetch cycle

Buses: Address, Data & Control


A bus is a collection of wires carrying information with a common purpose. Used to interconnect the various units of a computer (ie. CPU, memory, I/O, etc) Impractical to use a different set of wires for every electronic unit (too many wires needed) Usually one bus is used by many units using a Time Domain Multiplexing (TDM) scheme
7

Buses: Address, Data & Control con't


Output Unit
Central Processing Unit

Bus

Input Unit

Memory Unit

Single bus structure has the advantage of simplicity and low cost. Disadvantage is limited speed because only two units may use the bus at any given time. (Units are forced to contend for the one bus, waiting for their turn.)

FIGURE 1-5 Single bus architecture

Buses: Address, Data & Control con't


Access to the circuitry around the CPU is provided by three buses:
Address bus Data bus Control bus

An n-bit bus can access 2n locations Multi-bus architectures are used in large computers to increase speed.
9

Buses: Address, Data & Control con't


8051 uses a multi-bus architecture called Harvard architecture Separate memories with their own address and data buses are maintained for code (programs) and data This allows two parallel streams of programs and data to be maintained without the use of TDM Many 2-byte instructions now take only one machine cycle
10

Microprocessors vs. microcontrollers Hardware Architecture


Microprocessors
CPU (single IC chip) Requires additional components to be useful

Microcontrollers
Single IC chip that contains a CPU, memory, serial interface, parallel interface, timers, I/O handling 'computer on a chip' Permanently programmed for one task
11

Computer System Components


External clocks Internal clocks
Interrupt Control Serial interface Parallel interface

External interrupts

Serial device

Parallel device

Timers

CPU

Address, data and control buses

RAM
Figure 1-6 Detailed block diagram of a microcomputer system

ROM

12

processor vs. controller Applications


controllers are used to 'control' I/O devices in designs requiring a minimum component count.

' process' information processors in are u computer systems.

13

processor vs. controller Instruction Set Features


processor instruction sets have powerful addressing modes with instructions that operate on large volumes of data. Arrays of data, using address pointers and offsets. auto-increment/decrement modes to step through arrays on byte, word, or double word boundaries. controller Instruction sets cater to the control of inputs and outputs. Instructions are able to operate on individual bits Instructions are available for input/output operations, event timing, enabling and setting priority levels for interrupts. Instructions are extremely compact; most implemented in a single byte

14

Microcontroller pros & cons


Advantages Designs are implemented with fewer components Usually results in shorter development time, lower manufacturing cost, lower power consumption, higher reliability Changes in design can be implemented by modifying only the software, minimizing impact on the manufacturing cycle Disadvantages Slower than its discrete counterparts Extremely fast response to events handled poorly
15

NAND Gate example


8051 assembly language program:
LOOP: MOV ANL ANL CPL MOV SJMP C,P1.4 C,P1.5 C,P1.6 C P1.7,C LOOP ;READ P1.4 BIT INTO CARRY FLAG ;AND WITH P1.5 ;AND WITH P1.6 ;CONVERT TO NAND RESULT ;SEND TO P1.7 OUTPUT BIT ;REPEAT

8051
P1.4 P1.5 P1.6

P1.7

Microcontroller implementation of a simple logic operation

Propagation delay is between 3 to 17 microseconds. Equivalent TTL propagation delay is approx. 10 nanoseconds. In many applications with human operation, the difference is not noticeable.

16

CSCC85 Summer 2004

Chapter 2 8051 Hardware Summary

17

The 8051 Microprocessor Features


4K bytes ROM (factory mask programmed) 128 bytes RAM Four 8-bit I/O ports Two 16-bit timers Serial interface 64K external code memory space 64K external data memory space Boolean processor (operates on single bits) 210 bit-addressable locations 4s multiply/divide 18

8051 block diagram


INT1
* *

INT0

Timer 1 Timer 0 Serial port 4K ROM Interrupt control Other registers 128 bytes RAM Timer 1 Timer 0 T1 * T0 *

CPU

Oscillator

Bus control

I/O ports

Serial port

EA RST

ALE PSEN

P0

P1

P2

P3

TXD*

RXD*

19

Address/data

Memory Organization
The 8051 has three general types of memory: On-Chip Memory refers to any memory (Code, RAM, or other) that physically exists on the microcontroller itself. Also called Internal Memory. External Code Memory is code (or program) memory that resides off-chip. This is often in the form of an external EPROM. External RAM is RAM memory that resides off-chip. This is often in the form of standard static RAM.
20

8051 Memory Spaces


8051
FFFF

External code memory


0000

Enabled via
PSEN

FF

FFFF

On-chip memory
00 0000

External data memory

Enabled via
RD and WR

21

You might also like