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
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