3. Introduction to PIC Microcontroller
• Introduction to PIC Microcontroller
• PIC 16C6x Architecture
• PIC16C7x Architecture
• PIC16Cxx–Pipelining
• Program Memory considerations
• Register File Structure
• Addressing modes
• Instruction Set
• Simple Operations
4. Why PIC has become popular ???
• Low cost
• Wide availability
• Large user base
• Easy of availability of its supporting hardware
and software tools like assemblers, debuggers
and simulators
• Re-programming with flash memory capability
• Easy to interface with other peripherals
6. PIC - Introduction
• Power on Reset
• ROM/OTP/EPROM/ROM/Flash
• 8 level stack
• Powerful output pin control
• Up to 12 independent interrupt sources
• Direct and Indirect addressing modes
• Timers
• Serial Programming
7.
8. PIC 16C6x Architecture
• High performance RISC CPU
• 8 bit microcontroller
• Low cost, High performance, CMOS, fully static
microcontroller
• Only 35 single word instructions
• Interrupt capability
• Eight level deep hardware stack
• Direct and Indirect addressing modes
• Power-on Reset (POR)
• Power-up Timer (PWRT)
• Oscillator Start-up Timer (OST)
9. PIC 16C6x Architecture
• Watchdog Timer (WDT)
• Programmable code-protection
• Power saving SLEEP mode
• Selectable oscillator options
• Low-power, high-speed CMOS EPROM/ROM
technology
• Fully static design
• Wide operating voltage range: 2.5V to 6.0V
• Commercial, Industrial, and Extended
temperature ranges
• Low-power consumption
10. PIC 16C6x Peripheral Features
• Three timers: Timer0, Timer1, Timer2
– Timer0 : 8-bit timer/counter with 8-bit prescaler
– Timer1 : 16-bit timer/counter with prescaler, can
be incremented during sleep via external
crystal/clock
– Timer2 : 8-bit timer/counter with 8-bit period
register, prescaler and postscaler
• Capture/Compare/PWM (CCP) module(s)
– Capture is 16-bit, max resolution is 12.5 ns
– Compare is 16-bit, max resolution is 200 ns
– PWM max resolution is 10-bit
11. PIC 16C6x Peripheral Features
• Synchronous Serial Port (SSP) with SPI and I2C
• Universal Synchronous Asynchronous Receiver
Transmitter (USART/SCI)
• Parallel Slave Port (PSP) 8-bits wide, with
external RD, WR and CS controls
• Brown-out detection circuitry for Brown-out
Reset (BOR)
12. Harvard Architecture and Pipelining
PIC 16C6x/7x family of microcontrollers use
Hardware architecture to achieve an fast
execution speed for a given clock.
15. PIC Registers
• W - Reg
• Status Register
• FSR – File Select Register
• INDF
• Program Counter
• PCL
• PCLATCH
• Eight Level Stack
16. PIC Registers
• Working Register:(W - Register)
– Working Register is a 8-bit register used by many
instructions as the source of an operand.
– It also serves as the destination for the result of
instruction execution and it is similar to
accumulator in other Microcontrollers and
Microprocessors.
– It is a 8-bit regarding.
ADDWF f, d
17. PIC Registers
• Status Register:
– It contains the arithmetic status of the ALU, the
RESET status and the bank select bits for the data
memory.
18. PIC Registers
• Status Register:
– C: Carry/borrow bit
– DC: Digit carry/borrow bit
– Z: Zero bit
– NOT_PD: Reset Status bit (Power-down mode bit)
– NOT_TO: Reset Status bit (tme- out bit)
– RPO: Register bank Select
– The bits 7 and 6 of Status Register are unused by
16c6x/7x.
19. PIC Registers
• The ‘C’ bit is set when two 8-bit operands are added
together and a 9-bit result occurs. This 9-bit is placed in
the carry bit.
• The DC or Digit carry bit indicates that a carry from the
lower 4 bits occurred during an 8-bit addition.
Example:
0011 1000
0011 1000
----------------
0111 0000
---------------
Here DC=1 as a result of the carry from the bit 3 to the
bit 4 position.
20. PIC Registers
• The Z or zero bits is affected by the execution
of arithmetic or logic instructions.
• The reset status bits NOT_TO and NOT_PD are
used in conjunction with PIC’s sleep mode.
The micro controller can put itself to sleep
mode to save power during intervals when it
has nothing to do. Upon reset the CPU can
check these two reset status bits to determine
which kind of event resettled it and then
respond accordingly.
21. PIC Registers
• The Register bank select bit RPO is used to
select either bank .
When RPO=0, select Bank 0,
RPO=1, select Bank 1.
• Example:
bcf STATUS, RPO //Select bank 0
bsf STATUS, RPO //Select bank 1.
22. PIC Registers
• FSR – (File Select Register):
– It is the pointer used for indirect addressing.
– In the indirect addressing mode the 8-bit register
file address is first written into FSR.
– It is a special purpose register that serves as an
address pointer to any address through out the
entire register file.
• INDF – (Indirect File):
– It is not a physical register addressing, this INDF
will cause indirect addressing.
– Any instruction using the INDF register actually
access the register pointed to by the FSR.
23. PIC Registers
• PCL:
– PCL is actually the lower 8-bits of the 13-bit program
counter.
– It can be read like any other register.
• PCLATH (Program Counter Latch):
– Upper bits of are not readable but are indirectly
writable .
– The upper 3-bits of PCLATH remains zero and serves no
purpose.
Progarm Counter :
24. Watch Dog Timer (WDT):
A Watch dog timer is a simple timer circuit
that performs a specific operation after a certain
period of time if something goes wrong.
28. Program Memory Considerations
Program memory access for PIC parts having 2K of
program memory.
• PIC family uses 13-bit program counter allowing the
controllers to an 8k- program memory without changing the
CPU structure.
31. Two addresses in the program memory address space are treated
in a special way by the CPU.
• When the CPU starts up from its reset state, its program
counter is automatically cleared to zero. with the content of
address H'000’being a go to Mainline instruction.
• The second special address H'004', is automatically loaded
into the program counter when an interrupt occurs.
33. Data Memory
The data memory of PIC 16F8XX is partitioned into multiple
banks which contain
• General purpose registers
• Special function Registers.(SFRs).
The bits RP1 and RP0 bits of the status register are used
to select these banks
40. INSTRUCTION SET OF PIC
• Instruction set of PIC are divided into three
basic categories,
• Byte Oriented Instruction
• Bit Oriented Instruction
• Literal and Control Instruction
120. Reference :
• Peatman,J.B., “Design with PIC Micro
Controllers”PearsonEducation,3rdEdition, 2004.
• Mazidi, M.A.,“PIC Microcontroller” Rollin Mckinlay,
Danny causey Printice Hall of India, 2007.