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

Lecture 3

The document provides an overview of the PIC microcontroller family introduced by Microchip, detailing its architecture, features, and comparisons with the 8051 family. It highlights the advantages of PIC microcontrollers, such as high performance and low cost, while also noting compatibility issues across different PIC families. Additionally, it discusses specific models like the PIC 18F series, their memory organization, and instruction set examples for programming.

Uploaded by

vinod SALUNKHE
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lecture 3

The document provides an overview of the PIC microcontroller family introduced by Microchip, detailing its architecture, features, and comparisons with the 8051 family. It highlights the advantages of PIC microcontrollers, such as high performance and low cost, while also noting compatibility issues across different PIC families. Additionally, it discusses specific models like the PIC 18F series, their memory organization, and instruction set examples for programming.

Uploaded by

vinod SALUNKHE
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Lecture 3

PIC Microcontroller
Peripheral Interface Controller
 Microchip introduced an 8 bit microcontroller in 1989 called PIC
 PIC family includes 10xxx, 12xxx, 14xxx, 16xxx, 17xxx, 18xxx series
 They all are 8 bit processors, i.e. CPU can work 8-bit data at a time.
 One majaor problem with PIC family is that they are not completely compatible in terms of
software when going from one family to another family.
Comparison of 8051 and PIC18
family
Feature 8951 (8051 Family) PIC18 (PIC Family)
Architecture 8-bit Harvard 8-bit Harvard
Instruction Set CISC (Complex Instruction Set RISC (Reduced Instruction Set Computing)
Computing)
Clock Speed Typically up to 33 MHz Typically up to 64 MHz
Memory Separate code (ROM) and data (RAM) Separate code (Flash) and data (RAM) memory
memory
Program Memory ROM/Flash (4KB–64KB) Flash (Up to 128KB)
Data Memory Internal SRAM (128B–256B) + External Internal SRAM (Up to 4KB)
RAM

Number of Registers 8 General-Purpose Registers (R0-R7) Many General-Purpose Registers

GPIO (I/O Pins) 4 Ports (32 I/O pins) Varies, up to 70 I/O pins
Timers 2 or 3 Timers Multiple Timers with CCP (Capture/Compare/PWM)

Interrupts Limited (6 sources) Advanced interrupt handling


ADC Support No (requires external ADC) Yes (10-bit or 12-bit ADC)

PWM Support No (requires external PWM) Yes (with CCP modules)

Communication Interfaces UART, I²C, SPI (with external modules) Built-in UART, I²C, SPI, USB, CAN (depending on
model)
PIC Microcontroller

 PIC 16CXX, PIC18FXX are 8-bit microcontrollers by Microchip.


 It uses High-speed RISC Architecture.
 PIC microcontrollers are popular due to high performance, low cost, and small size.
 Mostly single-word instructions, except for four two-word instructions.
 Operating frequency for 18CXX – DC to 40 MHz.
 Some advanced versions include ADC with 4-8 channels.
 General features include Timers, Watchdog Timers, ADC, Extended Instruction/Data
Memory, Serial Communication, Capture/Compare/Pulse Width Modulation (CCP).
Comparison of PIC Family
PIC Pins Flash/ Timers I/O Pins / Addition
Family RAM ADC al
Memory Channel Features
Range s
PIC 6 896 B / 64 8-bit (2), 4 / 2 ch. ---
10CXX B PWM (2) 8-bit
PIC 8 3.5 KB / 8-bit (2), 6 / 3 ch. USART (1)
12CXX 128-256 B 16-bit 8-bit
(1), PWM
(2)
PIC 14-40 7-28 KB / 8-bit (4), 12 / 4 ch. WDT,
16FXX 512 B-2 KB 16-bit 10-bit Data
(1), PWM EEPROM,
USART,
I²C, SPI
EEPROM
PIC 40-100 2 MB / 32- 3 Timers, 33-72 / USB, 12-
18FXX 128 KB WDT, 12 ch. 10- bit ADC,
PWM bit USART,
New for 18 Series
• The number of instructions more than doubled, with 16-bit instruction word
• Enhanced Status Register
• Hardware 8 × 8 multiply
• More external interrupts
• Two prioritized interrupt vectors
• Radically different approach to memory structures, with increased memory size
• Bigger stack, with some user access and control
Selection Criteria for PIC
Microcontroller
• Speed
• Amount of RAM/ROM
• Number of I/O pins, Timers
• Power consumption
• Availability of tools
• Added features like ADC/DAC/CCP, Bus support like CAN, SPI, I2C, USB.
• Watchdog timer, Timer modes, Data EEPROM etc.
Features of IC 18F452/458
 Program memory: 2MBytes ROM [21 Address line]
 Data RAM: 4KBytes [12 Address lines]
 Flash ROM: 32 KB
 Data EEPROM: 256 bytes - for storing critical information
 10 bit, 8 channel ADC
 5 ports A[6], B,C,D[8], E[3] =33 IO lines
 Capture/compare/pulse width modulation
Features of PIC 18F458
High-Performance RISC CPU:
• Three external interrupt pins
• Has 15 bank registers with 256 entries, GPR [variable] and SFR [fixed locations]
• Priority levels for interrupts.
• USART, 3 Timers/Counters 8-bit/16-bit timer/counter with 8-bit programmable prescaler
• DC-40 MHz clock Input
• High current sink/source 25 mA/25 mA
PIC18 Architecture

PIC18 Architecture Block


Diagram
PIC18 Features:
⚫ CPU core
⚫ The function of the CPU is to execute
(process) information stored in memory.

⚫ Program ROM
⚫ The ROM use to store program.
PIC18 Features (cont’d)
⦿ Data Memory
 The data memory is SRAM and EEPROM.
 provides a place to store data as application
executes and is lost when power is removed from
the system.

⦿ EEPROM
 also a nonvolatile memory which is used to
store data like values of certain variables.
PIC18F4550 has 256 Bytes of EEPROM.
PIC18 Features (cont’d)
⚫ I/O Ports:
⚫ The I/O ports are used to interface the
microprocessor to the outside world.

PIC18F4550 pin diagram.


Other internal Devices

• Oscillator
• 8x8 Multiplier
• ADC Interface
• Timers/Counters
• USB
PIC18 Registers
• CPUs use many registers to store data
temporarily.

• To program in assembly language, we must


understand the registers and architecture of given
CPU and the role they play in processing data.
PIC18 Registers
• PIC microcontroller contains an 8-bit ALU (Arithmetic
Logic Unit) and an 8-bit Working Register (WREG).

• There are different GPRs (General Purpose Registers)


and SFRs (Special Function Registers) in a PIC
microcontroller.

• The overall system performs 8-bit arithmetic and logic


functions.
PIC registers
WREG Register
• Stand for Working register
• 8-bit register
• Use for all arithmetic and logic instructions.
• Used by many instructions as:
• the source of an operand.
• the destination for the result of the
instruction execution.
PIC File Register

• The file register is read/write memory used by


CPU for data storage, scratch pad, and
register for internal use and functions.
• Divided into two sections:
• Special Function Registers (SFR)
• General Purpose Registers (GPR)
General Purpose Register (GPR)
• 8-bit registers
• A group of RAM locations in the file
register that are used for data storage and
scratch pad.
• The space that is not allocated to the SFRs
typically used for general-purpose registers.
Special Function Register (SFR)

 SFR are dedicated to specific functions such as ALU status, timers, serial communication, I/O
ports, ADC and so on.
 The function of each SFR is fixed by the CPU designer at the time of design.
 8-bit registers
Memory Organisation of PIC 18
Instruction Set
 MOVWF
 The MOVWF (Move WREG to File Register) instruction in the PIC18
microcontroller is used to transfer the contents of the WREG (Working
Register) to a specified file register in RAM.
 MOVWF Syntax:
 MOVWF f, a
 f- destination file register (address in RAM)
 a- access bank selection bit

 Ex.
 MOVLW 0x55 ; Load WREG with 0x55
 MOVWF 0x20, 0 ; Store WREG content (0x55) into RAM location 0x20
Instruction Set
 Example 1
 Q. State the content of file register RAM location after the following
program:
 MOVLW 99H
 MOVWF 12H
?
 MOVLW 85H
 MOVWF 30H
?
Instruction Set
 COMF Instruction
 MOVLW 55H
 MOVWF PORTB
 COMF PORTB, F
Instruction Set
Q. Write a simple program to toggle the SFR of PORT B continuously forever
Ans:
MOVLW 55H
MOVWF PORTB
B1 COMF PORTB, F
GOTO B1
Instruction Set
 DECF Instruction
 The DECF (Decrement File Register) instruction in the PIC18 microcontroller decrements the
value of a specified file register by 1 and stores the result in either the same file register or the
WREG.
 Ex.
MOVLW 0x05 ; Load WREG with 5
MOVWF 0x20 ; Store 5 in register 0x20
DECF 0x20, F ; Decrement register 0x20 and store result in 0x20
Instruction Set
 MOVF Instruction
 The MOVF (Move File Register) instruction in the PIC18 microcontroller moves the value of
a specified file register to either the WREG or the same file register while affecting status
flags.
 Ex.

AGAIN MOVF PORTB, W ; bring data from Port B into WREG


MOVWF PORTC ; send to the Port C
GOTO AGAIN ; keep doing it forever
Instruction Set
 Ex. Write a program to get data from the SFR of PORT B. Add the value 5 to it and send it to
SFRs of Port C
Instruction Set
 Ex. Write a program to get data from the SFR of PORT B. Add the value 5 to it and send it to
SFRs of Port C
MOVF PORTB, W ; bring data from Port B into WREG
ADDLW 05H ; add 5 to WREG
MOVWF PORTC ; send to the Port C

You might also like