You are on page 1of 57

UNIT V & VI

GOGA SUBRAMANYAM
9849447561
PIC MICROCONTROLLER
• In 1989 MICROCHIP Technology introduce 8-bit
PIC microcontroller.
• PIC Stands for “Peripheral interface Controller”
• Some PIC microcontroller Family's are
PIC 10XX
PIC 12XX
PIC 14XX
PIC 16XX
PIC 18XX
PIC MICROCONTROLLER
• Program Memory Types is indicated by an
alphabet
C = EPROM
F = Flash
RC = Masked ROM
FEATURES OF PIC 18
• High Performance RISC CPU:
8-bit CPU
PIC16 source code compatible
Linear program memory addressing to 2 Mbyte
Linear data memory addressing up to 4 Kbytes
Up to 10 MIPs operation: – DC - 40 MHz osc/clock
16-bit wide instructions, 8-bit wide data path
8 x 8 Single Cycle Hardware Multiplier
77 instructions
C-Language friendly architecture
FEATURES OF PIC 18
• Peripheral Features:
High current sink/source 25 mA/25 mA
Up to Three external interrupt pins
Up to three 16-bit timer/counters
ONE 8-bit timer/counters with 8-bit period register
(time-base for PWM)
Up to Two Capture/Compare/PWM (CCP) modules
Master Synchronous Serial Port (MSSP) module
Up to 2 Addressable USART modules
 Parallel Slave Port (PSP) module
FEATURES OF PIC 18
• Analog Features:
 10-bit Analog-to-Digital Converter module (A/D)
Programmable Low Voltage Detection (LVD)
module – Supports interrupt-on-low voltage
detection
Programmable Brown-out Reset (BOR)
Comparators
FEATURES OF PIC 18
• Special Microcontroller Features:
Power-on Reset (POR), Power-up Timer (PWRT)
and Oscillator Start-up Timer (OST)
 Watchdog Timer (WDT) with its own on-chip RC
oscillator for reliable operation
Programmable code protection
In-Circuit Serial ProgrammingTM (ICSPTM) via two
pins
FEATURES OF PIC 18
• CMOS Technology:
Fully static design
Wide operating voltage range (2.0V to 5.5V)
Industrial and Extended temperature ranges
Power Managed Features:
Dynamically switch to secondary LP oscillator
Internal RC oscillator for ADC operation during SLEEP
SLEEP mode (IPD < 1 µA typ.)
Internal RC oscillator for WDT (period wake-up)
RAM retention mode (VDD as low as 1.5V)
Up to 6 more Power Managed modes available on selected
models
COMAPRISION BETWEEN 8051 AND PIC 18
8051 PIC 18
8051 IS 8-BIT MICRO PIC IS ALSO A 8-BIT MICRO
CONTROLLER CONTROLLER
IT is Having 128 Bytes Of RAM IT is Having 4k Bytes Of SRAM
IT is Having 4k Bytes Of Program IT is Having 2M Bytes Of Program
Memory Memory
It is having TWO Timers T0,T1 It is having FOUR Timers T0,T1,T2
and T3
It is having One UART It is having One USART,SPI,I2C
It is Not having CCP and PWM It is having TWO CCP and ONE
modules PWM modules
It is having 32 IO Pins(P0,P1,P2,P3) It is having 34 IO
Pins(PA,PB,PD,PE,PF)
It is not having in built ADC It is having in built 10Bit ADC(8-
channel)
Architecture of PIC18 Microcontroller
T3 RAM
4KB

Program
Memory 2MB
MEMORY ORGANIZATION
• There are three memory blocks in Enhanced
MCU devices. These memory blocks are:
Enhanced Flash Program Memory
Data Memory
EEPROM Data Memory
Note: Data and program memory use
separate busses
MEMORY ORGANIZATION
MEMORY ORGANIZATION
• PIC18 Data Memory
The PIC18 data memory is implemented as SRAM.
Each location in the data memory is also referred
to as a register or file register
The PIC18 MCU supports 4096 bytes of data
memory
It requires 12 bits of address to select one of the
data registers
MEMORY ORGANIZATION
Because of the limited length of the PIC18
instruction (most instructions are 16 bits)
 only eight bits of the PIC18 instruction are used
to specify the file register to be operated on.
 As a result, the PIC18 designers divided the
4096 file registers into 16 banks.
Only one bank of 256 file registers is active at
any time.
MEMORY ORGANIZATION
An additional four bits are placed in a special
register called bank select register (BSR) to
select the bank to be active.
 The user needs to change the contents of the
BSR register in order to change the active
bank
There are two types of registers:
general-purpose registers (GPRs)
special function registers (SFRs).
MEMORY ORGANIZATION
• GPRs are used to hold dynamic data when the
PIC18 CPU is executing a program.
• SFRs are registers used by the CPU and
peripheral modules for controlling the desired
operation of the MCU
MEMORY ORGANIZATION
• EEPROM Data Memory
 At the time of this writing, all the PIC18 devices that
have on-chip flash program memory also have either
256 bytes or 1024 bytes of data EEPROM.
 The data EEPROM is readable and writable during
normal operation over the entire power supply range.
 The data EEPROM memory is not directly mapped in
the register file space. Instead, it is indirectly addressed
through the special function register.
Program Memory Organization
• Program Memory Organization
Each PIC18 member has a 21-bit program
counter and hence is capable of addressing
the 2-MB program memory space
The address 000000h is assigned to the reset
vector, which is the program-starting address
after power-on or manual reset.
Program Memory Organization
The address 000008h is the starting address of
the high-priority interrupt service routine.
Sixteen bytes are allocated to the high priority
interrupt service routine by default.
The address 000018h is the starting address
for the low-priority interrupt service routine,
and there is no default size for this service
routine
PIC-18 STATUS REGISTER OR FLAG REGISTER

Bit Description

7-6-5 Reserved

N: Negative Flag bit


 1 = Indicates result of Signed Arithmetic Operation generated Negative result (Sign
4 bit of result=1)
 0 = Indicates result of Signed Arithmetic Operation generated Positive result (Sign
bit of result=0)

OV: Overflow flag bit


 1 = Indicates result of Signed Arithmetic operation generated carry from D6 to D7
3 bit
 0 = Indicates result of Signed Arithmetic operation not generated carry from D6 to
D7 bit
PIC-18 STATUS REGISTER OR FLAG REGISTER
Z: Zero flag bit
2  1 = Indicates result of Signed or Unsigned Arithmetic operation is ZERO
 0 = Indicates result of Signed or Unsigned Arithmetic operation is NON-ZERO

DC: Digital Carry bit


 1 = Indicates result of Unsigned Arithmetic operation generated carry from D3 to D4
1
bit i.e. Lower nibble to Higher nibble
 0 = No carry from Lower nibble to Higher nibble

C: Carry bit
 1 = Indicates result of Unsigned Arithmetic operation generated carry from D7 bit
0 i.e. Carry out of MSB
 0 = Indicates result of Unsigned Arithmetic operation generated NO carry from D7
bit i.e. No carry
INTERNAL REGISTERS OF PIC18
WREG (W)
Working Register , same as that of Accumulator in
8051
Size - 8 bits
Function - Used to store Result of Arithmetic and
Logical operations performed by CPU
INTERNAL REGISTERS OF PIC18
BSR: Bank Select Register (0 to F)
4-bit Register
Function - used to select perticular Memory
Bank of data memory (16 Memory Banks i.e.
BANK0 to Bank15)
INTERNAL REGISTERS OF PIC18
 Special Function Registers SFRs:
 Data registers associated with I/O ports, support
devices, and processes of data transfer
 I/O Ports (A to E)
 Interrupts
 EEPROM
 Serial I/O
 Timers
 Capture/Compare/PWM (CCP)
 Analog-to-Digital (A/D) Converter

You might also like