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

PIC Microcontroller - r2

The document discusses the PIC16C7x microcontroller. It describes the microcontroller's architecture including the ALU, status register, data memory with FSR and INDF registers, program memory, oscillator types, instruction types like BTFSC and DECFSZ, and provides an example of blinking an LED using registers like TRIS and PORT to set the pin direction and output data. It also shows using a delay subroutine to control the LED on/off timing.

Uploaded by

g3v5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

PIC Microcontroller - r2

The document discusses the PIC16C7x microcontroller. It describes the microcontroller's architecture including the ALU, status register, data memory with FSR and INDF registers, program memory, oscillator types, instruction types like BTFSC and DECFSZ, and provides an example of blinking an LED using registers like TRIS and PORT to set the pin direction and output data. It also shows using a delay subroutine to control the LED on/off timing.

Uploaded by

g3v5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 48

PIC Microcontroller

PIC16C6x/PIC16C7x
Microprocessor vs Microcontroller
Criterion For Selecting Microcontrollers

• Microcontroller Features
– Speed
– Packaging
– Power consumption
– RAM and ROM
– No. of I/O pins
• Support
• Availability
General Block Diagram
Microcontroller
Oscillator Types
• LP – Low Power crystal (32 kHz – 200 kHz)
• XT – Crystal /Resonator (200 kHz -4MHz)
• HS- High Speed crystal/Resonator (4-20 MHz)
• RC – Resistor/Capacitor – timing insensitive
application

*FOSC1 and FOCS0 bits configured to select any one


of the above four modes in CONFIG register
Oscillator
• RC
• LP
• XT
• HS
Architecture PIC16C7x
Architecture
ALU
• 8-bit ALU
• Arithmetic and Boolean
functions 8-bit data
8 –bit immediate
from
• One operand from W data
register
register
• Other operand is a file
register or an immediate
constant
• W register is not addressable
• ALU operation affects flag
Z,C,DC in STATUS register
Status Register

• Z- Zero flag • RP0-RP1 – Register


• DC- Digit Carry bank select direct
• C - Carry • IRP – Register bank
• PD - Power Down select Indirect
• T0 – Time Out
Data Memory
Addressing Modes
• FSR Register(File Selection Register, address = 04H,
84H)
FSR is an 8-bit register used as data memory address
pointer. This is used in indirect addressing mode.
• INDF Register
• (INDirect through FSR, address = 00H, 80H)
INDF is not a physical register. Accessing INDF access
is the location pointed to by FSR in indirect
addressing mode.
INDF and FSR
• INDF -Addressing this location uses contents of FSR to address
data memory
• FSR- File Select Register
• Example: clear 0x20 to 0x2F

Movlw 0x20
Movwf FSR Move 0x20 to FSR
Next: clrf INDF
incf FSR, F
Clear address pointed by FSR
btfss FSR,4
goto Next
All done?
…..
PCL
Program Memory

• PROM
• EPROM
• EEPROM
• Flash
Pin Diagram

Port B
Port A

Port C
Brown Out Detection
ALU
PIC Features
Clock
Pipeline
Program memory
SFR
Temperature Sensor
Instruction Types
Instruction Set
Q Cycle Activity
BTFSC

If bit 'b' in register 'f' is '0' then the next


instruction is skipped.
If bit 'b' is '0' then the next instruction
(fetched during the current instruction execu
tion) is discarded, and a NOP is executed
instead, making this a 2 cycle instruction.
DECFSZ
COMF
Decrement a 16 bit value
• movf countL ,f
• btfsc status , z
• decf countH, f
• decf countL, f
Test a 16 bit variable for zero
LED ON and OFF
• LED is connected to PORT A 2 pin (RA1)
• Registers involved
– TRIS A ( Direction)
– PORT A ( Data)

– TRISA is in Bank 1
– PORTA is in Bank 0
Program
bsf STATUS 5 ; select bank 1
movlw FD h ; RA1 as output
movwf TRISA ;
bcf STATUS 5; select bank 0
START: Movlw 02 h;
Movwf PORTA ; Turn on LED
Movlw 00 h;
Movwf PORTA ; Turn off LED
goto START
Delay
• Count1 equ 30 h
• Count2 equ 31 h
• Delay subroutine
loop1: Decfsz count1,1
goto loop1
Decfsz count2,1
goto loop1
Program
bsf STATUS 5 ; select bank 1
movlw FD h ; RA1 as output
movwf TRISA ;
bcf STATUS 5; select bank 0
START: Movlw 02 h;
Movwf PORTA ; Turn on LED
Call delay
Movlw 00 h;
Movwf PORTA ; Turn off LED
Call delay
goto START

You might also like