Вы находитесь на странице: 1из 36

Microprocessorand Microcontroller

Isra University SpringSemester,2012 Spring Semester, 2012 Instructor:Fahad AlGhazali

Miccorontroller module of Course moduleofCourse


Microcontrollers : PIC Series Microcontrollers:PICSeries

Introduction
PIC Microcontrollers are fabricated by PICMicrocontrollersarefabricatedby Microchip These microcontrollers have many series Thesemicrocontrollershavemanyseries LikePIC10,12,16,18etc. DependupontheinbuiltfeatureslikeRAM, Flash/EEPROM,ADCs,Ethernet,USBdrivers etc.

PIC18 PIC 18
Has RISC architecture HasRISCarchitecture Reducedinstructionsetarchitecture HasONchipprogram(code)ROM,data O hi ( d ) O d RAM,timers,ADC ,USARTandI/Oports ROM:128kto2MB OTPtypes:Onetypeprogrammable(cheap yp yp p g ( p solution)

BlockDiagram Block Diagram

Detailed Detailed Block Diagram i

PICwithUV EEPROM&Flash PIC with UVEEPROM & Flash


PICcomewithUV EEPROM PIC come with UVEEPROM RequireUVEPROMburner Takes~20minutes k 20 i ThusFlashversionisintroduced TheletterFintheseriesnamelike PIC18F452representsthattheFlashmemory PIC18F452 represents that the Flash memory isusedinthisIC

PICICComparisons PIC IC Comparisons

OTPVERsion andthemaskedversion OTP VERsion and the masked version


If the design is out of development and Ifthedesignisoutofdevelopmentand debuggingphase,microchipcancreate inexpensivedevicesinbulkforyouwithyour inexpensive devices in bulk for you with your hexfileburnt Reguires MOQ MOQ. TheletterCmeanstheOTPversionlike PIC18C432

PICTrainer PIC Trainer


Chapter 8 of the book Chapter8ofthebook PICmicrocontrollerandtheembedded systemsinAssemblyandC systems in Assembly and C ByDannyCausey andMuhammadAlMazidi

8051VsPIC 8051 Vs PIC


Both of them ruggedized architectures Bothofthem,ruggedizedarchitectures ButsupportforthePICismuchstrongerfor creatinglargeprojects creating large projects BuiltinClibrariesarethereRTOS,USART, CANBusinterfacesandtheUSBethernet CAN B i f d h USB h interfaceswhichcutshortthedesigncycle

WREGRegister WREG Register


The WREG register is the mainly used for TheWREGregisteristhemainlyusedfor arithmeticandlogicoperations It is one of these registers Itisoneoftheseregisters Usedtostoretemporaryinformation,data, valuesresults.etc. l l MOVLW;moveliteralvalueKintoWREG MOVLW25H;moves25toW

ADDLW
ADDLW instruction adds into the value of ADDLWinstructionaddsintothevalueof WREG ADDLW K ; add literal value K to WREG ADDLWK;addliteralvalueKtoWREG

PICWREGandALUusingLiteralValue PIC WREG and ALU using Literal Value

SFRs

Toolsandhardware Tools and hardware


Softwares for coding and debugging forcodinganddebugging
MPLAB(bymicrochip) MicroC ( by microElectronika) (bymicroElectronika)

Hardware
Training board Available in University TrainingboardAvailableinUniversity Itsdocumentationisuploadedongroup

PICdevelopmentKit PIC development Kit

Softwareforprogramming Software for programming


The kit supports incircuit programmability Thekitsupportsin circuitprogrammability Softwareforprogrammingisuploadedin group

Steps
First code is written Firstcodeiswritten Convertedtohex Downloaded onto the PIC using JDM DownloadedontothePICusingJDM programmer(whileprogramming,theLCD, MAX232ICandtheUSBconnectionshouldbe MAX232 IC and the USB connection should be unconnected) After programming the serial cable should be Afterprogrammingtheserialcableshouldbe disconnectedandtheUSBpowercable mountedforcheckingthecode

Fileregisters(Dataram) File registers (Data ram )


File registers are read/write memory used by Fileregistersareread/writememoryusedby theCPUfordatastorageadregistersfor internaluseandfunctions internal use and functions Theyaredividedintotwo G GeneralPurposeRAM lP RAM SpecialFunctionRegisters

SpecialFunctionregisters Special Function registers


These are used for special purposes or Theseareusedforspecialpurposesor interfacese.g.SerialcommunicationI/Oports

GeneralPurposeRegisters General Purpose Registers


Group of RAM locations in the file registers GroupofRAMlocationsinthefileregisters thatareusedfordatastorageandscratchpad Each location in 8 bit wide Eachlocationin8bitwide

MOVLWinstruction MOVLW instruction


MOVLW 0x0a ; move literal value 0x0a to MOVLW0x0a;moveliteralvalue0x0ato WREGregister MOVLW 25H MOVLW25H

ADDLWInstruction ADDLW Instruction


Adds value in WREG register AddsvalueinWREGregister MOVLW25H;load25hinwreg ADDLW34H;addvalue34toW(W=W+34) 3 dd l 3 ( 3 )

StatusRegistersinPIC18 Status Registers in PIC18


The status register is just like FLAGS register in ThestatusregisterisjustlikeFLAGSregisterin 8086

StatusregistersinPIC16f87x Status registers in PIC16f87x


IRP:Interbankselectbitforindirectaddressing IRP : Inter bank select bit for indirect addressing RP1:RP0.Bankselect TOtimeroutbit TO timer out bit PDPowerdownbit(0sleep..Powersave.1:power up up

MOVWFInstruction MOVWF Instruction

Valuesataddressesafterexecutionof instructions

Example2.1 Example 2.1

ADDWFinstruction ADDWF instruction


ADDWF adds contents of WREG and a file ADDWFaddscontentsofWREGandafile registerlocation. File register location can be an SFR or a GPR FileregisterlocationcanbeanSFRoraGPR ADDWFfilereg ,D Wherefilereg istheregisterdestinationandDis thebit

Instructionsetofpic16 Instruction set of pic16

PIC16Instructionsetsummary continued d

PIC18