PIC Microcontrollers
PIC Microcontrollers
PIC16F877a
A.Suyampulingam
Assistant Professor(Sr.Gr)
Introduction
What is PIC?
A family of Harvard architecture microcontrollers made by
Microchip Technology.
Micro Controller : Micro Processor + Peripherals
Derived from the PIC1650 originally developed by General
Instrument Microelectronics Division.
The name PIC was originally an acronym for "Programmable
Intelligent Computer".
The name PIC is referred to Peripheral Interface Controller.
It shares some common features with RISC designs.
Introduction
Why PIC is popular?
low cost ,wide availability with high clock speed
of low cost or free development tools
Only 35 instructions to remember
serial programming and re-programming with flash
memory capability
Its code is extremely efficient, allowing the PIC to run
with typically less program memory than its larger
competitors
PIC is very small and easy to implement for non-complex
problems and usually accompanies to the microprocessors
as an interface
Two Different Architectures
Harvard Architectures Von-Neumann Architecture
(newer arch.)
Two Different Architectures
Harvard Architectures Von-Neumann Architecture
32 bit microcontroller(PIC32FXX,PIC32MX)
The PIC Family: Speed
12C50X 4MHz
12C67X 10MHz
16F877 20MHz
17C4X/17C7XXX 33MHz
18CXXX 40MHz
Can use crystals, clock oscillators, or even an RC
circuit.
Some PICs have a built in 4MHz RC clock, Not very
accurate, but requires no external components!
Instruction speed = 1/4 clock speed (Tcyc = 4 * Tclk)
All PICs can be run from DC to their maximum
specified speed:
Clock and Instruction Cycles
Instruction Clock
Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of a
microcontroller divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do not
overlap.
These four clocks make up one instruction cycle (also called machine cycle) during which
one instruction is executed.
Execution of instruction starts by calling an instruction that is next in string.
Instruction is called from program memory on every Q1 and is written in instruction
register on Q4.
Decoding and execution of instruction are done between the next Q1 and Q4 cycles. On
the following diagram we can see the relationship between instruction cycle and clock of
the oscillator (OSC1) as well as that of internal clocks Q1-Q4.
Program counter (PC) holds information about the address of the next instruction.
The PIC Family: Program Memory
Technology: EPROM, FLASH, or ROM
It varies in size from one chip to another.
18FXXXX <= 75 x 16
8 <= 128 KB <= 16 High range, CAN, USB
100 bits
J series 3V supply, C program
76 x 24
24FXXXX <= Power range, 3V supply, no
16 <= 128 KB bits = 16
100 EEPROM,
data RAM < 8 KB, C program
PIC16F877a Architecture
PIC Program Memory
PIC16F877a Data Memory
Direct/Indirect Addressing
PIC Family Control Registers
PORTA PORTB
PORTD
PORTC PORTC
PORTD
Interrupts sources in the PIC 16F877
Interrupt Source Interrupt trigger event CCS C Interrupt label
TIMERS
Timer 0 Timer 0 register overflow INT_TIMER0
Timer 1 Timer 1 register overflow INT_TIMER1
CCP 1 Timer 1 capture or compare detected INT_CCP1
Timer 2 Timer 2 register overflow INT_TIMER2
CCP2 Timer 2 capture or compare detected INT_CCP2
PORTS
RB0/INT pin Change on single pin RB0 INT_EXT
Port B pins Change on any of four pins RB4 RB7 INT_RB
Parallel Slave Port Data received at PSP (write input active) INT_PSP
Analog Converter A/D conversion completed INT_AD
Analog Comparator Voltage compare true INT_COMP
SERIAL
UART Serial Port Received data available INT_RDA
UART Serial Port Transmit data buffer empty INT_TBE
SPI Serial Port Data transfer completed (read or write) INT_SSP
I2C Serial Port Interface activity detected INT_SSP
I2C Serial Port Bus collision detected INT_BUSCOL
MEMORY
EEPROM Non-volatile data memory write complete INT_EEPROM
PIC Peripherals: Timers
Available in all PICs.
1 2
Start counter Run
statement Counter
until
overflow
Program Execution
3
Timeout
Interrupt
7
Continue
5
Time-out
Process
(Interrupt
Service 6
Routine) Return
from
Interrupt