SlideShare a Scribd company logo
UNIT-V
PIC16F877 MICROCONTROLLER
11/2/2023 1
11/2/2023 2
UNIT-V (Syllabus)
8 bit microcontroller.
Operating Speed: Up to 20 MHz
Flash program memory (14 bit words), 8KB.
Data memory:Data SRAM: 368 bytes &Data EEPROM:
256 bytes.
Power-saving Sleep mode.
5 input/output ports
It has 15 interrupt signal.
Three timers
35 instructions
10bit A/D module (8 channels)
In-Circuit Serial Programming via two pins (5V)
Watchdog Timer with on-chip RC oscillator.
11/2/2023 3
FEATURES
11/2/2023 4
The main features of PIC microcontrollers are RAM, flash memory, Timers/
Counters, EEPROM, I/O Ports, USART, CCP (Capture/Compare/PWM module),
SSP, Comparator, ADC (analog to digital converter), PSP(parallel slave port),
LCD and ICSP (in circuit serial programming) .
The PIC microcontroller architecture comprises of CPU, I/O ports, memory
organization, A/D converter, timers/counters, interrupts, serial
communication, oscillator and CCP module which are discussed in detailed
below.
11/2/2023 5
Architecture of PIC16F877
MICROCONTROLLER
11/2/2023 6
PIC microcontroller’s CPU consists of
✔ Arithmetic logic unit (ALU)
✔ Memory unit (MU)
✔ Control unit (CU)
✔ Accumulator
ALU is used for arithmetic operations and for logical
decisions.
Memory is used for storing the instructions after processing.
Control unit is used to control the internal and external
peripherals which are connected to the CPU and accumulator
is used for storing the results.
11/2/2023 7
CPU (Central Processing Unit)
The memory module in the PIC microcontroller architecture
consists of
1. Data Memory (RAM)
2. Data EEPROM
3. Program Memory (FLASH Type)
11/2/2023 8
Memory Organization
RAM is an unstable memory which is used to store the data
temporarily in its registers.
The RAM memory is classified into two banks, and each bank
consists of so many registers.
The RAM registers are classified into two types:
1.Special Function Registers (SFR)
2. General Purpose Registers (GPR).
11/2/2023 9
1.Random Access Memory
(RAM)
General Purpose Registers (GPR):
These registers don’t have any special function.
These are used for general purpose for multiplying, addition or
subtraction and then storing the results in other registers.
CPU can easily access the data in these registers.
Special Function Registers (SFR):
These registers are used for special purposes and they cannot be used
as normal registers.
Their function is set at the time of manufacturing. They perform the
function assigned to them and user cannot change the function of SFR.
Three important SFRs for programming are:
STATUS register : It changes the bank
PORT registers : It assigns logic values 0 or 1 to the ports
TRIS registers : It is a data direction register for input and
output
11/2/2023 10
This memory allows storing the variables as a result of burning the
written program.
It is readable and writable during normal operation (over the full
VDD range).
This memory is not directly mapped in the register file. It is
indirectly addressed through the SFRs.
There are six SFRs which are used to read and write to this memory
1. EECON1
2.EECON2
3.EEDATA
4.EEDATH
5.EEADR
6.EEADRH
11/2/2023 11
2.DATA EEPROM:
It contains the written program after we burned it in
microcontroller.
Program Counter executes commands stored in the
program memory, one after the other.
PIC microcontroller can have 8K words x 14 bits of Flash
program memory that can be electrically erased and
reprogrammed.
Whenever we burn program into the microcontroller, we
erase an old program and write a new one.
11/2/2023 12
3. Program Memory (FLASH
Type)
Serial communication is the method of transferring data one
bit at a time sequentially over a communication channel.
There are three protocols of serial communication:
1.USART
2.SPI (Serial Peripheral Interface)
3.I2C (Inter Integrated Circuit)
1.USART:
❖ It stands for Universal synchronous and Asynchronous
Receiver and Transmitter which provides a serial
communication in two devices.
❖ In this protocol data is transmitted and received bit by bit
through a single wire according to the clock pulses.
❖ To send and receive data serially the PIC microcontroller
has two pins TXD and RXD.
11/2/2023 13
Serial Communication
2.SPI (Serial Peripheral Interface)
❖ SPI stands for Serial Peripheral Interface.
❖ It is used to send data between PIC microcontrollers and other
peripherals like sensors, shift registers and SD cards.
❖ Three wire SPI communications is supported in PIC
microcontroller between two devices on a common clock
source.
❖ SPI protocol has greater data handling capability than that
of the USART.
3.I2C (Inter Integrated Circuit)
❖ I2C stands for Inter Integrated Circuit, and this protocol is
used to connect low speed devices like microcontrollers,
EEPROMS and A/D converters.
❖ PIC microcontroller support two wire Interface or I2C
communication between two devices which can work as
both Master and Slave device.
11/2/2023 14
Interrupts
❖ There are 15 internal interrupts in PIC microcontrollers
which are related with different peripherals like ADC, USART,
Timers, and CCP etc.
Timers/ Counters
❖ PIC microcontroller has 3 timer/counters (T0,T1,T2) where in
the one 8-bit timer and the remaining timers have the choice
to select 8 or 16-bit mode.
❖ Timers are used for generating specific time delays between
two operations.
A/D Converter:
❖ It converts the analog voltage levels to digital voltage values.
In PIC Microcontroller, ADC has 8-channels and has resolution
of 10-bit.
❖ The special function registers ADCON0 and ADCON1 control
the operation of ADC.
11/2/2023 15
CCP module:
The name CCP module stands for capture/compare/PWM
where it works in three modes such as capture mode,
compare mode and PWM mode.
Capture Mode: Capture mode captures the time of arrival of
a signal.
Compare Mode: Compare mode acts as an analog comparator.
PWM Mode: PWM mode provides pulse width modulated
output with a 10-bit resolution and programmable duty cycle.
Oscillators
Oscillators are used for timing generation.
PIC microcontroller consist of external oscillators like RC
oscillators or crystal oscillators.
The range of clock frequency is upto 20MHz.
11/2/2023 16
Input/Output Ports
The series of PIC16f877 consists of five ports such as Port
A, Port B, Port C, Port D & Port E.
❖ Port A is an 6-bit port that can be used as input or output
port based on the status of the TRISA (Tradoc Intelligence
Support Activity) register.
❖ Port B is an 8- bit port that can be used as both input and
output port.
❖ Port C is an 8-bit port that can be used as input or output
port based on the status of the TRISC register.
❖ Port D is an 8-bit port acts as a slave port for connection to
the microprocessor BUS.
❖ Port E is a 3-bit port which serves the additional function of
the control signals to the analog to digital converter.
11/2/2023 17
Watchdog timer is a timer that resets the microcontroller in
case the program gets stuck for an unexpected length
of time.
It’s monitors microcontroller (MCU) programs to see if they
are out of control or have stopped operating.
11/2/2023 18
Watch Dog Timer (WDT)
The instruction set of PIC is divided into Three basic categories. They are
(a) Byte oriented Instructions
(b) Bit oriented Instructions
(c) Literal and Control Instructions
Byte oriented Instructions:
❖ In a byte oriented Instructions ‘f “ represents a file register and’ d’ represents
destination register.
❖ The destination specifies where the result of operation is to be placed. If D= 0
the result is placed in W register(Accumulator).
11/2/2023 19
INSTRUCTION SET
11/2/2023 20
Bit oriented Instructions:
11/2/2023 21
Literal and Control Instructions:
11/2/2023 22
The PIC 18 microcontroller supports following addressing
modes.
1. Immediate addressing mode
2. Direct addressing mode
3. Register addressing mode
4. Indexed ROM addressing mode
1. Immediate addressing mode:
❖ In immediate addressing mode, the immediate data is
specified in the instruction.
❖ The immediate addressing mode is used to load the data into
PIC registers and W register.
❖ However, it cannot use to load data into any of the file
register.
❖ Example: 1. MOVLW 50H
❖ 2. ANDLW 40H
❖ 3. IORLW 60H
11/2/2023 23
Addressing Modes
2. Direct addressing mode:
❖ In direct addressing mode, the 8- bit data in RAM memory location whose address is
specified in the instruction.
❖ This mode is used for accessing the RAM file register.
❖ Example: 1. MOVWF 0X10
2. MOVFF 0X30, PORT C
3. Register addressing mode
❖ Register indirect addressing mode is used for accessing data stored in the RAM part of
file register.
❖ In this addressing mode a register is used as pointer to the memory location of the file
register.
❖ Three file select registers are used.
❖ They are FSR0, FSR1 and FSR2.
❖ Example:
1. MOVWF FSR2
2.MOVWF FSR0
3.MOVWF FSR1
[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.
11/2/2023 24
4. Indexed ROM addressing mode:
❖ This addressing mode is used for accessing the data from look
up tables that reside in the PIC program ROM.
11/2/2023 25
26
REGISTER FILE MAP
The special function registers are also
memory registers which is used for special
dedicated functions.
These registers perform various dedicated
functions inside the PIC chip.
Each special function inside this PIC chip is
controlled by using these registers.
These registers are used by the CPU and
peripheral modules for controlling the
desired operation of the device.
27
SPECIAL FUNCTION
REGISTERS
28
SFRs IN BANK 0
29
SFRs IN BANK 1
30
SFRs IN BANK 2 and 3

More Related Content

What's hot (20)

PPTX
Using 8051 microcontroller based washing machine control ppt
Sangeeth Sb
 
PDF
Programmable logic controllers
Naveen Chandrasekar
 
PPTX
Thyrstors turn off methods
raviarmugam
 
PPTX
General Purpose Input Output - Brief Introduction
NEEVEE Technologies
 
PPT
Architecture of 8086 Microprocessor
Mustapha Fatty
 
DOC
PIC MICROCONTROLLERS -CLASS NOTES
Dr.YNM
 
PDF
VLSI Lab manual PDF
UR11EC098
 
PPT
Memory & I/O interfacing
deval patel
 
PDF
Automated Traffic Light control using 8051 microcontroller
VijayMaheshwari12
 
PDF
Introduction to ARM LPC2148
Veera Kumar
 
PPTX
8251 USART
coolsdhanesh
 
PDF
Keypad Interfacing with 8051 Microcontroller
Sudhanshu Janwadkar
 
PPT
Oscillatorsppt
Geetesh Wagadre
 
PPTX
8251 USART
ShivamSood22
 
PPTX
ATMEGA 328
ABHISHEK MAURYA
 
PPTX
8255 PPI
deval patel
 
PDF
Unit III ARM Interface and ARM Programming
Dr. Pankaj Zope
 
PDF
8259 Programmable Interrupt Controller
abhikalmegh
 
PPTX
Evolution of microprocessors and 80486 Microprocessor.
Ritwik MG
 
DOCX
8051 data types and directives
SARITHA REDDY
 
Using 8051 microcontroller based washing machine control ppt
Sangeeth Sb
 
Programmable logic controllers
Naveen Chandrasekar
 
Thyrstors turn off methods
raviarmugam
 
General Purpose Input Output - Brief Introduction
NEEVEE Technologies
 
Architecture of 8086 Microprocessor
Mustapha Fatty
 
PIC MICROCONTROLLERS -CLASS NOTES
Dr.YNM
 
VLSI Lab manual PDF
UR11EC098
 
Memory & I/O interfacing
deval patel
 
Automated Traffic Light control using 8051 microcontroller
VijayMaheshwari12
 
Introduction to ARM LPC2148
Veera Kumar
 
8251 USART
coolsdhanesh
 
Keypad Interfacing with 8051 Microcontroller
Sudhanshu Janwadkar
 
Oscillatorsppt
Geetesh Wagadre
 
8251 USART
ShivamSood22
 
ATMEGA 328
ABHISHEK MAURYA
 
8255 PPI
deval patel
 
Unit III ARM Interface and ARM Programming
Dr. Pankaj Zope
 
8259 Programmable Interrupt Controller
abhikalmegh
 
Evolution of microprocessors and 80486 Microprocessor.
Ritwik MG
 
8051 data types and directives
SARITHA REDDY
 

Similar to UNIT-V (PIC16F877-Microcontrollers).pdf (20)

PDF
Pic microcontroller architecture
Jamia Hamdard
 
PPTX
Class 5 an 8 bit embedded platform
SURYAPRAKASH S
 
PPT
Introduction2_PIC.ppt
AakashRawat35
 
PPTX
435303149-PIC-ppt microcontroller introduct
sindhujam30
 
PPT
PICPICPICPICPICPICPICPICPICPICPICPIC .ppt
DrHamdyMMousa
 
PDF
PIC Microcontrollers: Powering Versatile Embedded Solutions"
aadithyaaa2005
 
PPTX
MICROCONTROLLER.pptx
fiqrie mohd
 
PPTX
PIC introduction + mapping
OsaMa Hasan
 
PDF
Lecture 5-Embedde.pdf
BlackHunter13
 
PPTX
Seminar topic.on embeded system
SachinMaithani1
 
PPTX
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
VISHNU KP
 
PPTX
3-8051 Microcontroller-28-01-2024 (1).pptx
attack123crack
 
PPTX
LECT 2.pptx
SangeetaTripathi8
 
PDF
MC_module_3_2022.pdf
maheshwaran79
 
PPTX
PIC 16F877 micro controller by Gaurav raikar
GauravRaikar3
 
PDF
Architecture and Programmingpart1_Microcontroller
ssuser1bfdb5
 
PPTX
Micro Controllers engineering - computer engineering
MohammedTaha224136
 
PPTX
microcontroller 8051 hfdsdsyghydfhdsgukhdfsdgjkghu
suchitra72aw
 
Pic microcontroller architecture
Jamia Hamdard
 
Class 5 an 8 bit embedded platform
SURYAPRAKASH S
 
Introduction2_PIC.ppt
AakashRawat35
 
435303149-PIC-ppt microcontroller introduct
sindhujam30
 
PICPICPICPICPICPICPICPICPICPICPICPIC .ppt
DrHamdyMMousa
 
PIC Microcontrollers: Powering Versatile Embedded Solutions"
aadithyaaa2005
 
MICROCONTROLLER.pptx
fiqrie mohd
 
PIC introduction + mapping
OsaMa Hasan
 
Lecture 5-Embedde.pdf
BlackHunter13
 
Seminar topic.on embeded system
SachinMaithani1
 
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
VISHNU KP
 
3-8051 Microcontroller-28-01-2024 (1).pptx
attack123crack
 
LECT 2.pptx
SangeetaTripathi8
 
MC_module_3_2022.pdf
maheshwaran79
 
PIC 16F877 micro controller by Gaurav raikar
GauravRaikar3
 
Architecture and Programmingpart1_Microcontroller
ssuser1bfdb5
 
Micro Controllers engineering - computer engineering
MohammedTaha224136
 
microcontroller 8051 hfdsdsyghydfhdsgukhdfsdgjkghu
suchitra72aw
 
Ad

Recently uploaded (20)

PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PPTX
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
Distribution reservoir and service storage pptx
dhanashree78
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Water Resources Engineering (CVE 728)--Slide 3.pptx
mohammedado3
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
Ad

UNIT-V (PIC16F877-Microcontrollers).pdf

  • 3. 8 bit microcontroller. Operating Speed: Up to 20 MHz Flash program memory (14 bit words), 8KB. Data memory:Data SRAM: 368 bytes &Data EEPROM: 256 bytes. Power-saving Sleep mode. 5 input/output ports It has 15 interrupt signal. Three timers 35 instructions 10bit A/D module (8 channels) In-Circuit Serial Programming via two pins (5V) Watchdog Timer with on-chip RC oscillator. 11/2/2023 3 FEATURES
  • 5. The main features of PIC microcontrollers are RAM, flash memory, Timers/ Counters, EEPROM, I/O Ports, USART, CCP (Capture/Compare/PWM module), SSP, Comparator, ADC (analog to digital converter), PSP(parallel slave port), LCD and ICSP (in circuit serial programming) . The PIC microcontroller architecture comprises of CPU, I/O ports, memory organization, A/D converter, timers/counters, interrupts, serial communication, oscillator and CCP module which are discussed in detailed below. 11/2/2023 5 Architecture of PIC16F877 MICROCONTROLLER
  • 7. PIC microcontroller’s CPU consists of ✔ Arithmetic logic unit (ALU) ✔ Memory unit (MU) ✔ Control unit (CU) ✔ Accumulator ALU is used for arithmetic operations and for logical decisions. Memory is used for storing the instructions after processing. Control unit is used to control the internal and external peripherals which are connected to the CPU and accumulator is used for storing the results. 11/2/2023 7 CPU (Central Processing Unit)
  • 8. The memory module in the PIC microcontroller architecture consists of 1. Data Memory (RAM) 2. Data EEPROM 3. Program Memory (FLASH Type) 11/2/2023 8 Memory Organization
  • 9. RAM is an unstable memory which is used to store the data temporarily in its registers. The RAM memory is classified into two banks, and each bank consists of so many registers. The RAM registers are classified into two types: 1.Special Function Registers (SFR) 2. General Purpose Registers (GPR). 11/2/2023 9 1.Random Access Memory (RAM)
  • 10. General Purpose Registers (GPR): These registers don’t have any special function. These are used for general purpose for multiplying, addition or subtraction and then storing the results in other registers. CPU can easily access the data in these registers. Special Function Registers (SFR): These registers are used for special purposes and they cannot be used as normal registers. Their function is set at the time of manufacturing. They perform the function assigned to them and user cannot change the function of SFR. Three important SFRs for programming are: STATUS register : It changes the bank PORT registers : It assigns logic values 0 or 1 to the ports TRIS registers : It is a data direction register for input and output 11/2/2023 10
  • 11. This memory allows storing the variables as a result of burning the written program. It is readable and writable during normal operation (over the full VDD range). This memory is not directly mapped in the register file. It is indirectly addressed through the SFRs. There are six SFRs which are used to read and write to this memory 1. EECON1 2.EECON2 3.EEDATA 4.EEDATH 5.EEADR 6.EEADRH 11/2/2023 11 2.DATA EEPROM:
  • 12. It contains the written program after we burned it in microcontroller. Program Counter executes commands stored in the program memory, one after the other. PIC microcontroller can have 8K words x 14 bits of Flash program memory that can be electrically erased and reprogrammed. Whenever we burn program into the microcontroller, we erase an old program and write a new one. 11/2/2023 12 3. Program Memory (FLASH Type)
  • 13. Serial communication is the method of transferring data one bit at a time sequentially over a communication channel. There are three protocols of serial communication: 1.USART 2.SPI (Serial Peripheral Interface) 3.I2C (Inter Integrated Circuit) 1.USART: ❖ It stands for Universal synchronous and Asynchronous Receiver and Transmitter which provides a serial communication in two devices. ❖ In this protocol data is transmitted and received bit by bit through a single wire according to the clock pulses. ❖ To send and receive data serially the PIC microcontroller has two pins TXD and RXD. 11/2/2023 13 Serial Communication
  • 14. 2.SPI (Serial Peripheral Interface) ❖ SPI stands for Serial Peripheral Interface. ❖ It is used to send data between PIC microcontrollers and other peripherals like sensors, shift registers and SD cards. ❖ Three wire SPI communications is supported in PIC microcontroller between two devices on a common clock source. ❖ SPI protocol has greater data handling capability than that of the USART. 3.I2C (Inter Integrated Circuit) ❖ I2C stands for Inter Integrated Circuit, and this protocol is used to connect low speed devices like microcontrollers, EEPROMS and A/D converters. ❖ PIC microcontroller support two wire Interface or I2C communication between two devices which can work as both Master and Slave device. 11/2/2023 14
  • 15. Interrupts ❖ There are 15 internal interrupts in PIC microcontrollers which are related with different peripherals like ADC, USART, Timers, and CCP etc. Timers/ Counters ❖ PIC microcontroller has 3 timer/counters (T0,T1,T2) where in the one 8-bit timer and the remaining timers have the choice to select 8 or 16-bit mode. ❖ Timers are used for generating specific time delays between two operations. A/D Converter: ❖ It converts the analog voltage levels to digital voltage values. In PIC Microcontroller, ADC has 8-channels and has resolution of 10-bit. ❖ The special function registers ADCON0 and ADCON1 control the operation of ADC. 11/2/2023 15
  • 16. CCP module: The name CCP module stands for capture/compare/PWM where it works in three modes such as capture mode, compare mode and PWM mode. Capture Mode: Capture mode captures the time of arrival of a signal. Compare Mode: Compare mode acts as an analog comparator. PWM Mode: PWM mode provides pulse width modulated output with a 10-bit resolution and programmable duty cycle. Oscillators Oscillators are used for timing generation. PIC microcontroller consist of external oscillators like RC oscillators or crystal oscillators. The range of clock frequency is upto 20MHz. 11/2/2023 16
  • 17. Input/Output Ports The series of PIC16f877 consists of five ports such as Port A, Port B, Port C, Port D & Port E. ❖ Port A is an 6-bit port that can be used as input or output port based on the status of the TRISA (Tradoc Intelligence Support Activity) register. ❖ Port B is an 8- bit port that can be used as both input and output port. ❖ Port C is an 8-bit port that can be used as input or output port based on the status of the TRISC register. ❖ Port D is an 8-bit port acts as a slave port for connection to the microprocessor BUS. ❖ Port E is a 3-bit port which serves the additional function of the control signals to the analog to digital converter. 11/2/2023 17
  • 18. Watchdog timer is a timer that resets the microcontroller in case the program gets stuck for an unexpected length of time. It’s monitors microcontroller (MCU) programs to see if they are out of control or have stopped operating. 11/2/2023 18 Watch Dog Timer (WDT)
  • 19. The instruction set of PIC is divided into Three basic categories. They are (a) Byte oriented Instructions (b) Bit oriented Instructions (c) Literal and Control Instructions Byte oriented Instructions: ❖ In a byte oriented Instructions ‘f “ represents a file register and’ d’ represents destination register. ❖ The destination specifies where the result of operation is to be placed. If D= 0 the result is placed in W register(Accumulator). 11/2/2023 19 INSTRUCTION SET
  • 22. Literal and Control Instructions: 11/2/2023 22
  • 23. The PIC 18 microcontroller supports following addressing modes. 1. Immediate addressing mode 2. Direct addressing mode 3. Register addressing mode 4. Indexed ROM addressing mode 1. Immediate addressing mode: ❖ In immediate addressing mode, the immediate data is specified in the instruction. ❖ The immediate addressing mode is used to load the data into PIC registers and W register. ❖ However, it cannot use to load data into any of the file register. ❖ Example: 1. MOVLW 50H ❖ 2. ANDLW 40H ❖ 3. IORLW 60H 11/2/2023 23 Addressing Modes
  • 24. 2. Direct addressing mode: ❖ In direct addressing mode, the 8- bit data in RAM memory location whose address is specified in the instruction. ❖ This mode is used for accessing the RAM file register. ❖ Example: 1. MOVWF 0X10 2. MOVFF 0X30, PORT C 3. Register addressing mode ❖ Register indirect addressing mode is used for accessing data stored in the RAM part of file register. ❖ In this addressing mode a register is used as pointer to the memory location of the file register. ❖ Three file select registers are used. ❖ They are FSR0, FSR1 and FSR2. ❖ Example: 1. MOVWF FSR2 2.MOVWF FSR0 3.MOVWF FSR1 [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. 11/2/2023 24
  • 25. 4. Indexed ROM addressing mode: ❖ This addressing mode is used for accessing the data from look up tables that reside in the PIC program ROM. 11/2/2023 25
  • 27. The special function registers are also memory registers which is used for special dedicated functions. These registers perform various dedicated functions inside the PIC chip. Each special function inside this PIC chip is controlled by using these registers. These registers are used by the CPU and peripheral modules for controlling the desired operation of the device. 27 SPECIAL FUNCTION REGISTERS
  • 30. 30 SFRs IN BANK 2 and 3