Biology for Computer Engineers Course Handout.pptx
Pic microcontroller architecture
1. PIC Microcontroller Architecture
PIC Microcontroller was developed by microchip Technology in year 1993. The term PIC
stands for Peripheral Interface Controller. As compared to other microcontrollers, programme
execution is easy and very fast in PIC Microcontrollers. PIC microcontrollers are very
popular due to their ease of programming, wide availability, easy to interfacing with other
peripherals, low cost, large user base and serial programming capability (reprogramming with
flash memory), etc.
PIC microcontroller architecture consists of RAM, ROM, CPU, timers, counters and supports
the protocols such as SPI, CAN, and UART for interfacing with other peripherals. At present
PIC microcontrollers are extensively used for industrial purpose due to low power
consumption, high performance ability and easy of availability of its supporting hardware and
software tools like compilers, debuggers and simulators
These microcontrollers are found in many electronic devices such as phones, computer
control system, alarm systems, embedded systems etc. The 8-bit PIC microcontroller is
classified into four types on the basis of internal architecture such as Base Line PIC, Mid-
Range PIC, Enhanced Mid-Range PIC and PIC18
Figure 1: Block Diagram of PCI Microcontroler Architecture
Components of PIC Microcontroller
CPU (Central ProcessingUnit)
It is not different from other microcontrollers CPU and the PIC microcontroller CPU
consists of the ALU, CU, MU and accumulator, etc. Arithmetic logic unit is mainly used
for arithmetic operations and to take logical decisions. Memory is used for storing the
instructions after processing. To control the internal and external peripherals, control unit
is used which are connected to the CPU and the accumulator is used for storing the results
and further process.
2. Memory Organization:
Programme Memory: 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 micro, we erase an old program and write a new one.
Data Memory:
It is a RAM type which is used to store the data temporarily in its registers. The RAM
memory is classified into banks. Each bank extends up to 7Fh (128 bytes). Number of
banks may vary depending on the microcontroller. PIC16F84 has only two banks. Banks
contain Special Function Registers (SFR) and General Purpose Registers (GPR). The
lower locations of each bank are reserved for the Special Function Registers and upper
locations are for General Purpose Registers.
Figure 2: Memory Organization of PIC Microcontroller
The memory module in the PIC Microcontroller architecture consists of random Access
Memory (RAM), Read Only Memory (ROM), and Stack
Random Access Memory (RAM): 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:
o Special Function Registers (SFR): These registers are used for special purposes
only as the name SFR implies. These registers will perform according to the
functions assigned to them , and they cannot be used as normal registers. For
example, if you cannot use the STATUS register for storing the data, these
registers are used for showing the operation or status of the program. So, user
cannot change the function of the SFR; the function is given by the retailer at the
time of manufacturing. 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
o General Purpose Registers (GPR): These registers are used for general purpose
only as the name implies. For example, if we want to multiply two numbers by
3. using the PIC microcontroller. Generally, we use registers for multiplying and
storing the numbers in other registers. So these registers don’t have any special
function,- CPU can easily access the data in the registers.
Read Only Memory (ROM): Read only memory is a stable memory which is used to store the
data permanently. In PIC microcontroller architecture, the architecture ROM stores the
instructions or program, according to the program the microcontroller acts. The ROM is also
called as program memory, wherein the user will write the program for microcontroller and
saves it permanently, and finally the program is executed by the CPU. The microcontroller
performance depends on the instruction, which is executed by the CPU.
o Electrically Erasable Programmable Read Only Memory (EEPROM): In the normal
ROM, we can write the program for only once we cannot use again the
microcontroller for multiple times. But, in the EEPROM, we can program the ROM
multiple times.
o Flash Memory: Flash memory is also programmable read only memory (PROM) in
which we can read, write and erase the program thousands of times. Generally, the
PIC microcontroller uses this type of ROM.
Stack: When an interrupt occurs, first the PIC microcontroller has to execute the interrupt and
the existing process address. Then that is being executed is stored in the stack. After
completing the execution of the interrupt, the microcontroller calls the process with the help
of address, which is stored in the stack and get executes the process.
I/O Ports (Port A, Port B, Port C, Port D, & Port E)
Let us take PIC16 series, it consists of five ports, such as Port A, Port B, Port C, Port D
and Port E.
Port A: This port is 7-bit wide and can be used for both input and output. The status of
TRISA register decided whether it is used as input or output port.
Port B: It is an 8-bit port. This port also can be used as input and output. Moreover in
input mode four of its bits are variable according to the interrupt signals.
Port C: It is also an 8-bit port and can be used as both input and output port which is
determined by the status of the TRISC register.
Port D: This 8-bit port, unlike Port A, B and C is not an input/output port, but is used as
acts as a slave port for the connection to the microprocessor When in I/O mode Port D all
pins should have Schmitt Trigger buffers.
Port E: It is a 3-bit port which is used as the additional feature of the control signals to the
A/D converter
4. BUS: BUS is used to transfer and receive the data from one peripheral to another. It is
classified into two types such as data bus and address.
Data Bus: It is used for only transfer or receive the data.
Address Bus: Address bus is used to transmit the memory address from the peripherals to the
CPU. I/O pins are used to interface the external peripherals; UART and USART both are
serial communication protocols which are used for interfacing serial devices like GSM, GPS,
Bluetooth, IR , etc.
Figure 3: Bus
A/D & D/A Converters: The main intention of this analog to digital converter is to
convert analog voltage values to digital voltage values. A/D module of PIC
microcontroller consists of 5 inputs for 28 pin devices and 8 inputs for 40 pin devices.
The operation of the analog to digital converter is controlled by ADCON0 and ADCON1
special registers. The upper bits of the converter are stored in register ADRESH and
lower bits of the converter are stored in register ADRESL. For this operation, it requires
5V of an analog reference voltage.
Figure 4: A/D converter System
There are no analog outputs in PIC Microcontroller. To get analog output we have to use
external Digital-to-Analog Converter (DAC). It can convert 8 bits of digital number from
the eight digital outputs of PIC microcontroller.
5. Timers/Counters: Timers and counters are important as timers can tell the time and
count. PIC microcontroller can have up to four timers (depending upon the family)
Timer0, Timer1, Timer2 and Timer3. Timer0 and Timer2 are of 8-bits while the Timer1
and Timer3 are of 16-bits, which can also be used as a counter. These timers work
according to the selected modes.
Interrupts: PIC microcontroller consists of 20 internal interrupts and three external
interrupt sources which are associated with different peripherals like ADC, USART,
Timers, and so on.
Serial Communications: Serial communication is the method of transferring data one bit
at a time sequentially over a communication channel.
o USART: The name USART stands for Universal synchronous and Asynchronous
Receiver and Transmitter which is a serial communication for two protocols. It is used
for transmitting and receiving the data bit by bit over a single wire with respect to
clock pulses. The PIC microcontroller has two pins TXD and RXD. These pins are
used for transmitting and receiving the data serially.
o SPI Protocol: The term SPI stands for Serial Peripheral Interface. This protocol is
used to send data between PIC microcontroller and other peripherals such as SD
cards, sensors and shift registers. PIC microcontroller support three wire SPI
communications between two devices on a common clock source. The data rate of
SPI protocol is more than that of the USART.
o I2C Protocol: The term I2C stands for Inter Integrated Circuit, and it is a serial
protocol which is used to connect low speed devices such as EEPROMS,
microcontrollers, A/D converters, etc. PIC microcontroller support two wires
Interface or I2C communication between two devices which can work as both Master
and Slave device.
Oscillators: Oscillators are used for timing generation. Pic microcontrollers consist of
external oscillators like RC oscillators or crystal oscillators. Where the crystal oscillator is
connected between the two oscillator pins. The value of the capacitor is connected to
every pin that decides the mode of the operation of the oscillator. The modes are crystal
mode, high-speed mode and the low-power mode. In case of RC oscillators, the value of
the resistor & capacitor determine the clock frequency and the range of clock frequency is
30KHz to 4MHz.
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.
o Capture Mode: Capture mode captures the time of arrival of a signal, or in other
words, when the CCP pin goes high, it captures the value of the Timer1.
6. o Compare Mode: Compare mode acts as an analog comparator. When the timer1 value
reaches a certain reference value, then it generates an output.
o PWM Mode: PWM mode provides pulse width modulated output with a 10-bit
resolution and programmable duty cycle.
PIN Diagram of PIC microcontroller and its explanation
7. Figure 5: PIN Diagram of PIC Microcontroller
Table1: Pin Description of PIC Microcontroller
Pin Number Pin Name Description
1. MCLR̅̅̅̅̅̅̅̅/VPP
MCLR is used during programming, mostly connected to
programmer like PicKit
2. RA0/AN0 Analog pin 0 or 0th
pin of PORTA
3. RA1/AN1 Analog pin 1 or 1st
pin of PORTA
4. RA2/AN2/Vref- Analog pin 2 or 2nd
pin of PORTA
5. RA3/AN3/Vref+ Analog pin 3 or 3rd
pin of PORTA
6. RA4/T0CKI/C1out 4th
pin of PORTA
7. RA5/AN4/SS/C2out Analog pin 4 or 5th
pin of PORTA
8. RE0/RD/AN5 Analog pin 5 or 0th
pin of PORTE
9. RE1/WR/AN6 Analog pin 6 or 1st
pin of PORTE
10. RE2/CS/AN7 7th
pin of PORTE
11. Vdd Ground pin of MCU
12. Vss Positive pin of MCU (+5V)
13. OSC1/CLKI External Oscillator/clock input pin
14. OSC2/CLKO External Oscillator/clock output pin
15. RC0/T1OSO/T1CKI 0th
pin of PORT C
16. RC1/T1OSI/CCP2 1st
pin of PORTC or Timer/PWM pin
17. RC2/CCP1 2nd
pin of PORTC or Timer/PWM pin
18. RC3/SCK/SCL 3rd
pin of PORTC
19. RD0/PSP0 0th
pin of PORTD
20. RD1/PSPI 1st
pin of PORTD
21. RD2/PSP2 2nd
pin of PORTD
22. RD3/PSP3 3rd
pin of PORTD
23. RC4/SDI/SDA 4th
pin of PORTC or Serial Data in pin
8. 24. RC5/SDO 5th
pin of PORTC or Serial Data Out pin
25. RC6/Tx/CK 6th
pin of PORTC or Transmitter pin of Microcontroller
26. RC7/Rx/DT 7th
pin of PORTC or Receiver pin of Microcontroller
27. RD4/PSP4 4th
pin of PORTD
28. RD5/PSP5 5th
pin of PORTD
29. RD6/PSP6 6th
pin of PORTD
30. RD7/PSP7 7th
pin of PORTD
31. Vss Positive pin of MCU (+5V)
32. Vdd Ground pin of MCU
33. RB0/INT 0th
pin of PORTB or External Interrupt pin
34. RB1 1st
pin of PORTB
35. RB2 2nd
pin of PORTB
36. RB3/PGM 3rd
pin of PORTB or connected to programmer
37. RB4 4th
pin of PORTB
38. RB5 5th
pin of PORTB
39. RB6/PGC 6th
pin of PORTB or connected to programmer
40. RB7/PGD 7th
pin of PORTB or connected to programmer
References
1. https://www.watelectronics.com/pic-microcontroller-architecture-and-applications/
2. https://www.electronicshub.org/pic-microcontroller-architecture/
3. https://www.elprocus.com/introduction-to-pic-microcontrollers-and-its-architecture/
4. https://microcontrollerslab.com/pic-microcontroller-architecture/
5. https://components101.com/pic16f877a-pin-diagram-description-features-datasheet