MPMC Unit-5 Material
MPMC Unit-5 Material
• 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
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
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
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
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.