Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 41

Chapter 2

Embedded Microcontroller Systems

Dr. Dereje Shiferaw Negash, AAIT


Contents
• Microcomputer system
– CPU
– Buses
– Memory
• Microcontroller basics
• Family of microcontrollers
– 8051 family
– PIC family

Dr. Dereje Shiferaw Negash, AAIT


Microcomputer system
• Microcomputer is a single microprocessor or
microcontroller based computer
• Contains three basic parts
– CPU
– Memory
– I/O

Dr. Dereje Shiferaw Negash, AAIT


Microcomputer system
A Simple Computer consists of a Processor (CPU-
Central Processing Unit), Memory, and I/O
Arithmetic
Logic
Unit
Input

Control
Unit Memory

Registers Output

Processor I/O
Or CPU Dr. Dereje Shiferaw Negash, AAIT
Microcomputer system
Basic functions of parts of microcomputer system
• Input – accepts coded information from human
operators, from electromechanical devices (such as
keyboards), or from other digital medium via digital
communication lines.
• The information received is either stored in the
memory or immediately used by the arithmetic and
logic unit (ALU) to perform the desired operations.
• The results are sent back out through the output
medium.
• All actions are coordinated through the control unit.

Dr. Dereje Shiferaw Negash, AAIT


Microcomputer system
• Information organization
– Categorized as either instructions or data
– Instructions (or machine instructions) are explicit
commands that
• Govern the transfer of information within a computer
as well as between the computer and its I/O devices.
• Specify the arithmetic and logic operations to be
performed.

Dr. Dereje Shiferaw Negash, AAIT


Microcomputer systems
• Programs
– A list of instructions that performs a task is called a
program.
– Usually the program is stored in memory.
– The program fetches the instructions from memory,
one after another, and performs the desired
operations.
– The computer is completely controlled by the stored
program, except for possible interruption by an
operator or by I/O devices connected to the machine.
– Data are numbers and encoded characters that are
used as operands by the instructions.

Dr. Dereje Shiferaw Negash, AAIT


Micro Computer System Organization

Dr. Dereje Shiferaw Negash, AAIT


Inside the CPU
• Control Unit (CU)
coordinates the sequencing of steps involved
in executing machine instructions
• Arithmetic Logic Unit (ALU)
performs arithmetic and logical operations
• Registers
storage locations
• Clock
synchronizes the internal operations of the
CPU with the other system components

Dr. Dereje Shiferaw Negash, AAIT


Bus Structure
• Bus - a group of parallel wires that transfer
information from one part of the computer to
another.
– Control Bus
synchronizes the actions of all of the
devices attached to the system bus.
– Address Bus
passes the addresses of instructions and
data between the CPU and memory (or I/O).
– Data Bus
transfers instructions and data between the
CPU and memory (or I/O).

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller
• Definition
– Integrated electronic computing device that includes three
major components on a single chip
• Microprocessor (MPU)
• Memory
• I/O (Input/Output) ports
• it also includes support devices
– Timers
– ADC and DAC controllers
– Serial I/O
• Common communication line
Dr. Dereje Shiferaw Negash, AAIT
Microcontroller basics
• Block diagram of a microcontroller system

Dr. Dereje Shiferaw Negash, AAIT


General architecture of microcontroller
• A typical microcontroller consists of
– CPU from 4bit to 64 bit
– RAM for data storage
– ROM, EPROM or EEPROM or flash memory for
program storage
– Timers and counters
– Serial input and output ports
– ADC and DAC
– Clock
– Data bus
Dr. Dereje Shiferaw Negash, AAIT
General architecture of microcontroller

Dr. Dereje Shiferaw Negash, AAIT


Types of microcontrollers

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller basics
• First developed in 1970s by Intel as 4bit device
but after that many developments have taken
4 bit (2300 PMOS
Intel 4004 1971
trans, 108 kHz)
Intel 8048 8 bit 1976
Intel 8031 8 bit (ROM-less) .
Intel 8051 8 bit (Mask ROM) 1980
Microchip PIC16C64 8 bit 1985
Motorola 68HC11 8 bit (on chip ADC) .
Intel 80C196 16 bit 1982

Atmel AT89C51 8 bit (Flash memory) .

8 bit (Flash memory +


Microchip PIC 16F877 .
ADC)
Dr. Dereje Shiferaw Negash, AAIT
Microcontroller basics
• The most famous type of microcontroller is 8051
• Architecture
– 3 system inputs
• Vcc power supply and ground
• Clock inputs (XTAL 1 and XTAL 2)
• Reset
– 3 control signals
• EA (External Access)
• PSEN (program store enable)
• ALE (Address latch enable)
– 4 ports
• Port 0, port 1, port 2 and port 3
• Each 8 bit is programmable for I/O
• Used to connect ADC, DAC, LED, 7 segment display etc
Dr. Dereje Shiferaw Negash, AAIT
Microcontroller basics 8051 family
• The microcontroller usually referred as 8051
has many variants from different
manufacturers

Dr. Dereje Shiferaw Negash, AAIT


Dr. Dereje Shiferaw Negash, AAIT
Microcontroller basics
• Connection for standalone operation

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller 8051
• Pin configuration
– 8051 uc has 40 pins
– Is the functional assignment of pins of a
microcontroller
– Some pins are dedicated pins, i.e used for one
purpose and others are multiplexed (used for
multiple functions)
– It can be used as a 4 i/o port standalone processor
without external memory or can be used with 16
bit address line for external memory and 8 bit data
line for external data access
Dr. Dereje Shiferaw Negash, AAIT
Microcontroller basics 8051

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller basics 8051
• Pin 1-8 is port 1: dedicated port with internal pull up resistors
and quasi-bidirectional
• Pin 9 is reset
• Pin 10-17 is port 3 and it also serves for other functions
– Receive, transmit, interrupt 1 and 2, timer 1 and 2, write enable and
read enable
– When used as port 3, it is quasi bidirectional and has internal pull up
resistor
• Pin 18 and 19 crystal oscillator connector for clock
• Pin 20 is Vss ground
• Pin 21-28 is port 2, quasi bidirectional port and higher order
address lines (A8-A15)
• Pin 29/30/31 are control lines
• Pin 31-39 is port 0 which is true bidirectional port and needs
external pull up resistors. It is also used as Address and data bus
Dr. Dereje Shiferaw Negash, AAIT
for external memory interfacing
Microcontroller basics
• Memory organization
– 8051 as it is built on Harvard architecture, has two
memory blocks
• Program memory and data memory
– In program memory, 8051 has two options
• Use of internal memory with external memory
interfacing , in this case pin 31 is connected to Vcc
• Use of external memory only, for this case pin 31 is
connected to ground
• Total memory capacity of 8051 is 64kbyte with internal
memory of 4Kbyte

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller basics 8051

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller basics 8051
• Memory organization
– Data memory
• This is the area used to store data to be used in a program
• Has 128 byte internal memory and is capable of interfacing
external memory
• The 128 byte internal memory is divided into three parts
– Register banks (bank #0,#1, #2, #3)
– Bit addressable area (used to store bit values such as status of
motors, LEDS etc )
– General purpose storage area
• Special function registers (80-FF0) is used for
– Instruction register
– Data pointer
– Stack pointer
– PSW, timers, IODr.ports, ACC and
Dereje Shiferaw BAAIT
Negash, registers
Dr. Dereje Shiferaw Negash, AAIT
Microcontroller basics 8051
• Clock connection
– For 8051 microcontroller operation, one of the
external inputs needed is the clock.
– There are three variations for this

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller basics 8051
• A machine cycle in 8051 contains six states or
12 clock cycles

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller basics 8051
• Reset operation
– The other external input in 8051 is the reset input
– It is activated by making pin 9 high
– When reset occurs
• Program counter is cleared
• Register bank 0 is selected
• Stack pointer is initialized to 07H
• All ports are written with FFh

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller basics 8051

Dr. Dereje Shiferaw Negash, AAIT


Microcontroller basics 8051
• Instruction set
– Has more than 110 instructions
– Can be grouped into 5 categories
– These are
• Arithmetic instructions
• Logical instructions
• Data transfer instructions
• Bit manipulation instructions
• Program branching and control

Dr. Dereje Shiferaw Negash, AAIT


8051 INSTRUCTION SET
Arithmetic logical Data transfer Bit Program
manipulation control
ADD, ADDC, ANL,ORL, MOV, MOVX, CLR, SETB, CPL, ACALL, LCALL,
SUBB, INC, XRL,CLR,CPL,RL MOVC, PUSH, ANL, ORL, RET, RETI,
DEC, MUL, DIV, ,RLC,RR,RRC,S POP, XCH, MOV, JC, JNC, AJMP, LJMP,
DA WAP XCHD JB, JNB, JBC SJMP, JMP, JZ,
JNZ, CJNE,
DJNC, NOP

Dr. Dereje Shiferaw Negash, AAIT


8051 Addressing modes
• An instruction consists of an op code and
operand

• Addressing mode is the way the operand is


specified in an instruction
Dr. Dereje Shiferaw Negash, AAIT
Addressing modes
• Immediate addressing
– MOV A, #09h
– MOV 52H, #3Ah
• Direct addressing
– MOV A,03h
– MOV 24h, A
– MOV 7Ch, 0Fh
– PUSH 49h
– POP 22h
• Register addressing
– MOV A, R3
– MOV R1,A
• Indirect addressing
– Can be performed in four different ways
• Using R0 and R1 of each bank
• Using DPTR and Acc
• Using PC and ACC
Dr. Dereje Shiferaw Negash, AAIT
• Using XCHD instruction
Addressing modes
• Indirect addressing
– MOV A, @R1
– MOVX @RO, A
– MOVX A, @DPTR
– MOVC A, @A+DPTR
– MOVC A, @A+PC
– XCHD A,@R1

Dr. Dereje Shiferaw Negash, AAIT


PIC microcontrollers
• Originally product of general instruments but latter
transferred to microchip
– PIC 1650 and 1655 8 bit microcontroller
– Faster speed, low cost, easier prototyping and simpler
chip set
• Basic features
– 8 bit microcontrollers
– Self contained (have internal program and data memory)
– Have single accumulator

Dr. Dereje Shiferaw Negash, AAIT
PIC microcontroller family
• Basic families of PIC controller

Dr. Dereje Shiferaw Negash, AAIT


Dr. Dereje Shiferaw Negash, AAIT
PIC microcontrollers
• The most famous family of the PIC
microcontrollers is the 16 series/ family
• As a family, they have identical core and
instruction set
• However, they have different package sizes,
internal memory capacity, number of
peripheral devices etc

Dr. Dereje Shiferaw Negash, AAIT


Dr. Dereje Shiferaw Negash, AAIT

You might also like