Microcontroller Based System Design Microcontroller Based System Design Microcontroller Based System Design Microcontroller Based System Design Module 2 Module 2 Module 2 Module 2 . Prepared by Emil Raj,Dept. Of ECE,MLMCE
Oct 27, 2014
Microcontroller Based System DesignMicrocontroller Based System DesignMicrocontroller Based System DesignMicrocontroller Based System Design
Module 2Module 2Module 2Module 2
.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Syllabus
� Module 2Module 2Module 2Module 2
Embedded C compiler – advantages – memory models – interrupt
functions – code optimization - 89C2051 micro-controller-
architecture-comparison with 89C51- design of a simple trainer architecture-comparison with 89C51- design of a simple trainer
circuit using 89C51/89C2051 µC – interfacing of DIP switch, LED, 7
segment display, alphanumeric LCD – relay interface – design of a
traffic light control system - interfacing programs using C and
assembly language.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
89C51
Prepared by Emil Raj,Dept. Of ECE,MLMCE
FEATURES
� 8 bit CPU with registers A and B
� 16 bit PC and DPTR
� 8 bit PSW
� Four 8 bit ports:P0-P3
� Two 16 bit timers &
counters:T0&T1
� Full duplex serial data
Rxr/Txr : SBUF.
� 8 bit stack pointer
� Internal ROM 4K
� Internal RAM of 128b
� Oscillator & clock circuits
Rxr/Txr : SBUF.
� Control registers :
TCON,TMOD,
SCON,PCON,IP &IE
� 2 external & 3 internal
interrupts.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
INTERNAL RAM
� Total 128 Bytes.
� Divided into 3 groups.
� 4 Register banks.
� Bit addressable memory(16
bytes).
� General purpose
registers(80 bytes).
Prepared by Emil Raj,Dept. Of ECE,MLMCE
INTERNAL RAM� Each bank has 8 registers(R0-R7).
� RS0 & RS1 bits selects the bank.� BANK 0: 00-07H
� BANK 1: 08-0FH
� BANK 2: 10-17H
� BANK 3:18-1FH
� General purpose registers.� Total 80 bytes.
� 30H to 7FH
Prepared by Emil Raj,Dept. Of ECE,MLMCE
BIT ADDRESSABLE
� 16 bytes from20H to 2FH.
� Total 128 bits.
� Specified by its bit address of
00H to 7FH.
� Set directly by SETB 2F.
� Cleared by CLR 2F.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
89C2051
Prepared by Emil Raj,Dept. Of ECE,MLMCE
PIN DIAGRAM
89C51 89C2051
Prepared by Emil Raj,Dept. Of ECE,MLMCE
89C2051 FEATURES
• 2K bytes of Flash
• 128 bytes of RAM
• 15 I/O lines
• two 16-bit timer/counters
• full duplex serial port• full duplex serial port
• a precision analog comparator
• on-chip oscillator and clock circuitry
• compatible with the industry standard MCS51 instruction set.
• supports two software selectable power saving modes.
• Idle Mode
• Power down modePrepared by Emil Raj,Dept. Of ECE,MLMCE
89C2051 FEATURES
• Idle Mode
• Stops the CPU while allowing the RAM, timer/counters, serial port and interrupt
system to continue functioning.
• Power down mode• Power down mode
• Saves the RAM contents and freezes the oscillator disabling all other chip
functions until the next hardware reset.
• It has a static processor core, ie. there is no minimum clock frequency
• maximum clock frequency is 24 MHz.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
89C2051 FEATURES
• Consist of Program Memory Lock Bits
� There are two on-chip lock bits which
can be left un programmed (U) or can
be programmed (P).
� They provide a kind of security for the
data.
� The Lock Bits can only be erased with
the Chip Erase operation. Prepared by Emil Raj,Dept. Of ECE,MLMCE
Comparison between 89C51 & 89C2051
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Comparison between 89C51 & 89C2051
� 89C2051 is having additionally an on chip precision analog comparator.
� 89C2051 has only 15 I/O lines so, port1 and port3 are only available on it.
� The architecture of 89C2051 does not support any external address/data � The architecture of 89C2051 does not support any external address/data
bus and therefore RD,WR signals are absent .
� Similar to 89C51 ,the 89C2051 also supports full-duplex serial
communication and six interrupts.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Comparison between 89C51 & 89C2051
� Similar to 89C51 ,two power saving modes namely “Idle mode and power down
modes are also available in 89C2051 .
� The 89C51 has 4Kb of flash memory where as 89C2051 is having only 2Kb of flash
memory
� ALE,PSEN,EA signals are not available in 89C2051 chip.
� The analog precision comparator on the 89C2051 is used along with RC components
to build a simple comparator type ADC.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Prepared by Emil Raj,Dept. Of ECE,MLMCE
.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
7 SEGMENT DISPLAY
Prepared by Emil Raj,Dept. Of ECE,MLMCE
PIN CONNECTIONS
Prepared by Emil Raj,Dept. Of ECE,MLMCE
LUT for Common Anode
Prepared by Emil Raj,Dept. Of ECE,MLMCE
INTERFACING
Prepared by Emil Raj,Dept. Of ECE,MLMCE
INTERFACING
Prepared by Emil Raj,Dept. Of ECE,MLMCE
PROGRAM ORG 0000hCLR P0.1CLR P0.2MOV P2, #ffh
Loop: CLR P0.2SETB P0.1SETB P0.1
MOV P2, # B0hCALL delay
CLR P0.1SETB P0.2
MOV P2, # 0F9hCALL delay
AJMP loop
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Interfacing LED & DIP Switch
� Emit light when an electric current
passes through them
LED’s are available in a wide variety of � LED’s are available in a wide variety of
sizes and shapes.
� Commonly used size are 5mm and 3mm
diameter.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Interfacing LED & DIP Switch
� A series of tiny switches built into circuit
boards.
� DIP switches enable you to configure a
circuit board for a particular type of
computer or application.
� DIP switches are always toggle switches,
which mean they have two possible
positions -- on or off. (Instead of on and
off, you may see the numbers 1 and 0.)Prepared by Emil Raj,Dept. Of ECE,MLMCE
Interfacing LED & DIP Switch
Prepared by Emil Raj,Dept. Of ECE,MLMCE
TRAFFIC LIGHT SYSTEM
Prepared by Emil Raj,Dept. Of ECE,MLMCE
TRAFFIC LIGHT SYSTEM
Prepared by Emil Raj,Dept. Of ECE,MLMCE
INTERFACING PRGM
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Prepared by Emil Raj,Dept. Of ECE,MLMCE
RELAY
� Electromechanical switch, which perform ON and OFF operations
without any human interaction.
� The relay consists a inductor coil, a spring (not shown in the
figure), Swing terminal, and two high power contacts named as
normally closed (NC) and normally opened (NO). normally closed (NC) and normally opened (NO).
� Relay uses an Electromagnet to move swing terminal between
two contacts (NO and NC). When there is no power applied to
the inductor coil (Relay is OFF), the spring holds the swing
terminal is attached to NC contact.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
� Whenever required power is applied to the inductor coil, the current
flowing through the coil generates a magnetic field which moves the swing
terminal to normally open (NO) contact.
RELAY
� When power is OFF, the spring restores the swing terminal position to NC.
Prepared by Emil Raj,Dept. Of ECE,MLMCE
TYPES OF RELAY
Prepared by Emil Raj,Dept. Of ECE,MLMCE
Relay Interfacing
� .
Prepared by Emil Raj,Dept. Of ECE,MLMCE