0% found this document useful (0 votes)
38 views62 pages

MPMC Unit-5 Material

MPMC material

Uploaded by

korapatiusharani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views62 pages

MPMC Unit-5 Material

MPMC material

Uploaded by

korapatiusharani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

UNIT-5

• Interfacing Microcontroller
• Programming 8051 Timers
• Serial Port Programming
• Interrupts Programming
• LCD & Keyboard Interfacing
• ADC, DAC & Sensor Interfacing
• External Memory Interface
• Stepper Motor and Waveform generation
• Comparison of Microprocessor, Microcontroller,
• PIC
• ARM processors
Interfacing Microcontroller
Interfacing Microcontroller
• Every electrical and electronics project designed to develop electronic
gadgets that are frequently used in our day-to-day life utilizes
microcontrollers with appropriate interfacing devices.
• There are different types of applications that are designed using
microcontroller-based projects.
• In maximum number of applications, the microcontroller is connected
with some external devices called as interfacing devices for
performing some specific tasks.
• For example, consider security system with a user changeable
password project, in which an interfacing device, keypad is interfaced
with microcontroller to enter the password.
Programming 8051 Timers

• In Intel 8051, there are two 16-bit timer registers. These


registers are known as Timer0 andTimer1.
• The timer registers can be used in two modes. These modes are
Timer mode and the Counter mode.
• The only difference between these two modes is the source for
incrementing the timer registers.
Timer Mode
• In the timer mode, the internal machine cycles are
counted.
• So this register is incremented in each machine cycle.
• So when the clock frequency is 12MHz, then the timer
register is incremented in each millisecond.
• In this mode it ignores the external timer input pin.
Counter Mode
• In the counter mode, the external events are counted.
• In this mode, the timer register is incremented for each 1 to 0
transition of the external input pin.
• This type of transitions is treated as events.
• The external input pins are sampled once in each machine cycle, and
to determine the 1or 0 transitions, another machine cycle will be
needed.
• So in this mode, at least two machine cycles are needed.
• When the frequency is12MHz, then the maximum count frequency
will be 12MHz/24 = 500KHz. So for event counting the time duration
is 2 µs.
TMOD Register

• Timer Timer1 Mode Timer0 Mode


• Bit Details Gate (G) C/T M1 M0 Gate (G) C/T M1 M0
Difference between a Timer and a Counter
Timer 0 Register

The 16-bit register of Timer 0 is accessed as low- and high-byte.


The low-byte register is called TL0 (Timer 0 low byte) and the
high-byte register is called TH0 (Timer 0 high byte).
These registers can be accessed like any other register.
For example, the instruction MOV TL0, #4H moves the value
into the low-byte of Timer #0.
Timer 1 Register
• The 16-bit register of Timer 1 is accessed as low- and high-byte.
• The low-byte register is called TL1 (Timer 1 low byte) and the high-byte
register is called TH1 (Timer 1 high byte).
• These registers can be accessed like any other register.
• For example, the instruction MOV TL1, #4H moves the value into the low-
byte of Timer 1.
TMOD (Timer Mode) Register

• Both Timer 0 and Timer 1 use the same register to set the various
timer operation modes.
• It is an 8-bit register in which the lower 4 bits are set aside for Timer
0 and the upper four bits for Timers.
• In each case, the lower 2 bits are used to set the timer mode in
advance and the upper 2 bits are used to specify the location.
.
• This is an 8-bit register which is used by both timers 0 and 1 to set
the various timer modes. In this TMOD register, lower 4 bits are set
aside for timer0 and the upper 4 bits are set aside for timer1. In each
case, the lower 2 bits are used to set the timer mode and upper 2 bits
to specify the operation.
• In upper or lower 4 bits, first bit is a GATE bit. Every timer has a
means of starting and stopping. Some timers do this by software,
some by hardware, and some have both software and hardware
controls. The hardware way of starting and stopping the timer by an
external source is achieved by making GATE=1 in the TMOD register.
And if we change to GATE=0 then we do no need external hardware
to start and stop the timers.
TCON register
• Bits and symbol and functions of every bits of TCON are as follows:
MODES OF OPERATION:

The Mode 0 operation is the 8-bit timer or counter with a 5-bit pre-scaler.
So it is a 13-bit timer/counter. It uses 5 bits of TL0 or TL1 and all of the 8-
bits of TH0 or TH1.

Mode 0 of Timer/Counter
MOV TMOD, #00H
MOV TH1, #0F0H
MOV IE, #88H
SETB TR1
Mode 1 of Timer/Counter

MOV TMOD, #01H


MOV TL0, #0F0H
MOV TH0, #0FFH
MOV IE, #82H
The Mode 1 operation is the 16-bit timer or SETB TR0
counter. In the following diagram, we are
using Mode 1 for Timer0.
Mode 2 of Timer/Counter

The Mode 2 operation is the 8-bit auto


reload timer or counter. In the following
diagram, we are using Mode 2 for Timer1. MOV TMOD, #20H
MOV TL1, #0F0H
MOV TH1, #0F0H
MOV IE, #88H
SETB TR1
Mode 3 of Timer/Counter • Mode 3 is different for Timer0 and
Timer1.
• When the Timer0 is working in mode
3, the TL0 will be used as an 8-bit
timer/counter.
• It will be controlled by the standard
Timer0 control bits, T0 and INT0
inputs. The TH0 is used as an 8-bit
timer but not the counter.
• This is controlled by Timer1 Control
bit TR1.
• When the TH0 overflows from FFH to
00H, then TF1 is set to 1.
• In the following diagram, we can
Timer0 in Mode 3.
Serial Communication
.
Serial Port Programming
Serial Port Programming: 8051 Serial Communication
One of the 8051’s many powerful features -integrated UART,
known as a serial port to easily read and
write values to the serial port instead of turning
on and off one of the I/O lines in rapid succession
to properly "clock out" each individual bit,
including start bits, stop bits and parity bits.
.
.
.
Interrupts Programming
.
.
.
.
.
LCD & Keyboard Interfacing
• LCD stands for liquid crystal display which can display the characters per
line.
• Here 16 by 2 LCD display can display 16 characters per line and there are
2 lines.
• In this LCD each character is displayed in 5*7 pixel matrix.
.

LCD Display Commands

LCD Interfacing to Microcontroller


ADC Interfacing
• ADC (Analog to digital converter) forms a very essential part in many
embedded projects.
• ADC 0804 is the ADC used here and before going through the
interfacing procedure, we must neatly understand how the ADC 0804
works.
• ADC0804 is an 8 bit successive approximation analogue to digital
converter from National semiconductors.
• The features of ADC0804 are differential analogue voltage inputs, 0-
5V input voltage range, no zero adjustment, built in clock generator,
reference voltage can be externally adjusted to convert smaller
analogue voltage span to 8 bit resolution etc.
Steps for converting the analogue input and reading the output from
ADC0804.
• Make CS=0 and send a low to high pulse to WR pin to start the
conversion.
• Now keep checking the INTR pin. INTR will be 1 if conversion is not
finished and INTR will be 0 if conversion is finished.
• If conversion is not finished (INTR=1) , poll until it is finished.
• If conversion is finished (INTR=0), go to the next step.
• Make CS=0 and send a high to low pulse to RD pin to read the data
from the ADC.
ORG 00H
MOV P1,#11111111B // initiates P1 as the input port
MAIN: CLR P3.7 // makes CS=0
SETB P3.6 // makes RD high
CLR P3.5 // makes WR low
SETB P3.5 // low to high pulse to WR for starting conversion
WAIT: JB P3.4,WAIT // polls until INTR=0
CLR P3.7 // ensures CS=0
CLR P3.6 // high to low pulse to RD for reading the data from ADC
MOV A,P1 // moves the digital data to accumulator
CPL A // complements the digital data (*see the notes)
MOV P0,A // outputs the data to P0 for the LEDs
SJMP MAIN // jumps back to the MAIN program
END
DAC Interfacing
• Microcontroller are used in wide variety of applications like for
measuring and control of physical quantity like temperature,
pressure, speed, distance, etc.
• In these systems microcontroller generates output which is in digital
form but the controlling system requires analog signal as they don't
accept digital data thus making it necessary to use DAC which
converts digital data into equivalent analog voltage.
• In the figure shown, we use 8-bit DAC 0808. This IC converts digital
data into equivalent analog Current. Hence we require an I to V
converter to convert this current into equivalent voltage.
1KHz Square wave using 8051 timer.
MOV P1,#00000000B
MOV TMOD,#00000001B
MAIN: SETB P1.0
ACALL DELAY
CLR P1.0
ACALL DELAY
SJMP MAIN
DELAY: MOV TH0,#0FEH
MOV TL0,#00CH
SETB TR0
HERE: JNB TF0,HERE
CLR TR0
CLR TF0
SETB P1.0
RET
END
SENSOR INTERFACING:
• LM35 Temperature sensors:
• The LM35 series sensors are precision integrated-circuit temperature sensors whose output
voltage is linearly proportional to the celsius (centigrade) temperature.
• The LM35 requires no external calibration since it is internally calibrated.
• It outputs 10mV for each degree of centigrade temperature.
• Table is the selection guide for the LM3.
• The sensors of the LM34 series are precision integrated-circuit temperature sensors whose
output voltage is linearly proportional to the Fahrenheit temperature.
• It also internally calibrated.
• It outputs 10mV for each degree Fahrenheit temperature.
• The above figure shows the steps involved in
acquiring data from analog world.
• Signal conditioning is widely used in the world
of data acquisition.
• The most common transducers produce an
output in the form of voltage, current,charge,
capacitance, and resistance.
• However, we need to convert these signals to
voltage in order to send input to an A-to-D
converter.
• This conversion (modification) is commonly
called signal conditioning.
• Signal conditioning can be a current-to-voltage
conversion or a signal amplification.
Stepper Motor
• A stepper motor is one of the most commonly used motor for precise angular
movement.
• The advantage of using a stepper motor is that the angular position of the motor
can be controlled without any feedback mechanism.
• The stepper motors are widely used in industrial and commercial applications.
• They are also commonly used as in drive systems such as robots, washing
machines etc.
Stepper Motor
• Stepper motors can be unipolar or bipolar and here we are
using unipolar stepper motor.
• The unipolar stepper motor consists of six wires out of which
four are connected to coil of the motor and two are common
wires.
• Each common wire is connected to a voltage source and
remaining wires are connected to the microcontroller.
Comparison of Microprocessor, Microcontroller
.
Difference Between Von Neumann And Harvard Architecture
RISC vs CISC ARCHITECTURE
ARM 8051 PIC

Speed 1 clock/instruction cycle 12 clock/instruction cycle 4 clock/instruction cycle


32 bit mostly also available
Bus width in 64 bit 8 bit for the standard core 8/16/32 bit
Acorn,Apple, Nvidia, NXP, Atmel, Silicon Labs,
Qualcomm, Samsung Dallas, Cyprus, Infineon,
Manufacturer Electronics, and TI etc Microchip Average
Modified Harvard
Memory Architecture Architecture Von Neumann Architecture Harvard Architecture
Power Consumption Low Average Low

UART, USART, LIN, I2C, SPI,


CAN, USB, Ethernet, 12S,
DSP, SAI (serial audio PIC, UART, USART, LIN,
Communication Protocols interface), IrDA UART, USART, SPI, I2C CAN, Ethernet, SPI, I2S

LPC2148, ARM Cortex-M0 PIC18fXX8, PIC16f88X,


Popular Microcontrollers to ARM Cortex-M7, etc AT89C51, P89v51, etc PIC32MXX

Memory Flash, SDRAM, EEPROM ROM, SRAM, FLASH SRAM, FLASH


PIC16, PIC17, PIC18, PIC24,
Families ARMv4, 5, 6, 7, and series 8051 variants PIC32
PIC (Programmable Interface Controllers)
• PIC (Programmable Interface Controllers) microcontrollers are the
worlds smallest microcontrollers that can be programmed to carry
out a huge range of tasks.
• These microcontrollers are found in many electronic devices such as
phones, computer control systems, alarm systems, embedded
systems, etc.
• Various types of microcontrollers exist, even though the best are
found in the GENIE range of programmable microcontrollers.
• These microcontrollers are programmed and simulated by a circuit-
wizard software.
• PIC microcontrollers are based on the Harvard architecture where
program and data busses are kept separate.
• Early versions of PIC microcontrollers use EPROM to store the
program instruction but have adopted the flash memory since 2002
to allow better erasing and storing of the code.
Architecture of PIC Microcontroller
Architecture of PIC Microcontroller
• CPU (Central Processing Unit)
• Memory Organization
• Random Access Memory (RAM)
 General Purpose Registers (GPR)
 Special Function Registers
• Read Only Memory (ROM)
• Electrically Erasable Programmable Read Only Memory (EEPROM)
• Flash Memory
• Stack
• I/O Ports
• BUS
• A/D converters
• Timers/ Counters
• Interrupts
• Serial Communication
• Oscillators
• CCP module
.

A/D CONVERTER

Serial Communication
Memory Organization

BUS
ARM processors
• The ARM architecture processor is an advanced reduced instruction set
computing [RISC] machine and it’s a 32bit reduced instruction set computer
(RISC) microcontroller.
• It was introduced by the Acron computer organization in 1987.
• This ARM is a family of microcontroller developed by makers like ST
Microelectronics, Motorola, and so on.
• The ARM architecture comes with totally different versions like ARMv1,
ARMv2, etc., and, each one has its own advantage and disadvantages.
• The ARM microcontroller most commonly used controller in different types
of embedded projects and in different types of industrial projects it uses due
to different types of advantages over other controllers and modern structures.
Features of ARM Microcontroller
 These are some important features of this controller which are described
here with the details.
 This board comprises of thirty two bit central processing unit which is
high speed.
 It comprises of the three-stage pipeline.
 This board uses the thumb 2 technique.
 This module is compatible with the different types of tools and RTOS.
 It is compatible with the sleep mode of operation.
 It has the ability to control different types of software
.
The ARM Architecture

 Arithmetic Logic Unit


 Booth multiplier
 Barrel shifter
 Control unit
Arithmetic Logic Unit
• The ALU has two 32-bits inputs. The primary comes from the register file, whereas the other
comes from the shifter.
• Status registers flags modified by the ALU outputs.
• The V-bit output goes to the V flag as well as the Count goes to the C flag.
• Whereas the foremost significant bit really represents the S flag, the ALU output operation
is done by NORed to get the Z flag. The ALU has a 4-bit function bus that permits up to 16
opcode to be implemented.
Booth Multiplier Factor
• The multiplier factor has 3 32-bit inputs and the inputs return from the register file. The
multiplier output is barely 32-Least Significant Bits of the merchandise.
• The entity representation of the multiplier factor is shown in the above block diagram. The
multiplication starts whenever the beginning 04 input goes active.
• Fin of the output goes high when finishing.
Barrel Shifter
• The barrel shifter features a 32-bit input to be shifted.
• This input is coming back from the register file or it might be immediate data.
• The shifter has different control inputs coming back from the instruction register.
• The Shift field within the instruction controls the operation of the barrel shifter.
• This field indicates the kind of shift to be performed (logical left or right, arithmetic
right or rotate right).
Control Unit
• For any microprocessor, control unit is the heart of the whole process and it is
responsible for the system operation, so the control unit design is the most important part
within the whole design.
• The control unit is sometimes a pure combinational circuit design.
• Here, the control unit is implemented by easy state machine.
• The processor timing is additionally included within the control unit.
• Signals from the control unit are connected to each component within the processor to
supervise its operation.
ARM Microcontroller Register Modes
Application of ARM Microcontroller
 This board is used in different types of techniques used in
space and aerospace.
 Different types of medical devices such as MRI machines,
computed tomography scanners, ultrasound machines.
 It used in different types of accelerators, nuclear reactors,
and X-ray machines.
10M QUESTIONS:
1. Describe the different modes of operation of timers/counters in
8051 with its associated register?
2. Explain the architecture of ARM with neat diagram.
3. Explain the architecture of PIC microcontroller with neat sketch.
4. Explain about serial Communication registers in 8051
microcontroller.
5. What is interrupt? Explain about Interrupt registers in 8051.
2M Questions:
1. What is the difference between PIC and ARM processors
2. Give the comparison of Microprocessor & Microcontroller.
3. Explain the register PCON format of 8051
4. List the modes of timer in 8051
5. Write an ALP to generate 1KHz Square wave using 8051 timer?
6. List the applications of microcontroller
7. What are the advantages of microcontroller over microprocessor?
8. Give the different applications of ARM processors.
9. What is ARM architecture?
10.What is the difference between CISC and RISC.
11.What is the difference between Synchronous and Asynchronous Communication.
12.What are the features of PIC microcontroller.
13.Differentiate between 8051, PIC and ARM microcontrollers.

You might also like