Microprocessor and  Microcontroller

Isra University Spring Semester, 2012 Spring Semester, 2012 Instructor : Fahad Al Ghazali

Miccorontroller module of Course module of Course
• Microcontrollers : PIC Series Microcontrollers : PIC Series

• PIC Microcontrollers are fabricated by PIC Microcontrollers are fabricated by  Microchip • These microcontrollers have many series These microcontrollers have many series  • Like PIC10,12,16,18 etc.  • Depend upon the in‐built features like RAM,  Flash/EEPROM,ADCs, Ethernet , USB drivers  etc.

ADC . data  O hi ( d ) O d RAM. USART and I/O ports • ROM : 128 k to2MB • OTP types : One‐type programmable (cheap  yp yp p g ( p solution )  .timers.PIC 18 PIC 18 • Has RISC architecture Has RISC architecture  • Reduced instruction set architecture • Has ON‐chip program (code) ROM.

Block Diagram Block Diagram .

Detailed  Detailed Block  Diagram i .

PIC with UV EEPROM & Flash PIC with UV‐EEPROM & Flash • • • • • • PIC come with UV EEPROM PIC come with UV‐EEPROM Require UV‐EPROM burner Takes ~20 minutes k 20 i Thus Flash version is introduced  The letter F in the series name like  PIC18F452 represents that the Flash memory  PIC18F452 represents that the Flash memory is used in this IC .

PIC IC Comparisons PIC IC Comparisons .

  • The letter C means the OTP version like  PIC18C432 . microchip can create  inexpensive devices in bulk for you with your  inexpensive devices in bulk for you with your hex file burnt • Reguires MOQ MOQ.OTP VERsion and the masked version OTP VERsion and the masked version • If the design is out of development and If the design is out of development and  debugging phase .

PIC Trainer PIC Trainer • Chapter 8 of the book Chapter 8 of the book  “ PIC microcontroller and the embedded  systems in Assembly and C  systems in Assembly and C By “ Danny Causey “  and Muhammad Al Mazidi .

 USART .  CAN Bus interfaces and the USB ethernet CAN B i f d h USB h interfaces which cut short the design cycle . ruggedized architectures • But support for the PIC is much stronger for  creating large projects  creating large projects • Built‐in C libraries are there RTOS.8051 Vs PIC 8051 Vs PIC • Both of them ruggedized architectures Both of them.

 move literal value K into WREG • MOV LW 25H .WREG Register WREG Register • The WREG register is the mainly used for The WREG register is the mainly used for  arithmetic and logic operations  • It is one of these registers It is one of these registers • Used to store temporary information . moves 25 to W .  values results . l l • MOVLW .etc. data .

ADDLW • ADDLW instruction adds into the value of ADDLW instruction adds into the value of  WREG • ADDLW K . add literal value K to WREG . add literal value K to WREG ADDLW K .

PIC WREG and ALU using Literal Value PIC WREG and ALU using Literal Value .

SFRs .

Tools and hardware Tools and hardware • Softwares for coding and debugging for coding and debugging  – MPLAB ( by microchip) – MicroC ( by microElectronika) ( by microElectronika) .

Hardware • Training board Available in University Training board Available in University • Its documentation is uploaded on group .

PIC development Kit PIC development Kit .

Software for programming Software for programming • The kit supports in‐circuit programmability The kit supports in circuit programmability  • Software for programming is uploaded in  group .

Steps • First code is written First code is written • Converted to hex  • Downloaded onto the PIC using JDM Downloaded onto the PIC using JDM  programmer (while programming. the LCD.  MAX232 IC and the USB connection should be  MAX232 IC and the USB connection should be unconnected) • After programming the serial cable should be After programming the serial cable should be  disconnected and the USB power cable  mounted for checking the code .

File registers (Data ram )  File registers (Data ram ) • File registers are read/write memory used by File registers are read/write memory used by  the CPU for data storage ad registers for  internal use and functions internal use and functions • They are divided into two  • G General Purpose RAM  lP RAM • Special Function Registers .

 Serial communication I/O ports .g.Special Function registers Special Function registers • These are used for special purposes or These are used for special purposes or  interfaces e.

General Purpose Registers General Purpose Registers • Group of RAM locations in the file registers Group of RAM locations in the file registers  that are used for data storage and scratch pad • Each location in 8 bit wide Each location in 8 bit wide  .

move literal value 0x0a to MOVLW 0x0a . move literal value  0x0a to  WREG register • MOVLW 25H MOVLW 25H .MOVLW instruction MOVLW instruction • MOVLW 0x0a .

ADDLW Instruction  ADDLW Instruction • Adds value in WREG register Adds value in WREG register • MOVLW 25H. add value 34to W (W=W+34) 3 dd l 3 ( 3 ) . load25h in wreg • ADDLW 34H.

Status Registers in PIC18 Status Registers in PIC18 • The status register is just like FLAGS register in The status register is just like FLAGS register in  8086 .

 Power save . 1 : power  up  up .Status registers in PIC16f87x Status registers in PIC16f87x • • • • IRP : Inter bank select bit for indirect addressing IRP : Inter bank select bit for indirect addressing RP1:RP0 .. Bank select TO timer out bit TO timer out bit PD Power down bit (0 sleep .

MOVWF Instruction MOVWF Instruction .

Values at addresses after execution of  instructions  .

Example 2.1 .1 Example 2.

  • File register location can be an SFR or a GPR File register location can be an SFR or a GPR ADDWF filereg .ADDWF instruction ADDWF instruction • ADDWF adds contents of WREG and a file ADDWF adds contents of WREG and a file  register location. D Where filereg is the register destination and D is  the bit .

Instruction set of pic16 Instruction set of pic16 .

PIC16 Instruction set summary  continued d .



PIC18 .

Sign up to vote on this title
UsefulNot useful