0% found this document useful (0 votes)
19 views

MPMC Unit-5 Material

Uploaded by

Vinayak Gupta
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)
19 views

MPMC Unit-5 Material

Uploaded by

Vinayak Gupta
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/ 66

UNIT-5

• InterfacingMicrocontroller
• Programming8051Timers
• SerialPortProgramming
• InterruptsProgramming
• LCD&Keyboard Interfacing
• ADC,DAC&SensorInterfacing
• ExternalMemoryInterface
• StepperMotorandWaveformgeneration
• ComparisonofMicroprocessor,Microcontroller,
• PIC
• ARMprocessors
InterfacingMicrocontroller
InterfacingMicrocontroller
• Everyelectricalandelectronicsprojectdesignedtodevelopelectronic
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.
• Inmaximumnumberofapplications,themicrocontrollerisconnected
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.
Programming8051Timers

• 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
forincrementing the timer registers.
TimerMode
• Inthetimermode,theinternalmachinecyclesarecounted.
• Sothisregisterisincrementedineachmachinecycle.
• Sowhentheclockfrequencyis12MHz,thenthetimer
register is incremented in each millisecond.
• Inthismodeitignorestheexternaltimerinputpin.
CounterMode
• Inthecountermode,theexternaleventsarecounted.
• In this mode, the timer register is incremented for each 1 to 0
transition of the external input pin.
• Thistypeoftransitionsistreatedasevents.
• The external input pins are sampled once in each machine cycle, and
to determine the 1or 0 transitions, another machine cycle will be
needed.
• Sointhismode,atleasttwomachinecyclesareneeded.
• When the frequency is12MHz, then the maximum count frequency
will be 12MHz/24 = 500KHz. So for event counting the time durationis
2 µs.
TMODRegister

• Timer Timer1Mode Timer0Mode


• BitDetailsGate(G) C/T M1 M0 Gate(G) C/T M1 M0
DifferencebetweenaTimerandaCounter
Timer0Register

The16-bitregisterofTimer0isaccessedaslow-andhigh-byte. The
low-byteregisteris called TL0 (Timer 0 low byte) and the high-
byte register is called TH0 (Timer 0 high byte).
Theseregisterscanbeaccessedlikeanyotherregister.
Forexample,theinstructionMOVTL0,#4Hmovesthevalue into
the low-byte of Timer #0.
Timer1Register
• The16-bit register ofTimer1isaccessedaslow-andhigh-byte.
• Thelow-byteregisteriscalledTL1(Timer1lowbyte)andthehigh-byteregister is
called TH1 (Timer 1 high byte).
• Theseregisterscan beaccessedlikeanyotherregister.
• For example,the instruction MOV TL1, #4Hmovesthe value into the low-
byte of Timer 1.
TMOD(TimerMode)Register

• BothTimer0andTimer1usethesameregistertosetthevarioustimer
operation modes.
• It is an 8-bit register in which the lower 4 bits are set aside for Timer0
and the upper four bits for Timers.
• Ineachcase,thelower2bitsareusedtosetthetimermodein advance and
the upper 2 bits are used to specify the location.
.
• Thisisan8-bitregisterwhichisusedbybothtimers0and1toset
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 modeand 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.
TCONregister
• BitsandsymbolandfunctionsofeverybitsofTCONareasfollows:
MODESOFOPERATION:

TheMode0operationisthe8-bittimerorcounterwitha5-bitpre-scaler. So it is
a 13-bittimer/counter.It uses 5 bits of TL0 or TL1 and all of the8- bits of
TH0 or TH1.

Mode 0ofTimer/Counter
MOVTMOD,#00H
MOVTH1, #0F0H
MOVIE, #88H SETB
TR1
Mode1ofTimer/Counter

MOVTMOD,#01H
MOV TL0, #0F0H
MOVTH0, #0FFH
MOV IE, #82H
TheMode1operationisthe16-bit timeror SETBTR0
counter. In the followingdiagram, we are
using Mode 1 for Timer0.
Mode2ofTimer/Counter

The Mode 2 operation is the 8-bit auto


reload timer or counter. In the following
diagram,weareusingMode2forTimer1. MOVTMOD,#20H
MOVTL1, #0F0H
MOVTH1, #0F0H
MOVIE, #88H
SETBTR1
Mode3ofTimer/Counter • Mode3isdifferentforTimer0and
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.
• WhentheTH0overflowsfromFFHto
00H,thenTF1issetto1.
• Inthefollowingdiagram,wecan
Timer0inMode3.
SerialCommunication
.
SerialPortProgramming
Serial Port Programming: 8051 Serial Communication
Oneofthe8051’smany powerfulfeatures-integratedUART,
known as a serial port to easily read and
write values to the serial port instead of turningon
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.
.
.
.
InterruptsProgramming
.
.
.
.
.
LCD&KeyboardInterfacing
• LCDstandsforliquid crystaldisplaywhich candisplaythecharactersper line.
• Here16by 2LCDdisplaycandisplay 16 charactersperline andthereare 2
lines.
• InthisLCDeachcharacterisdisplayedin5*7pixelmatrix.
.

LCDDisplayCommands

LCDInterfacingtoMicrocontroller
ADCInterfacing
• ADC(Analogtodigitalconverter)formsaveryessentialpartinmany
embedded projects.
• ADC 0804 is the ADC used here and before going through the
interfacingprocedure,wemustneatlyunderstandhowtheADC0804
works.
• ADC0804isan8bitsuccessiveapproximationanaloguetodigitalconverter
from National semiconductors.
• The features of ADC0804 aredifferential 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.
StepsforconvertingtheanalogueinputandreadingtheoutputfromADC0804.
• MakeCS=0andsendalowtohighpulsetoWRpintostartthe
conversion.
• Nowkeepchecking theINTRpin.INTRwillbe1ifconversionisnot
finished and INTR will be 0 if conversion is finished.
• Ifconversionisnotfinished(INTR=1),polluntilitisfinished.
• Ifconversionisfinished(INTR=0),gotothenextstep.
• MakeCS=0andsendahightolowpulsetoRDpintoreadthedata from
the ADC.
ORG00H
MOVP1,#11111111B//initiatesP1astheinputport
MAIN:CLR P3.7//makes CS=0
SETBP3.6//makesRDhigh
CLR P3.5 // makes WR low
SETBP3.5//lowtohighpulsetoWRforstartingconversion WAIT: JB
P3.4,WAIT// polls untilINTR=0
CLRP3.7//ensuresCS=0
CLRP3.6//hightolowpulsetoRDforreadingthedatafromADC
MOV A,P1 // moves the digital data to accumulator
CPLA//complementsthedigitaldata(*seethenotes)
MOV P0,A // outputs the data to P0 for the LEDs
SJMPMAIN//jumpsbacktotheMAINprogram END
DACInterfacing
• 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
converterto convert this current into equivalent voltage.
1KHzSquarewaveusing8051timer.
MOV P1,#00000000B
MOVTMOD,#00000001B
MAIN: SETB P1.0
ACALLDELAY
CLR P1.0
ACALLDELAY
SJMP MAIN
DELAY:MOVTH0,#0FEH
MOV TL0,#00CH
SETB TR0
HERE:JNBTF0,HERE CLR
TR0
CLR TF0
SETBP1.0
RET
END
SENSORINTERFACING:
• LM35Temperaturesensors:
• TheLM35seriessensorsareprecisionintegrated-circuittemperaturesensorswhoseoutput voltage is
linearly proportionalto the celsius (centigrade) temperature.
• TheLM35requiresnoexternalcalibrationsinceitisinternallycalibrated.
• Itoutputs10mVforeachdegreeofcentigradetemperature.
• TableistheselectionguidefortheLM3.
• ThesensorsoftheLM34seriesareprecisionintegrated-circuittemperaturesensorswhose output
voltage is linearly proportional to the Fahrenheit temperature.
• Italsointernallycalibrated.
• Itoutputs10mVforeachdegreeFahrenheittemperature.
• 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.
• Signalconditioningcanbeacurrent-to-voltage
conversionorasignalamplification.
StepperMotor
• Asteppermotorisoneofthemostcommonlyusedmotorforpreciseangular
movement.
• Theadvantageofusingasteppermotoristhattheangularpositionofthemotor
canbecontrolledwithoutanyfeedbackmechanism.
• Thesteppermotorsarewidelyusedinindustrialandcommercialapplications.
• Theyarealsocommonlyusedasindrivesystemssuchasrobots,washing
machinesetc.
StepperMotor
• 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.
ComparisonofMicroprocessor,Microcontroller
.
DifferenceBetweenVonNeumannAndHarvardArchitecture
RISCvsCISCARCHITECTURE
ARM 8051 PIC

Speed 1clock/instructioncycle 12clock/instructioncycle 4clock/instructioncycle


32bitmostlyalsoavailable in
Buswidth 64 bit 8bitforthestandardcore 8/16/32bit
Acorn,Apple, Nvidia, NXP,Atmel,SiliconLabs,
Qualcomm,Samsung Dallas,Cyprus,Infineon,
Manufacturer Electronics, and TI etc MicrochipAverage
ModifiedHarvard
MemoryArchitecture Architecture VonNeumannArchitecture HarvardArchitecture
PowerConsumption Low Average Low

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

LPC2148,ARMCortex-M0 PIC18fXX8,PIC16f88X,
PopularMicrocontrollers toARMCortex-M7,etc AT89C51,P89v51,etc PIC32MXX

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


PIC16,PIC17,PIC18,PIC24,
Families ARMv4,5,6,7,andseries 8051 variants PIC32
PIC(ProgrammableInterfaceControllers)
• 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,
embeddedsystems, etc.
• Various types of microcontrollersexist, 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 storingof the code.
ArchitectureofPICMicrocontroller
ArchitectureofPICMicrocontroller
• CPU(CentralProcessingUnit)
• MemoryOrganization
• RandomAccessMemory(RAM)
• GeneralPurposeRegisters(GPR)
• SpecialFunctionRegisters
• ReadOnlyMemory(ROM)
• ElectricallyErasableProgrammableReadOnlyMemory(EEPROM)
• FlashMemory
• Stack
• I/OPorts
• BUS
• A/Dconverters
• Timers/Counters
• Interrupts
• SerialCommunication
• Oscillators
• CCPmodule
.

A/D CONVERTER

SerialCommunication
MemoryOrganization

BUS
ARMprocessors
• The ARM architecture processor is an advanced reduced instruction set
computing [RISC] machine and it’s a 32bit reduced instruction set computer
(RISC) microcontroller.
• ItwasintroducedbytheAcroncomputerorganizationin1987.
• 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.
• TheARM microcontrollermostcommonlyusedcontrollerindifferenttypes of
embedded projects and in different types of industrial projects it uses due to
different types of advantages over other controllers and modern structures.
FeaturesofARM Microcontroller
• Thesearesomeimportantfeaturesofthiscontrollerwhicharedescribed here
with the details.
• Thisboardcomprisesofthirtytwobitcentralprocessingunitwhichis high
speed.
• Itcomprisesofthethree-stagepipeline.
• Thisboardusesthethumb2technique.
• ThismoduleiscompatiblewiththedifferenttypesoftoolsandRTOS.
• Itiscompatiblewiththesleepmodeofoperation.
• Ithastheabilitytocontroldifferenttypesofsoftware
.
TheARMArchitecture

• ArithmeticLogicUnit
• Boothmultiplier
• Barrelshifter
• Controlunit
ArithmeticLogic Unit
• TheALUhastwo32-bitsinputs.Theprimarycomesfromtheregisterfile,whereastheother
comesfromtheshifter.
• StatusregistersflagsmodifiedbytheALUoutputs.
• TheV-bitoutputgoestotheVflagaswellastheCountgoestotheCflag.
• WhereastheforemostsignificantbitreallyrepresentstheSflag,theALUoutputoperation isdone by
NORed togettheZflag. The ALU has a 4-bit function bus that permits up to 16 opcode to be
implemented.
BoothMultiplierFactor
• Themultiplierfactorhas332-bitinputsandtheinputsreturnfromtheregisterfile. The
multiplieroutputisbarely32-LeastSignificantBitsofthemerchandise.
• Theentityrepresentationofthemultiplierfactorisshownintheaboveblockdiagram.The
multiplicationstartswheneverthebeginning04inputgoesactive.
• Finoftheoutputgoeshighwhenfinishing.
BarrelShifter
• Thebarrelshifterfeaturesa32-bitinputtobeshifted.
• Thisinputiscomingbackfromtheregisterfileoritmightbeimmediatedata.
• Theshifterhasdifferentcontrolinputscomingbackfromtheinstructionregister.
• TheShiftfieldwithintheinstructioncontrolstheoperationofthebarrelshifter.
• Thisfieldindicates thekindofshifttobeperformed(logicalleftorright,arithmetic right or
rotate right).
ControlUnit
• 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.
• Thecontrolunitissometimesapurecombinationalcircuitdesign.
• Here,thecontrolunitisimplementedbyeasystatemachine.
• Theprocessortimingisadditionallyincludedwithinthecontrolunit.
• Signalsfromthecontrolunitareconnectedtoeachcomponentwithintheprocessorto
superviseitsoperation.
ARMMicrocontrollerRegisterModes
ApplicationofARMMicrocontroller
• Thisboardisusedindifferenttypesoftechniquesusedin space
and aerospace.
• DifferenttypesofmedicaldevicessuchasMRImachines,comput
ed tomography scanners, ultrasound machines.
• Itusedindifferenttypesofaccelerators,nuclearreactors,and X-
ray machines.
10MQUESTIONS:
1. Describethedifferentmodesofoperationoftimers/countersin8051
with its associated register?
2. ExplainthearchitectureofARMwithneatdiagram.
3. ExplainthearchitectureofPICmicrocontrollerwithneatsketch.
4. Explain about serial Communication registers in 8051
microcontroller.
5. Whatisinterrupt?ExplainaboutInterruptregistersin8051.
2MQuestions:
1. WhatisthedifferencebetweenPICandARMprocessors
2. GivethecomparisonofMicroprocessor&Microcontroller.
3. ExplaintheregisterPCONformatof8051
4. Listthemodesoftimerin8051
5. WriteanALPtogenerate1KHzSquarewaveusing8051timer?
6. Listtheapplicationsofmicrocontroller
7. Whataretheadvantagesofmicrocontrollerovermicroprocessor?
8. GivethedifferentapplicationsofARMprocessors.
9. WhatisARMarchitecture?
10. WhatisthedifferencebetweenCISCandRISC.
11. WhatisthedifferencebetweenSynchronousandAsynchronousCommunication.
12. WhatarethefeaturesofPICmicrocontroller.
13. Differentiatebetween8051,PICandARMmicrocontrollers.

You might also like