SlideShare ist ein Scribd-Unternehmen logo
1 von 71
Downloaden Sie, um offline zu lesen
Microcontroller (PIC)
Basics of Microcontroller (PIC)
Nilesh Bhaskarrao Bahadure
Ph.D, ME, BE
nbahadure@gmail.com
https://www.sites.google.com/site/nileshbbahadure/home
July 1, 2021
1 / 71
Overview
1 Syllabus
2 Course Objectives & Outcomes
3 Objectives
4 What is Microcontroller
5 Microcontroller vs Microprocessor
6 Development/Classification of microcontrollers
7 Harvard vs. Princeton Architecture
8 RISC AND CISC CONTROLLERS
Features of RISC
9 Microcontroller for Embedded Systems
10 x86 PC Embedded Applications
11 Choosing a Microcontroller
Criteria for Choosing a Microcontroller
12 Mechatronics and Microcontrollers
13 A brief history of the PIC microcontroller
14 PIC Microcontrollers
15 Feature: PIC16F877
Simplified Features 2 / 71
Syllabus
Unit Heading No. of Lectures
Unit 1: PIC Microcontrollers No of lectures - 3
The PIC Microcontrollers: History, Overview and Features.
3 / 71
Course Objectives
1 To expose the students to the fundamentals of PIC Microcontroller
16F877 architecture and its Peripherals.
2 To introduce the advanced features in PIC Microcontroller 16F877.
3 To make student develop and practice assembly language and C
language programming techniques
4 To enable student demonstrate and perform hardware interfacing and
design.
4 / 71
Course Outcomes
At the end of the course, the student shall be able to,
1 Describe how PIC microcontroller and its peripherals function.
2 Interpret advanced features in PIC Microcontroller 16F877.
3 Program an embedded system in assembly and C.
4 Design, implement and test a single-processor embedded systems for
real-time applications
5 / 71
Objectives
Upon completion of this chapter, you will be able to:
1 Compare and contrast microprocessors and microcontrollers [1, 2]
2 Describe the advantages of microcontrollers for some applications
3 Explain the concept of embedded systems
4 Discuss the criteria for considering Microcontroller
5 Explain the variations of speed, packaging, memory and cost per unit
and how these affect choosing a Microcontroller
6 Compare and contrast the various members of the PIC family
7 Compare the PIC with microcontrollers offered by other manufactures.
6 / 71
What is Microcontroller
A Microcontroller is a programmable digital processor with necessary
peripherals. Both microcontrollers and microprocessors are complex
sequential digital circuits meant to carry out job according to the program
/ instructions. Sometimes analog input/output interface makes a part of
microcontroller circuit of mixed mode(both analog and digital nature).
7 / 71
Microcontroller vs Microprocessor
Figure : Microprocessor system contrasted with Microcontroller system
8 / 71
Microcontroller vs Microprocessor...
A system designer using a general purpose microprocessor such as the
Pentium or the PowerPC must add RAM, ROM, IO ports, and timers
externally to make then functional. Although the addition of external
RAM, ROM, and IO ports makes these systems bulkier and much more
expensive, they have the advantage of versatility, enabling the designer to
decide on the amount of RAM, ROM, and IO ports needed to fit the task
at hand. This is not the case with microcontrollers. A Microcontroller has
a CPU (a Microprocessor) in addition to a fixed amount of RAM, ROM,
IO ports, and a timer all on a single chip.
The fixed amount of ON - chip ROM, RAM, and number of IO ports in
microcontrollers makes them ideal for many applications in which cost and
space are critical. In many applications, for example a TV remote control,
there is no need for the consuming power of a 486 or even an 8086
microprocessor. In many applications, the space used, the power
consumed, and the price per unit are much critical considerations than the
computing power.
9 / 71
Microcontroller vs Microprocessor...
1 A microprocessor requires an external memory for program/data
storage. Instruction execution requires movement of data from the
external memory to the microprocessor or vice versa. Usually,
microprocessors have good computing power and they have higher
clock speed to facilitate faster computation.
2 A microcontroller has required on-chip memory with associated
peripherals. A microcontroller can be thought of a microprocessor
with inbuilt peripherals.
3 A microcontroller does not require much additional interfacing ICs for
operation and it functions as a stand alone system. The operation of
a microcontroller is multipurpose, just like a Swiss knife.
4 Microcontrollers are also called embedded controllers. A
microcontroller clock speed is limited only to a few tens of MHz.
Microcontrollers are numerous and many of them are application
specific.
10 / 71
Development/Classification of microcontrollers
Microcontrollers have gone through a silent evolution (invisible). The
evolution can be rightly termed as silent as the impact or application of a
microcontroller is not well known to a common user, although
microcontroller technology has undergone significant change since early
1970’s. Development of some popular microcontrollers is given as follows.
11 / 71
Development/Classification of microcontrollers...
Processor No. of Bits Year
Intel 4004 4 bit (2300 PMOS trans, 108 kHz) 1971
Intel 8048 8 bit 1976
Intel 8031 8 bit (ROM-less) –
Intel 8051 8 bit (Mask ROM) 1980
Microchip PIC16C64 8 bit 1985
Motorola 68HC11 8 bit (on chip ADC) –
Intel 80C196 16 bit 1982
Atmel AT89C51 8 bit (Flash memory) –
Microchip PIC 16F877 8 bit (Flash memory + ADC) –
12 / 71
Harvard vs. Princeton Architecture
Harvard vs. Princeton
Many years ago, in the late 1940’s, the US Government asked Harvard and
Princeton universities to come up with a computer architecture to be used
in computing distances of Naval artillery shell for defense applications.
Princeton suggested computer architecture with a single memory interface.
It is also known as Von Neumann architecture after the name of the chief
scientist of the project in Princeton University John Von Neumann (1903 -
1957 Born in Budapest, Hungary).
Harvard suggested a computer with two different memory interfaces, one
for the data / variables and the other for program / instructions. Although
Princeton architecture was accepted for simplicity and ease of
implementation, Harvard architecture became popular later, due to the
parallelism of instruction execution.
13 / 71
Princeton Architecture - Single Memory Interface
Figure : Princeton Architecture
14 / 71
Harvard Architecture (Separate Program and Data
Memory interfaces)
Figure : Harvard Architecture
15 / 71
RISC AND CISC CONTROLLERS
There are some differences that an Electronics Engineer must know
regarding the design aspect of microcontrollers. RISC stands for reduced
instruction set computing and CISC stands for complex instruction set
computing. As the name implies RISC perform the same operation as CISC
can perform, but on the reduced instruction. In other words, we can say
that with only few or less number of instruction compared to CISC, RISC
can perform all the operations initiated by CISC computing approach.
16 / 71
RISC AND CISC CONTROLLERS...
The CISC Approach
The primary goal of CISC architecture is to complete a task in as few
lines of assembly as possible. This is achieved by building processor
hardware that is capable of understanding and executing a series of
operations.
For this particular task, a CISC processor would come prepared with a
specific instruction (we’ll call it ”MULT”). When executed, this
instruction loads the two values into separate registers, multiplies the
operands in the execution unit, and then stores the product in the
appropriate register. Thus, the entire task of multiplying two numbers
can be completed with one instruction.
17 / 71
RISC AND CISC CONTROLLERS...
The RISC Approach
RISC processors only use simple instructions that can be executed
within one clock cycle.
Thus, the ”MULT” command described above could be divided into
three separate commands: ”LOAD,” which moves data from the
memory bank to a register, ”PROD,” which finds the product of two
operands located within the registers, and ”STORE,” which moves
data from a register to the memory banks. In order to perform the
exact series of steps described in the CISC approach, a programmer
would need to code four lines of assembly:
LOAD A, 2:3
LOAD B, 5:2
PROD A, B
STORE 2:3, A
18 / 71
RISC AND CISC CONTROLLERS...
The RISC Approach
At first, this may seem like a much less efficient way of completing
the operation. Because there are more lines of code, more RAM is
needed to store the assembly level instructions.
The compiler must also perform more work to convert a high-level
language statement into code of this form.
19 / 71
Features of RISC
Feature 1
RISC processors have a fixed instruction size. In a CISC microcontroller
such as the 8051, instructions can be 1, 2, or even 3 bytes. For example,
look at the following instructions in the 8051:
CLR C ; Clear carry flag ; 1- byte instruction
ADD A, #20h ; 2-byte instruction
LJMP 2000 ; 3-byte instruction
This variable instruction size makes the task of the instruction decoder
very difficult because the size of the incoming instruction is never known.
In RISC architecture, the size of all instructions is fixed. Therefore, the
CPU can decode the instructions quickly.
20 / 71
Features of RISC
Feature 2
One of the major characteristics of RISC architecture is a large number of
registers. ALL RISC architectures have at least 32 registers. Of these 32
registers only a few are assigned to a dedicated function.
Feature 3
RISC processors have a small instruction set. RISC processors have only
the basic instructions such as ADD, SUB, MUL, LOAD, STORE, AND,
OR, EXOR, CALL, JUMP, and so on. The limited number of instructions
is one of the criticism leveled at the RISC processor because it makes the
job of assembly language programmer much more tedious and difficult
compared to CISC programmer. This is one reason RISC processor mostly
used in high language environment such as C.
21 / 71
Features of RISC
Feature 4
The most important characteristics of the RISC processor is that more
than 95% of instructions are executed with only one clock cycle, in
contrast to CISC instructions.
Feature 5
RISC processors have separate buses for data and code. In all the x86
processors, like all other CISC computers, there is one set of buses for all
the address and another set of buses for data carrying opcodes and
operand in and out of the CPU. In RISC processors, there are four sets of
buses:
1. A set of data buses for carrying data (operand) 2. A set of address bus
for accessing the data 3. A set of buses to carry the opcodes 4. A set of
address buses to access the opcodes
The use use of separate buses for code and data operands is commonly
referred to as Harvard architecture.
22 / 71
Features of RISC
Feature 6
In case of RISC, however, due to the small set of instructions, they are
implemented using the hardwire method. Hardwiring of RISC insructions
takes no more than 10% of the transistors, the same will take 40 - 60% of
transistors in many CISC processors.
Feature 7
RISC uses load/store architecture. In CISC microprocessors, data can be
manipulated while it is still in memory.
23 / 71
Microcontroller for Embedded Systems
Microprocessors and microcontrollers are widely used in embedded system
products. An embedded product is controlled by its own internal
microprocessor or Microcontroller as opposed to an external controller.
Typically, in an embedded system, the microcontrollers ROM are burned
with a purpose for specific functions needed for the system. A printer is an
example of an embedded system because the processor inside it performs
one task only; namely, getting the data and printing it. Contrast this with
a Pentium based PC, which can be used for any number of applications
such as word processor, print server, bank teller terminal, video game
player, network server or internal terminal.
24 / 71
Microcontroller for Embedded Systems...
A PC can also load and run software for a variety of applications. Of
course, the reason a PC can perform myriad tasks is that it has RAM
memory and an operating system that loads the application software into
RAM and lets the CPU run it. In an embedded system, typically only one
application software is burned into ROM. An x86 PC contains or is
connected to various embedded products such as the keyboard, printer,
modem, disk controller, sound card, CD - ROM driver, mouse, and so on.
Each of these peripherals has a Microcontroller inside it that performs only
one task. For example, inside every mouse a Microcontroller performs the
task of finding the mouse’s position and sending it to the PC.
25 / 71
Microcontroller for Embedded Systems...
Home Office Auto
Appliances Telephones Trip computer
Intercom Computers Engine control
Telephone Security systems Air bag
Security systems Fax Machines ABS
Garage door openers Microwave Instrumentation
Answering machines Copier Security system
Fax machines Laser printer Transmission control
Home computers Color Printer Entertainment
TVs Paging Climate control
Cable TV tuner Keyless entry
VCR
Camcorders
Remote controls
Video games,
cellular phones
Musical instruments
Sewing machines
Lighting control
Paging Camera
26 / 71
x86 PC Embedded Applications
Although microcontrollers are the preferred choice for many embedded
systems, sometimes a Microcontroller is inadequate for the task. For this
reason, in recent years many manufactures of general purpose
microprocessors such as Intel, Freescale Semiconductors (Formerly
Motorola), and AMD (Advanced Micro Devices, Inc.) have targeted their
microprocessor for the high end of the embedded market. Intel and AMD
push their x86 processors for both the embedded and desktop PC markets.
In the early 1990s, apple computer began using the PowerPC
microprocessors (604, 603, 620 etc) in place of the 680x0 for the
Macintosh. The PowerPC microprocessor is a joint venture between IBM
and Motorola, and is targeted for the high end of the embedded market as
well as the PC market. It must be noted that when a company targets a
general purpose microprocessor for the embedded market it optimizes the
processor used for embedded systems. For this reason these processors are
often called high end embedded processors. Another chip widely used in
the high end of the embedded system design is the ARM microprocessor.
Very often the terms embedded processor and Microcontroller are used
27 / 71
x86 PC Embedded Applications...
One of the most critical needs of an embedded system is to decrease
power consumption and space. This can be achieved by integrating more
functions into the CPU chip. All the embedded processors based on the
x86 and PowerPC 6xx have low power consumption in addition to some
forms of I/O, COM port, and ROM, all on a single chip. In high
performance embedded processors, the trend is to integrate more and
more functions on the CPU chip and let the designer decides which
features to use. This trend is invading PC system design as well. Normally
in designing the PC motherboard we need a CPU plus a chipset containing
I/O a cache controller, a flash ROM containing BIOS, and finally a
secondary cache memory.
28 / 71
x86 PC Embedded Applications...
Currently, because of Linux, MS- DOS, and Windows standardization,
many embedded systems use x86 PCs. In many cases, using x86 PCs for
the high end embedded applications not only saves money but also
shortens development times because a vast library of software already
exists for the Linus, DOS and Windows plate form.
29 / 71
Choosing a Microcontroller
There are five major 8 - bit microcontrollers. They are: Freescale
Semiconductor’s (Motorola) 68HC08/68HC11, Intel’s 8051, Atmel’s AVR,
Zilog’s Z8 and PIC from Microchip technology. Each of the above
microcontrollers has a unique instruction set and register set; therefore
they are not compatible with each other. Programs written for one will not
run on the others. There are also 16 and 32 bit microcontrollers made by
various chip makers. With all these different microcontrollers, what criteria
for designers consider in choosing one? Three criteria in choosing
microcontrollers are as follows:
30 / 71
Choosing a Microcontroller
Choosing a Microcontroller
1 Meeting the computing needs of the task at hand efficiently and cost
effectively
2 Availability of software and hardware development tools such as
compilers, assemblers, debuggers, and emulators and
3 Wide availability and reliable source of microcontrollers.
31 / 71
Criteria for Choosing a Microcontroller I
1 The first and foremost criterion in choosing a Microcontroller is that
it must meet the task at hand efficiently and cost effectively. In
analyzing the needs of a Microcontroller - based project, we must first
see whether an 8 - bit, 16 bit or 32 bit Microcontroller can best
handle the computing needs of the task most effectively. Among
other considerations in this category are:
Speed: What is the highest speed that the Microcontroller supports?
Packaging: Does it come in a40-pin DIP (dual in line package) or a
QFP (quad flat package), or some other packaging format? This is
important in terms of space, assembling, and prototyping the end
product.
Power consumption:This is especially critical for battery-powered
products.
The amount of RAM and ROM on the chip.
The number of I/O pins and the timer on the chip.
Ease of upgrade to higher-performance or lower-power-consumption
versions.
32 / 71
Criteria for Choosing a Microcontroller II
Cost per unit:This is important in terms of the final cost of the product
in which a Microcontroller is used. For example, some microcontrollers
cost 50 cents per unit when purchased 1000,000 units at a time.
2 The second criterion in choosing a Microcontroller is how easy it is to
develop products around it. Key considerations include the availability
of an assembler, debugger, a code-efficient C language compiler,
emulator, technical sup-port, and both in-house and outside expertise.
In many cases, third-party vendor (i.e., a supplier other than the chip
manufacturer) support for the chip is as good as, if not better than,
support from the chip manufacturer.
33 / 71
Criteria for Choosing a Microcontroller III
3 The third criterion in choosing a microcontroller is its ready
availability in needed quantities both now and in the future. For some
designers this is even more important than the first two criteria.
Currently, of the leading 8-bit micro-controllers, the 8051 family has
the largest number of diversified (multiple source) suppliers. (Supplier
means a producer besides the originator of the microcontroller.) In
the case of the 8051, which was originated by Intel, several companies
also currently produce (or have produced in the past) the 8051.
34 / 71
Mechatronics and Microcontrollers
The microcontroller is playing a major role in an emerging field called Mecha-
tronics. Here is an excellent summary of what the field of Mechatronics is
all about, ”Many technical processes and products in the area of mechan-
ical and electrical engineering show an increasing integration of mechanics
with electronics and information processing. This integration is between the
components (hardware) and the information-driven functions (software), re-
sulting in integrated systems called Mechatronics systems. The development
of Mechatronics systems involves finding an optimal balance between the
basic mechanical structure, sensor and actuator implementation, automatic
digital information processing and overall control, and this synergy results in
innovative solutions. The practice of Mechatronics requires multidisciplinary
expertise across a range of disciplines, such as: mechanical engineering, elec-
tronics, information technology, and decision making theories.”
35 / 71
A brief history of the PIC microcontroller I
In 1989, Microchip Technology Corporation introduced an 8-bit micro-controller called
the PIC, which stands for Peripheral Interface Controller. This microcontroller had small
amounts of data RAM, a few hundred bytes of on-chip ROM for the program, one timer,
and a few pins for I/O ports, all on a single chip with only 8 pins.The simplified view of
PIC microcontroller is shown in Figure 4. It is amazing that a company that began with
such a humble product became one of the leading suppliers of 8-bit microcontrollers in
less than a decade. At the time of this writing, Microchip is the number-one supplier of
8-bit microcontrollers in the world. Since the introduction of the PIC16xxx, they have
introduced an array of 8-bit microcontrollers too numerous to list here. They include
the PIC families of 10xxx, 12xxx, 14xxx, 16xxx, 17xxx, and 18xxx. They are all 8-bit
processors, meaning that the CPU can work on only 8 bits of data at a time. Data
larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU. One of
the problems with the PIC family is that they are not all 100% upwardly compatible in
terms of software when going from one family to another family. For example, while the
12xxx/16xxx have 12-bit and 14-bit wide instructions, the PIC18xxx instruction is 16 bits
wide with many new instructions.
36 / 71
A brief history of the PIC microcontroller II
Figure : Simplified View of a PIC Microcontroller
37 / 71
PIC Microcontrollers I
PIC stands for Peripheral Interface Controller given by Microchip
Technology to identify its single-chip microcontrollers. These devices have
been very successful in 8-bit microcontrollers. The main reason is that
Microchip Technology has continuously upgraded the device architecture
and added needed peripherals to the microcontroller to suit customers’
requirements. The development tools such as assembler and simulator are
freely available on the internet at www.microchip.com.
The architectures of various PIC microcontrollers can be divided as follows.
38 / 71
PIC Microcontrollers II
Low - end PIC Architectures:
Microchip PIC microcontrollers are available in various types. When PIC
microcontroller MCU was first available from General Instruments in early
1980’s, the microcontroller consisted of a simple processor executing
12-bit wide instructions with basic I/O functions. These devices are known
as low-end architectures. They have limited program memory and are
meant for applications requiring simple interface functions and small
program data memories. Some of the low-end device numbers are
1 12C5XX
2 16C5X
3 16C505
39 / 71
PIC Microcontrollers III
Mid range PIC Architectures
Mid range PIC architectures are built by upgrading low-end architectures
with more number of peripherals, more number of registers and more
data/program memory. Some of the mid-range devices are
1 16C6X
2 16C7X
3 16F87X
Program memory type is indicated by an alphabet.
1 C = EPROM
2 F = Flash
3 RC = Mask ROM
Popularity of the PIC microcontrollers is due to the following
factors.
40 / 71
PIC Microcontrollers IV
1 Speed: Harvard Architecture, RISC architecture, 1 instruction cycle =
4 clock cycles.
2 Instruction set simplicity: The instruction set consists of just 35
instructions (as opposed to 111 instructions for 8051).
3 Power-on-reset and brown-out reset. Brown-out-reset means when
the power supply goes below a specified voltage (say 4V), it causes
PIC to reset; hence malfunction is avoided.
4 A watch dog timer (user programmable) resets the processor if the
software/program ever malfunctions and deviates from its normal
operation.
5 PIC microcontroller has four optional clock sources.
Low power crystal
Mid range crystal
High range crystal
RC oscillator (low cost).
41 / 71
PIC Microcontrollers V
6 Programmable timers and on-chip ADC.
7 Up to 12 independent interrupt sources.
8 Powerful output pin control (25 mA (max.) current sourcing
capability per pin.)
9 EPROM/OTP/ROM/Flash memory option.
10 I/O port expansion capability.
11 Free assembler and simulator support from Microchip at
www.microchip.com
42 / 71
Feature: PIC16F877 I
1 High performance RISC CPU
2 Only 35 single word instructions to learn
3 All single cycle instructions except for program branches which are
two cycle
4 Operating speed: DC - 20 MHz clock input DC - 200 ns instruction
cycle
5 Up to 8K x 14 words of FLASH Program Memory,
Up to 368 x 8 bytes of Data Memory (RAM)
Up to 256 x 8 bytes of EEPROM Data Memory
6 Pinout compatible to the PIC16C73B/74B/76/77
7 Interrupt capability (up to 14 sources)
8 Eight level deep hardware stack
9 Direct, indirect and relative addressing modes
43 / 71
Feature: PIC16F877 II
10 Power-on Reset (POR)
11 Power-up Timer (PWRT) and
Oscillator Start-up Timer (OST)
12 Watchdog Timer (WDT) with its own on-chip RC oscillator for
reliable operation
13 Programmable code protection
14 Power saving SLEEP mode
15 Selectable oscillator options
16 Low power, high speed CMOS FLASH/EEPROM technology
17 Fully static design
18 In-Circuit Serial Programming (ICSP)via two pins
19 Single 5V In-Circuit Serial Programming capability
20 In-Circuit Debugging via two pins
21 Processor read/write access to program memory
44 / 71
Feature: PIC16F877 III
22 Wide operating voltage range: 2.0V to 5.5V
23 High Sink/Source Current: 25 mA
24 Commercial, Industrial and Extended temperature ranges
25 Low-power consumption:
< 0.6 mA typical @ 3V, 4 MHz
20 µ A typical @ 3V, 32 kHz
< 1 µ A typical standby current
26 Peripheral Features:
27 Timer0: 8-bit timer/counter with 8-bit prescaler
28 Timer1: 16-bit timer/counter with prescaler, can be incremented
during SLEEP via external crystal/clock
29 Timer2: 8-bit timer/counter with 8-bit period register, prescaler and
postscaler
30 Two Capture, Compare, PWM modules
Capture is 16-bit, max. resolution is 12.5 ns
45 / 71
Feature: PIC16F877 IV
Compare is 16-bit, max. resolution is 200 ns
PWM max. resolution is 10-bit
31 10-bit multi-channel Analog-to-Digital converter
32 Synchronous Serial Port (SSP) with SPI (Master mode) and
I2C(Master/Slave)
33 Universal Synchronous Asynchronous Receiver Transmitter
(USART/SCI) with 9-bit address detection
34 Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS
controls (40/44-pin only)
35 Brown-out detection circuitry for Brown-out Reset (BOR)
46 / 71
Simplified Features I
: Simplified features
Features Description
CPU 8-bit PIC
Number of Pins 40
Operating Voltage
(V)
2 to 5.5 V
Number of I/O
pins
33
ADC Module 8ch, 10-bit
Timer Module 8-bit(2), 16-bit(1)
Comparators 2
DAC Module Nil
47 / 71
Simplified Features II
Communication
Peripherals
UART(1),
SPI(1), I2C(1),
MSSP(SPI/I2C)
External Oscillator Up to 20Mhz
Internal Oscillator Nil
Program Memory
Type
Flash
Program Memory
(KB)
14KB
CPU Speed
(MIPS)
5 MIPS
RAM Bytes 368
Data EEPROM 256 bytes
48 / 71
Simplified Features III
49 / 71
Pin Diagram of PIC16F877
50 / 71
Pin Diagram of PIC16F877...
51 / 71
Pin Diagram of PIC16F877... I
1 The first pin is the master clear pin of this IC. It resets the
microcontroller and is active low, meaning that it should constantly
be given a voltage of 5V and if 0 V are given then the controller is
reset. Resetting the controller will bring it back to the first line of the
program that has been burned into the IC.
52 / 71
Pin Diagram of PIC16F877... II
A push button and a resistor is connected to the pin. The pin is
already being supplied by constant 5V. When we want to reset the IC
we just have to push the button which will bring the MCLR pin to 0
potential thereby resetting the controller.
2 PIN 2: RA0/AN0 PORTA consists of 6 pins, from pin 2 to pin 7, all
of these are bidirectional input/output pins. Pin 2 is the first pin of
this port. This pin can also be used as an analog pin AN0. It is built
in analog to digital converter.
3 PIN 3: RA1/AN1
This can be the analog input 1.
4 PIN 4: RA2/AN2/Vref-
It can also act as the analog input2. Or negative analog reference
voltage can be given to it.
53 / 71
Pin Diagram of PIC16F877... III
5 PIN 5: RA3/AN3/Vref+
It can act as the analog input 3. Or can act as the analog positive
reference voltage.
6 PIN 6: RA0/T0CKI
To timer0 this pin can act as the clock input pin, the type of output
is open drain.
7 PIN 7: RA5/SS/AN4
This can be the analog input 4. There is synchronous serial port in
the controller also and this pin can be used as the slave select for that
port.
8 PIN 8: RE0/RD/AN5
PORTE starts from pin 8 to pin 10 and this is also a bidirectional
input output port. It can be the analog input 5 or for parallel slave
port it can act as a read control pin which will be active low.
54 / 71
Pin Diagram of PIC16F877... IV
9 PIN 9: RE1/WR/AN6
It can be the analog input 6. And for the parallel slave port it can act
as the write control which will be active low.
10 PIN 10: RE2/CS/A7
It can be the analog input 7, or for the parallel slave port it can act as
the control select which will also be active low just like read and write
control pins.
11 PIN 11 and 32: VDD
These two pins are the positive supply for the input/output and logic
pins. Both of them should be connected to 5V.
12 PIN 12 and 31: VSS
These pins are the ground reference for input/output and logic pins.
They should be connected to 0 potential.
13 PIN 13: OSC1/CLKIN
This is the oscillator input or the external clock input pin.
55 / 71
Pin Diagram of PIC16F877... V
14 PIN 14: OSC2/CLKOUT
This is the oscillator output pin. A crystal resonator is connected
between pin 13 and 14 to provide external clock to the
microcontroller. 1
4 of the frequency of OSC1 is outputted by OSC2 in
case of RC mode. This indicates the instruction cycle rate.
56 / 71
Pin Diagram of PIC16F877... VI
15 PIN 15: RC0/T1OCO/T1CKI
PORTC consists of 8 pins. It is also a bidirectional input output port.
Of them, pin 15 is the first. It can be the clock input of timer 1 or
the oscillator output of timer 2.
16 PIN 16: RC1/T1OSI/CCP2
It can be the oscillator input of timer 1 or the capture 2
input/compare 2 output/ PWM 2 output.
17 PIN 17: RC2/CCP1
It can be the capture 1 input/ compare 1 output/ PWM 1 output.
18 PIN 18: RC3/SCK/SCL
It can be the output for SPI or I2C modes and can be the
input/output for synchronous serial clock.
19 PIN 23: RC4/SDI/SDA
It can be the SPI data in pin. Or in I2C mode it can be data
input/output pin.
57 / 71
Pin Diagram of PIC16F877... VII
20 PIN 24: RC5/SDO
It can be the data out of SPI in the SPI mode.
21 PIN 25: RC6/TX/CK
It can be the synchronous clock or USART Asynchronous transmit
pin.
22 PIN 26: RC7/RX/DT
It can be the synchronous data pin or the USART receive pin.
23 PIN 19,20,21,22,27,28,29,30:
All of these pins belong to PORTD which is again a bidirectional
input and output port. When the microprocessor bus is to be
interfaced, it can act as the parallel slave port.
24 PIN 33-40: PORT B
All these pins belong to PORTB. Out of which RB0 can be used as
the external interrupt pin and RB6 and RB7 can be used as in-circuit
debugger pins.
58 / 71
Pin Diagram of PIC16F877...
59 / 71
Pin Diagram of PIC16F877...
60 / 71
CPU Architecture:
The CPU uses Harvard architecture with separate Program and Variable
(data) memory interface. This facilitates instruction fetch and the
operation on data/accessing of variables simultaneously.
Figure : CPU Architecture of PIC microcontroller
61 / 71
PIC Memory Organization: I
PIC microcontroller has 13 bits of program memory address. Hence it can
address up to 8k of program memory. The program counter is 13-bit. PIC
16C6X or 16C7X program memory is 2k or 4k. While addressing 2k of
program memory, only 11-bits are required. Hence two most significant
bits of the program counter are ignored. Similarly, while addressing 4k of
memory, 12 bits are required. Hence the MSB of the program counter is
ignored.
62 / 71
PIC Memory Organization: II
Figure : Program Memory Map
63 / 71
PIC Memory Organization: III
The program memory map of PIC16C74A is shown in Fig 6. On reset, the
program counter is cleared and the program starts at 00H. Here a ’goto’
instruction is required that takes the processor to the mainline program.
When a peripheral interrupt, that is enabled, is received, the processor
goes to 004H. A suitable branching to the interrupt service routine (ISR) is
written at 004H.
Data memory (Register Files):
Data Memory is also known as Register File. Register File consists of two
components.
1 General purpose register file (same as RAM).
2 Special purpose register file (similar to SFR in 8051).
64 / 71
PIC Memory Organization: IV
Figure : Data Memory Map
65 / 71
PIC Memory Organization: V
The special purpose register file consists of input/output ports and control
registers. Addressing from 00H to FFH requires 8 bits of address.
However, the instructions that use direct addressing modes in PIC to
address these register files use 7 bits of instruction only. Therefore the
register bank select (RP0) bit in the STATUS register is used to select one
of the register banks.
In indirect addressing FSR register is used as a pointer to anywhere from
00H to FFH in the data memory.
66 / 71
PIC Memory Organization: VI
67 / 71
Que - 1
2018 (SLR - TJ-221) - Marks 1
PIC 16F877 devices . . . . . . bit program counter capable of addressing
. . . . . . program memory.
(a) 8, 256K x 8
(b) 16, 64K x 8
(c) 13, 8K x 14
(d) 14, 8K x 13
Answer
(c) 13, 8K x 14
68 / 71
Que - 2
2018 (SLR - TJ-221) - Marks 1
PIC16F877 is a . . . . . . bit microcontroller
(a) 8
(b) 16
(c) 32
(d) None of the above
Answer
(a) 8
69 / 71
References
Muhammad Ali Mazidi, Rolin D. McKinlay, and Danny Causey.
PIC Microcontroller and Embedded Systems - Using Assembly and C
for PIC18.
Pearson International Edition, Upper Saddle River, NJ, 2008.
Martin P. Bates.
Programming 8 - bit PIC Microcontrollers in C with Interactive
Hardware Simulation.
Newnes Press Private Limited, United Kingdom, 2008.
70 / 71
Thank you
Please send your feedback at nbahadure@gmail.com
For download and more information [Click Here]
71 / 71

Weitere ähnliche Inhalte

Was ist angesagt?

LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERsravannunna24
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureJamia Hamdard
 
Arm assembly language programming
Arm assembly language programmingArm assembly language programming
Arm assembly language programmingv Kalairajan
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in cAbdelrahman Elewah
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureDominicHendry
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller pptRahul Kumar
 
8096 microcontrollers notes
8096 microcontrollers notes8096 microcontrollers notes
8096 microcontrollers notesDr.YNM
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.pptDr.YNM
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Ganesh Ram
 
Introduction to arm architecture
Introduction to arm architectureIntroduction to arm architecture
Introduction to arm architectureZakaria Gomaa
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples Dr.YNM
 

Was ist angesagt? (20)

LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
ARM Processor
ARM ProcessorARM Processor
ARM Processor
 
Arm assembly language programming
Arm assembly language programmingArm assembly language programming
Arm assembly language programming
 
Chapter 7 8051 programming in c
Chapter 7  8051 programming in cChapter 7  8051 programming in c
Chapter 7 8051 programming in c
 
TMS320C5x
TMS320C5xTMS320C5x
TMS320C5x
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
8051 interfacing
8051 interfacing8051 interfacing
8051 interfacing
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
Switches and LEDs interface to the 8051 microcontroller
Switches and LEDs interface to the 8051 microcontrollerSwitches and LEDs interface to the 8051 microcontroller
Switches and LEDs interface to the 8051 microcontroller
 
8051 Microcontroller ppt
8051 Microcontroller ppt8051 Microcontroller ppt
8051 Microcontroller ppt
 
8096 microcontrollers notes
8096 microcontrollers notes8096 microcontrollers notes
8096 microcontrollers notes
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))
 
8051 MICROCONTROLLER
8051 MICROCONTROLLER 8051 MICROCONTROLLER
8051 MICROCONTROLLER
 
Introduction to arm architecture
Introduction to arm architectureIntroduction to arm architecture
Introduction to arm architecture
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples
 
I o ports.ppt
I o ports.pptI o ports.ppt
I o ports.ppt
 
LCD Interacing with 8051
LCD Interacing with 8051LCD Interacing with 8051
LCD Interacing with 8051
 

Ähnlich wie Microcontroller pic 16f877 architecture and basics

MergeResult_2023_04_02_05_26_56.pptx
MergeResult_2023_04_02_05_26_56.pptxMergeResult_2023_04_02_05_26_56.pptx
MergeResult_2023_04_02_05_26_56.pptxbhaveshagrawal35
 
A 64-Bit RISC Processor Design and Implementation Using VHDL
A 64-Bit RISC Processor Design and Implementation Using VHDL A 64-Bit RISC Processor Design and Implementation Using VHDL
A 64-Bit RISC Processor Design and Implementation Using VHDL Andrew Yoila
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollersnehapvs
 
Micro controller and dsp processor
Micro controller and dsp processorMicro controller and dsp processor
Micro controller and dsp processorShubhamMishra485
 
Design of a low power processor for Embedded system applications
Design of a low power processor for Embedded system applicationsDesign of a low power processor for Embedded system applications
Design of a low power processor for Embedded system applicationsROHIT89352
 
Microprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.pptMicroprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.pptTALHARIAZ46
 
A PIC compatible RISC CPU core Implementation for FPGA based Configurable SOC...
A PIC compatible RISC CPU core Implementation for FPGA based Configurable SOC...A PIC compatible RISC CPU core Implementation for FPGA based Configurable SOC...
A PIC compatible RISC CPU core Implementation for FPGA based Configurable SOC...IDES Editor
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to MicrocontrollerNikhil Sharma
 
Necessity of 32-Bit Controllers
Necessity of 32-Bit ControllersNecessity of 32-Bit Controllers
Necessity of 32-Bit Controllersmohanav
 
DESIGN OF A 16-BIT HARVARD STRUCTURED RISC PROCESSOR IN CADENCE 45nmTECHNOLOGY
DESIGN OF A 16-BIT HARVARD STRUCTURED RISC PROCESSOR  IN CADENCE 45nmTECHNOLOGYDESIGN OF A 16-BIT HARVARD STRUCTURED RISC PROCESSOR  IN CADENCE 45nmTECHNOLOGY
DESIGN OF A 16-BIT HARVARD STRUCTURED RISC PROCESSOR IN CADENCE 45nmTECHNOLOGYshaikalthaf40
 
Design development-and-implementation-of-a temperature-sensor-using-zigbee-co...
Design development-and-implementation-of-a temperature-sensor-using-zigbee-co...Design development-and-implementation-of-a temperature-sensor-using-zigbee-co...
Design development-and-implementation-of-a temperature-sensor-using-zigbee-co...Cemal Ardil
 
A REVIEW ON ANALYSIS OF 32-BIT AND 64-BIT RISC PROCESSORS
A REVIEW ON ANALYSIS OF 32-BIT AND 64-BIT RISC PROCESSORSA REVIEW ON ANALYSIS OF 32-BIT AND 64-BIT RISC PROCESSORS
A REVIEW ON ANALYSIS OF 32-BIT AND 64-BIT RISC PROCESSORSIRJET Journal
 
microprocessor-and-microcontroller
microprocessor-and-microcontrollermicroprocessor-and-microcontroller
microprocessor-and-microcontrollerjhcid
 
Ajal mod 1
Ajal mod 1Ajal mod 1
Ajal mod 1AJAL A J
 
Risc and cisc eugene clewlow
Risc and cisc   eugene clewlowRisc and cisc   eugene clewlow
Risc and cisc eugene clewlowChaudhary Manzoor
 

Ähnlich wie Microcontroller pic 16f877 architecture and basics (20)

MergeResult_2023_04_02_05_26_56.pptx
MergeResult_2023_04_02_05_26_56.pptxMergeResult_2023_04_02_05_26_56.pptx
MergeResult_2023_04_02_05_26_56.pptx
 
Unit I_MT2301.pdf
Unit I_MT2301.pdfUnit I_MT2301.pdf
Unit I_MT2301.pdf
 
A 64-Bit RISC Processor Design and Implementation Using VHDL
A 64-Bit RISC Processor Design and Implementation Using VHDL A 64-Bit RISC Processor Design and Implementation Using VHDL
A 64-Bit RISC Processor Design and Implementation Using VHDL
 
Risc processors
Risc processorsRisc processors
Risc processors
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Micro controller and dsp processor
Micro controller and dsp processorMicro controller and dsp processor
Micro controller and dsp processor
 
Design of a low power processor for Embedded system applications
Design of a low power processor for Embedded system applicationsDesign of a low power processor for Embedded system applications
Design of a low power processor for Embedded system applications
 
Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
 
Microprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.pptMicroprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.ppt
 
A PIC compatible RISC CPU core Implementation for FPGA based Configurable SOC...
A PIC compatible RISC CPU core Implementation for FPGA based Configurable SOC...A PIC compatible RISC CPU core Implementation for FPGA based Configurable SOC...
A PIC compatible RISC CPU core Implementation for FPGA based Configurable SOC...
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
 
Necessity of 32-Bit Controllers
Necessity of 32-Bit ControllersNecessity of 32-Bit Controllers
Necessity of 32-Bit Controllers
 
DESIGN OF A 16-BIT HARVARD STRUCTURED RISC PROCESSOR IN CADENCE 45nmTECHNOLOGY
DESIGN OF A 16-BIT HARVARD STRUCTURED RISC PROCESSOR  IN CADENCE 45nmTECHNOLOGYDESIGN OF A 16-BIT HARVARD STRUCTURED RISC PROCESSOR  IN CADENCE 45nmTECHNOLOGY
DESIGN OF A 16-BIT HARVARD STRUCTURED RISC PROCESSOR IN CADENCE 45nmTECHNOLOGY
 
Ijetr042175
Ijetr042175Ijetr042175
Ijetr042175
 
Design development-and-implementation-of-a temperature-sensor-using-zigbee-co...
Design development-and-implementation-of-a temperature-sensor-using-zigbee-co...Design development-and-implementation-of-a temperature-sensor-using-zigbee-co...
Design development-and-implementation-of-a temperature-sensor-using-zigbee-co...
 
A REVIEW ON ANALYSIS OF 32-BIT AND 64-BIT RISC PROCESSORS
A REVIEW ON ANALYSIS OF 32-BIT AND 64-BIT RISC PROCESSORSA REVIEW ON ANALYSIS OF 32-BIT AND 64-BIT RISC PROCESSORS
A REVIEW ON ANALYSIS OF 32-BIT AND 64-BIT RISC PROCESSORS
 
Hg3612911294
Hg3612911294Hg3612911294
Hg3612911294
 
microprocessor-and-microcontroller
microprocessor-and-microcontrollermicroprocessor-and-microcontroller
microprocessor-and-microcontroller
 
Ajal mod 1
Ajal mod 1Ajal mod 1
Ajal mod 1
 
Risc and cisc eugene clewlow
Risc and cisc   eugene clewlowRisc and cisc   eugene clewlow
Risc and cisc eugene clewlow
 

Mehr von Nilesh Bhaskarrao Bahadure

Microcontroller 8051 instruction set and assemble directives
Microcontroller 8051 instruction set and assemble directivesMicrocontroller 8051 instruction set and assemble directives
Microcontroller 8051 instruction set and assemble directivesNilesh Bhaskarrao Bahadure
 

Mehr von Nilesh Bhaskarrao Bahadure (20)

Biomedical Signal Origin and Dynamics
Biomedical Signal Origin and DynamicsBiomedical Signal Origin and Dynamics
Biomedical Signal Origin and Dynamics
 
Introduction to Medical Image Processing
Introduction to Medical Image ProcessingIntroduction to Medical Image Processing
Introduction to Medical Image Processing
 
Timing diagram of microprocessor 8085
Timing diagram of microprocessor 8085Timing diagram of microprocessor 8085
Timing diagram of microprocessor 8085
 
Timers and counters of microcontroller 8051
Timers and counters of microcontroller 8051Timers and counters of microcontroller 8051
Timers and counters of microcontroller 8051
 
Serial communication of microcontroller 8051
Serial communication of microcontroller 8051Serial communication of microcontroller 8051
Serial communication of microcontroller 8051
 
Peripherals of Microprocessor 8085
Peripherals of Microprocessor 8085Peripherals of Microprocessor 8085
Peripherals of Microprocessor 8085
 
Microprocessor 8085 Basics
Microprocessor 8085 BasicsMicroprocessor 8085 Basics
Microprocessor 8085 Basics
 
Microcontroller 8051 instruction set and assemble directives
Microcontroller 8051 instruction set and assemble directivesMicrocontroller 8051 instruction set and assemble directives
Microcontroller 8051 instruction set and assemble directives
 
Microcontroller 8051 basics (part I)
Microcontroller 8051 basics (part I)Microcontroller 8051 basics (part I)
Microcontroller 8051 basics (part I)
 
Memory interfacing of microprocessor 8085
Memory interfacing of microprocessor 8085Memory interfacing of microprocessor 8085
Memory interfacing of microprocessor 8085
 
Memory interfacing of microcontroller 8051
Memory interfacing of microcontroller 8051Memory interfacing of microcontroller 8051
Memory interfacing of microcontroller 8051
 
Interrupts of microprocessor 8085
Interrupts of microprocessor 8085Interrupts of microprocessor 8085
Interrupts of microprocessor 8085
 
Interrupts of microcontroller 8051
Interrupts of microcontroller 8051Interrupts of microcontroller 8051
Interrupts of microcontroller 8051
 
Instruction sets of microprocessor 8085
Instruction sets of microprocessor 8085Instruction sets of microprocessor 8085
Instruction sets of microprocessor 8085
 
Embedded Systems
Embedded Systems Embedded Systems
Embedded Systems
 
Basic Electronics Semiconductor Diodes
Basic Electronics Semiconductor DiodesBasic Electronics Semiconductor Diodes
Basic Electronics Semiconductor Diodes
 
Basic Electronics Electrical Transducers
Basic Electronics Electrical TransducersBasic Electronics Electrical Transducers
Basic Electronics Electrical Transducers
 
Basic Electronics BJT
Basic Electronics BJTBasic Electronics BJT
Basic Electronics BJT
 
Applications of Microcontroller 8051
Applications of Microcontroller 8051Applications of Microcontroller 8051
Applications of Microcontroller 8051
 
Question Bank Programmable Logic Controller
Question Bank Programmable Logic ControllerQuestion Bank Programmable Logic Controller
Question Bank Programmable Logic Controller
 

Kürzlich hochgeladen

Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 

Kürzlich hochgeladen (20)

Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 

Microcontroller pic 16f877 architecture and basics

  • 1. Microcontroller (PIC) Basics of Microcontroller (PIC) Nilesh Bhaskarrao Bahadure Ph.D, ME, BE nbahadure@gmail.com https://www.sites.google.com/site/nileshbbahadure/home July 1, 2021 1 / 71
  • 2. Overview 1 Syllabus 2 Course Objectives & Outcomes 3 Objectives 4 What is Microcontroller 5 Microcontroller vs Microprocessor 6 Development/Classification of microcontrollers 7 Harvard vs. Princeton Architecture 8 RISC AND CISC CONTROLLERS Features of RISC 9 Microcontroller for Embedded Systems 10 x86 PC Embedded Applications 11 Choosing a Microcontroller Criteria for Choosing a Microcontroller 12 Mechatronics and Microcontrollers 13 A brief history of the PIC microcontroller 14 PIC Microcontrollers 15 Feature: PIC16F877 Simplified Features 2 / 71
  • 3. Syllabus Unit Heading No. of Lectures Unit 1: PIC Microcontrollers No of lectures - 3 The PIC Microcontrollers: History, Overview and Features. 3 / 71
  • 4. Course Objectives 1 To expose the students to the fundamentals of PIC Microcontroller 16F877 architecture and its Peripherals. 2 To introduce the advanced features in PIC Microcontroller 16F877. 3 To make student develop and practice assembly language and C language programming techniques 4 To enable student demonstrate and perform hardware interfacing and design. 4 / 71
  • 5. Course Outcomes At the end of the course, the student shall be able to, 1 Describe how PIC microcontroller and its peripherals function. 2 Interpret advanced features in PIC Microcontroller 16F877. 3 Program an embedded system in assembly and C. 4 Design, implement and test a single-processor embedded systems for real-time applications 5 / 71
  • 6. Objectives Upon completion of this chapter, you will be able to: 1 Compare and contrast microprocessors and microcontrollers [1, 2] 2 Describe the advantages of microcontrollers for some applications 3 Explain the concept of embedded systems 4 Discuss the criteria for considering Microcontroller 5 Explain the variations of speed, packaging, memory and cost per unit and how these affect choosing a Microcontroller 6 Compare and contrast the various members of the PIC family 7 Compare the PIC with microcontrollers offered by other manufactures. 6 / 71
  • 7. What is Microcontroller A Microcontroller is a programmable digital processor with necessary peripherals. Both microcontrollers and microprocessors are complex sequential digital circuits meant to carry out job according to the program / instructions. Sometimes analog input/output interface makes a part of microcontroller circuit of mixed mode(both analog and digital nature). 7 / 71
  • 8. Microcontroller vs Microprocessor Figure : Microprocessor system contrasted with Microcontroller system 8 / 71
  • 9. Microcontroller vs Microprocessor... A system designer using a general purpose microprocessor such as the Pentium or the PowerPC must add RAM, ROM, IO ports, and timers externally to make then functional. Although the addition of external RAM, ROM, and IO ports makes these systems bulkier and much more expensive, they have the advantage of versatility, enabling the designer to decide on the amount of RAM, ROM, and IO ports needed to fit the task at hand. This is not the case with microcontrollers. A Microcontroller has a CPU (a Microprocessor) in addition to a fixed amount of RAM, ROM, IO ports, and a timer all on a single chip. The fixed amount of ON - chip ROM, RAM, and number of IO ports in microcontrollers makes them ideal for many applications in which cost and space are critical. In many applications, for example a TV remote control, there is no need for the consuming power of a 486 or even an 8086 microprocessor. In many applications, the space used, the power consumed, and the price per unit are much critical considerations than the computing power. 9 / 71
  • 10. Microcontroller vs Microprocessor... 1 A microprocessor requires an external memory for program/data storage. Instruction execution requires movement of data from the external memory to the microprocessor or vice versa. Usually, microprocessors have good computing power and they have higher clock speed to facilitate faster computation. 2 A microcontroller has required on-chip memory with associated peripherals. A microcontroller can be thought of a microprocessor with inbuilt peripherals. 3 A microcontroller does not require much additional interfacing ICs for operation and it functions as a stand alone system. The operation of a microcontroller is multipurpose, just like a Swiss knife. 4 Microcontrollers are also called embedded controllers. A microcontroller clock speed is limited only to a few tens of MHz. Microcontrollers are numerous and many of them are application specific. 10 / 71
  • 11. Development/Classification of microcontrollers Microcontrollers have gone through a silent evolution (invisible). The evolution can be rightly termed as silent as the impact or application of a microcontroller is not well known to a common user, although microcontroller technology has undergone significant change since early 1970’s. Development of some popular microcontrollers is given as follows. 11 / 71
  • 12. Development/Classification of microcontrollers... Processor No. of Bits Year Intel 4004 4 bit (2300 PMOS trans, 108 kHz) 1971 Intel 8048 8 bit 1976 Intel 8031 8 bit (ROM-less) – Intel 8051 8 bit (Mask ROM) 1980 Microchip PIC16C64 8 bit 1985 Motorola 68HC11 8 bit (on chip ADC) – Intel 80C196 16 bit 1982 Atmel AT89C51 8 bit (Flash memory) – Microchip PIC 16F877 8 bit (Flash memory + ADC) – 12 / 71
  • 13. Harvard vs. Princeton Architecture Harvard vs. Princeton Many years ago, in the late 1940’s, the US Government asked Harvard and Princeton universities to come up with a computer architecture to be used in computing distances of Naval artillery shell for defense applications. Princeton suggested computer architecture with a single memory interface. It is also known as Von Neumann architecture after the name of the chief scientist of the project in Princeton University John Von Neumann (1903 - 1957 Born in Budapest, Hungary). Harvard suggested a computer with two different memory interfaces, one for the data / variables and the other for program / instructions. Although Princeton architecture was accepted for simplicity and ease of implementation, Harvard architecture became popular later, due to the parallelism of instruction execution. 13 / 71
  • 14. Princeton Architecture - Single Memory Interface Figure : Princeton Architecture 14 / 71
  • 15. Harvard Architecture (Separate Program and Data Memory interfaces) Figure : Harvard Architecture 15 / 71
  • 16. RISC AND CISC CONTROLLERS There are some differences that an Electronics Engineer must know regarding the design aspect of microcontrollers. RISC stands for reduced instruction set computing and CISC stands for complex instruction set computing. As the name implies RISC perform the same operation as CISC can perform, but on the reduced instruction. In other words, we can say that with only few or less number of instruction compared to CISC, RISC can perform all the operations initiated by CISC computing approach. 16 / 71
  • 17. RISC AND CISC CONTROLLERS... The CISC Approach The primary goal of CISC architecture is to complete a task in as few lines of assembly as possible. This is achieved by building processor hardware that is capable of understanding and executing a series of operations. For this particular task, a CISC processor would come prepared with a specific instruction (we’ll call it ”MULT”). When executed, this instruction loads the two values into separate registers, multiplies the operands in the execution unit, and then stores the product in the appropriate register. Thus, the entire task of multiplying two numbers can be completed with one instruction. 17 / 71
  • 18. RISC AND CISC CONTROLLERS... The RISC Approach RISC processors only use simple instructions that can be executed within one clock cycle. Thus, the ”MULT” command described above could be divided into three separate commands: ”LOAD,” which moves data from the memory bank to a register, ”PROD,” which finds the product of two operands located within the registers, and ”STORE,” which moves data from a register to the memory banks. In order to perform the exact series of steps described in the CISC approach, a programmer would need to code four lines of assembly: LOAD A, 2:3 LOAD B, 5:2 PROD A, B STORE 2:3, A 18 / 71
  • 19. RISC AND CISC CONTROLLERS... The RISC Approach At first, this may seem like a much less efficient way of completing the operation. Because there are more lines of code, more RAM is needed to store the assembly level instructions. The compiler must also perform more work to convert a high-level language statement into code of this form. 19 / 71
  • 20. Features of RISC Feature 1 RISC processors have a fixed instruction size. In a CISC microcontroller such as the 8051, instructions can be 1, 2, or even 3 bytes. For example, look at the following instructions in the 8051: CLR C ; Clear carry flag ; 1- byte instruction ADD A, #20h ; 2-byte instruction LJMP 2000 ; 3-byte instruction This variable instruction size makes the task of the instruction decoder very difficult because the size of the incoming instruction is never known. In RISC architecture, the size of all instructions is fixed. Therefore, the CPU can decode the instructions quickly. 20 / 71
  • 21. Features of RISC Feature 2 One of the major characteristics of RISC architecture is a large number of registers. ALL RISC architectures have at least 32 registers. Of these 32 registers only a few are assigned to a dedicated function. Feature 3 RISC processors have a small instruction set. RISC processors have only the basic instructions such as ADD, SUB, MUL, LOAD, STORE, AND, OR, EXOR, CALL, JUMP, and so on. The limited number of instructions is one of the criticism leveled at the RISC processor because it makes the job of assembly language programmer much more tedious and difficult compared to CISC programmer. This is one reason RISC processor mostly used in high language environment such as C. 21 / 71
  • 22. Features of RISC Feature 4 The most important characteristics of the RISC processor is that more than 95% of instructions are executed with only one clock cycle, in contrast to CISC instructions. Feature 5 RISC processors have separate buses for data and code. In all the x86 processors, like all other CISC computers, there is one set of buses for all the address and another set of buses for data carrying opcodes and operand in and out of the CPU. In RISC processors, there are four sets of buses: 1. A set of data buses for carrying data (operand) 2. A set of address bus for accessing the data 3. A set of buses to carry the opcodes 4. A set of address buses to access the opcodes The use use of separate buses for code and data operands is commonly referred to as Harvard architecture. 22 / 71
  • 23. Features of RISC Feature 6 In case of RISC, however, due to the small set of instructions, they are implemented using the hardwire method. Hardwiring of RISC insructions takes no more than 10% of the transistors, the same will take 40 - 60% of transistors in many CISC processors. Feature 7 RISC uses load/store architecture. In CISC microprocessors, data can be manipulated while it is still in memory. 23 / 71
  • 24. Microcontroller for Embedded Systems Microprocessors and microcontrollers are widely used in embedded system products. An embedded product is controlled by its own internal microprocessor or Microcontroller as opposed to an external controller. Typically, in an embedded system, the microcontrollers ROM are burned with a purpose for specific functions needed for the system. A printer is an example of an embedded system because the processor inside it performs one task only; namely, getting the data and printing it. Contrast this with a Pentium based PC, which can be used for any number of applications such as word processor, print server, bank teller terminal, video game player, network server or internal terminal. 24 / 71
  • 25. Microcontroller for Embedded Systems... A PC can also load and run software for a variety of applications. Of course, the reason a PC can perform myriad tasks is that it has RAM memory and an operating system that loads the application software into RAM and lets the CPU run it. In an embedded system, typically only one application software is burned into ROM. An x86 PC contains or is connected to various embedded products such as the keyboard, printer, modem, disk controller, sound card, CD - ROM driver, mouse, and so on. Each of these peripherals has a Microcontroller inside it that performs only one task. For example, inside every mouse a Microcontroller performs the task of finding the mouse’s position and sending it to the PC. 25 / 71
  • 26. Microcontroller for Embedded Systems... Home Office Auto Appliances Telephones Trip computer Intercom Computers Engine control Telephone Security systems Air bag Security systems Fax Machines ABS Garage door openers Microwave Instrumentation Answering machines Copier Security system Fax machines Laser printer Transmission control Home computers Color Printer Entertainment TVs Paging Climate control Cable TV tuner Keyless entry VCR Camcorders Remote controls Video games, cellular phones Musical instruments Sewing machines Lighting control Paging Camera 26 / 71
  • 27. x86 PC Embedded Applications Although microcontrollers are the preferred choice for many embedded systems, sometimes a Microcontroller is inadequate for the task. For this reason, in recent years many manufactures of general purpose microprocessors such as Intel, Freescale Semiconductors (Formerly Motorola), and AMD (Advanced Micro Devices, Inc.) have targeted their microprocessor for the high end of the embedded market. Intel and AMD push their x86 processors for both the embedded and desktop PC markets. In the early 1990s, apple computer began using the PowerPC microprocessors (604, 603, 620 etc) in place of the 680x0 for the Macintosh. The PowerPC microprocessor is a joint venture between IBM and Motorola, and is targeted for the high end of the embedded market as well as the PC market. It must be noted that when a company targets a general purpose microprocessor for the embedded market it optimizes the processor used for embedded systems. For this reason these processors are often called high end embedded processors. Another chip widely used in the high end of the embedded system design is the ARM microprocessor. Very often the terms embedded processor and Microcontroller are used 27 / 71
  • 28. x86 PC Embedded Applications... One of the most critical needs of an embedded system is to decrease power consumption and space. This can be achieved by integrating more functions into the CPU chip. All the embedded processors based on the x86 and PowerPC 6xx have low power consumption in addition to some forms of I/O, COM port, and ROM, all on a single chip. In high performance embedded processors, the trend is to integrate more and more functions on the CPU chip and let the designer decides which features to use. This trend is invading PC system design as well. Normally in designing the PC motherboard we need a CPU plus a chipset containing I/O a cache controller, a flash ROM containing BIOS, and finally a secondary cache memory. 28 / 71
  • 29. x86 PC Embedded Applications... Currently, because of Linux, MS- DOS, and Windows standardization, many embedded systems use x86 PCs. In many cases, using x86 PCs for the high end embedded applications not only saves money but also shortens development times because a vast library of software already exists for the Linus, DOS and Windows plate form. 29 / 71
  • 30. Choosing a Microcontroller There are five major 8 - bit microcontrollers. They are: Freescale Semiconductor’s (Motorola) 68HC08/68HC11, Intel’s 8051, Atmel’s AVR, Zilog’s Z8 and PIC from Microchip technology. Each of the above microcontrollers has a unique instruction set and register set; therefore they are not compatible with each other. Programs written for one will not run on the others. There are also 16 and 32 bit microcontrollers made by various chip makers. With all these different microcontrollers, what criteria for designers consider in choosing one? Three criteria in choosing microcontrollers are as follows: 30 / 71
  • 31. Choosing a Microcontroller Choosing a Microcontroller 1 Meeting the computing needs of the task at hand efficiently and cost effectively 2 Availability of software and hardware development tools such as compilers, assemblers, debuggers, and emulators and 3 Wide availability and reliable source of microcontrollers. 31 / 71
  • 32. Criteria for Choosing a Microcontroller I 1 The first and foremost criterion in choosing a Microcontroller is that it must meet the task at hand efficiently and cost effectively. In analyzing the needs of a Microcontroller - based project, we must first see whether an 8 - bit, 16 bit or 32 bit Microcontroller can best handle the computing needs of the task most effectively. Among other considerations in this category are: Speed: What is the highest speed that the Microcontroller supports? Packaging: Does it come in a40-pin DIP (dual in line package) or a QFP (quad flat package), or some other packaging format? This is important in terms of space, assembling, and prototyping the end product. Power consumption:This is especially critical for battery-powered products. The amount of RAM and ROM on the chip. The number of I/O pins and the timer on the chip. Ease of upgrade to higher-performance or lower-power-consumption versions. 32 / 71
  • 33. Criteria for Choosing a Microcontroller II Cost per unit:This is important in terms of the final cost of the product in which a Microcontroller is used. For example, some microcontrollers cost 50 cents per unit when purchased 1000,000 units at a time. 2 The second criterion in choosing a Microcontroller is how easy it is to develop products around it. Key considerations include the availability of an assembler, debugger, a code-efficient C language compiler, emulator, technical sup-port, and both in-house and outside expertise. In many cases, third-party vendor (i.e., a supplier other than the chip manufacturer) support for the chip is as good as, if not better than, support from the chip manufacturer. 33 / 71
  • 34. Criteria for Choosing a Microcontroller III 3 The third criterion in choosing a microcontroller is its ready availability in needed quantities both now and in the future. For some designers this is even more important than the first two criteria. Currently, of the leading 8-bit micro-controllers, the 8051 family has the largest number of diversified (multiple source) suppliers. (Supplier means a producer besides the originator of the microcontroller.) In the case of the 8051, which was originated by Intel, several companies also currently produce (or have produced in the past) the 8051. 34 / 71
  • 35. Mechatronics and Microcontrollers The microcontroller is playing a major role in an emerging field called Mecha- tronics. Here is an excellent summary of what the field of Mechatronics is all about, ”Many technical processes and products in the area of mechan- ical and electrical engineering show an increasing integration of mechanics with electronics and information processing. This integration is between the components (hardware) and the information-driven functions (software), re- sulting in integrated systems called Mechatronics systems. The development of Mechatronics systems involves finding an optimal balance between the basic mechanical structure, sensor and actuator implementation, automatic digital information processing and overall control, and this synergy results in innovative solutions. The practice of Mechatronics requires multidisciplinary expertise across a range of disciplines, such as: mechanical engineering, elec- tronics, information technology, and decision making theories.” 35 / 71
  • 36. A brief history of the PIC microcontroller I In 1989, Microchip Technology Corporation introduced an 8-bit micro-controller called the PIC, which stands for Peripheral Interface Controller. This microcontroller had small amounts of data RAM, a few hundred bytes of on-chip ROM for the program, one timer, and a few pins for I/O ports, all on a single chip with only 8 pins.The simplified view of PIC microcontroller is shown in Figure 4. It is amazing that a company that began with such a humble product became one of the leading suppliers of 8-bit microcontrollers in less than a decade. At the time of this writing, Microchip is the number-one supplier of 8-bit microcontrollers in the world. Since the introduction of the PIC16xxx, they have introduced an array of 8-bit microcontrollers too numerous to list here. They include the PIC families of 10xxx, 12xxx, 14xxx, 16xxx, 17xxx, and 18xxx. They are all 8-bit processors, meaning that the CPU can work on only 8 bits of data at a time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU. One of the problems with the PIC family is that they are not all 100% upwardly compatible in terms of software when going from one family to another family. For example, while the 12xxx/16xxx have 12-bit and 14-bit wide instructions, the PIC18xxx instruction is 16 bits wide with many new instructions. 36 / 71
  • 37. A brief history of the PIC microcontroller II Figure : Simplified View of a PIC Microcontroller 37 / 71
  • 38. PIC Microcontrollers I PIC stands for Peripheral Interface Controller given by Microchip Technology to identify its single-chip microcontrollers. These devices have been very successful in 8-bit microcontrollers. The main reason is that Microchip Technology has continuously upgraded the device architecture and added needed peripherals to the microcontroller to suit customers’ requirements. The development tools such as assembler and simulator are freely available on the internet at www.microchip.com. The architectures of various PIC microcontrollers can be divided as follows. 38 / 71
  • 39. PIC Microcontrollers II Low - end PIC Architectures: Microchip PIC microcontrollers are available in various types. When PIC microcontroller MCU was first available from General Instruments in early 1980’s, the microcontroller consisted of a simple processor executing 12-bit wide instructions with basic I/O functions. These devices are known as low-end architectures. They have limited program memory and are meant for applications requiring simple interface functions and small program data memories. Some of the low-end device numbers are 1 12C5XX 2 16C5X 3 16C505 39 / 71
  • 40. PIC Microcontrollers III Mid range PIC Architectures Mid range PIC architectures are built by upgrading low-end architectures with more number of peripherals, more number of registers and more data/program memory. Some of the mid-range devices are 1 16C6X 2 16C7X 3 16F87X Program memory type is indicated by an alphabet. 1 C = EPROM 2 F = Flash 3 RC = Mask ROM Popularity of the PIC microcontrollers is due to the following factors. 40 / 71
  • 41. PIC Microcontrollers IV 1 Speed: Harvard Architecture, RISC architecture, 1 instruction cycle = 4 clock cycles. 2 Instruction set simplicity: The instruction set consists of just 35 instructions (as opposed to 111 instructions for 8051). 3 Power-on-reset and brown-out reset. Brown-out-reset means when the power supply goes below a specified voltage (say 4V), it causes PIC to reset; hence malfunction is avoided. 4 A watch dog timer (user programmable) resets the processor if the software/program ever malfunctions and deviates from its normal operation. 5 PIC microcontroller has four optional clock sources. Low power crystal Mid range crystal High range crystal RC oscillator (low cost). 41 / 71
  • 42. PIC Microcontrollers V 6 Programmable timers and on-chip ADC. 7 Up to 12 independent interrupt sources. 8 Powerful output pin control (25 mA (max.) current sourcing capability per pin.) 9 EPROM/OTP/ROM/Flash memory option. 10 I/O port expansion capability. 11 Free assembler and simulator support from Microchip at www.microchip.com 42 / 71
  • 43. Feature: PIC16F877 I 1 High performance RISC CPU 2 Only 35 single word instructions to learn 3 All single cycle instructions except for program branches which are two cycle 4 Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle 5 Up to 8K x 14 words of FLASH Program Memory, Up to 368 x 8 bytes of Data Memory (RAM) Up to 256 x 8 bytes of EEPROM Data Memory 6 Pinout compatible to the PIC16C73B/74B/76/77 7 Interrupt capability (up to 14 sources) 8 Eight level deep hardware stack 9 Direct, indirect and relative addressing modes 43 / 71
  • 44. Feature: PIC16F877 II 10 Power-on Reset (POR) 11 Power-up Timer (PWRT) and Oscillator Start-up Timer (OST) 12 Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation 13 Programmable code protection 14 Power saving SLEEP mode 15 Selectable oscillator options 16 Low power, high speed CMOS FLASH/EEPROM technology 17 Fully static design 18 In-Circuit Serial Programming (ICSP)via two pins 19 Single 5V In-Circuit Serial Programming capability 20 In-Circuit Debugging via two pins 21 Processor read/write access to program memory 44 / 71
  • 45. Feature: PIC16F877 III 22 Wide operating voltage range: 2.0V to 5.5V 23 High Sink/Source Current: 25 mA 24 Commercial, Industrial and Extended temperature ranges 25 Low-power consumption: < 0.6 mA typical @ 3V, 4 MHz 20 µ A typical @ 3V, 32 kHz < 1 µ A typical standby current 26 Peripheral Features: 27 Timer0: 8-bit timer/counter with 8-bit prescaler 28 Timer1: 16-bit timer/counter with prescaler, can be incremented during SLEEP via external crystal/clock 29 Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler 30 Two Capture, Compare, PWM modules Capture is 16-bit, max. resolution is 12.5 ns 45 / 71
  • 46. Feature: PIC16F877 IV Compare is 16-bit, max. resolution is 200 ns PWM max. resolution is 10-bit 31 10-bit multi-channel Analog-to-Digital converter 32 Synchronous Serial Port (SSP) with SPI (Master mode) and I2C(Master/Slave) 33 Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address detection 34 Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS controls (40/44-pin only) 35 Brown-out detection circuitry for Brown-out Reset (BOR) 46 / 71
  • 47. Simplified Features I : Simplified features Features Description CPU 8-bit PIC Number of Pins 40 Operating Voltage (V) 2 to 5.5 V Number of I/O pins 33 ADC Module 8ch, 10-bit Timer Module 8-bit(2), 16-bit(1) Comparators 2 DAC Module Nil 47 / 71
  • 48. Simplified Features II Communication Peripherals UART(1), SPI(1), I2C(1), MSSP(SPI/I2C) External Oscillator Up to 20Mhz Internal Oscillator Nil Program Memory Type Flash Program Memory (KB) 14KB CPU Speed (MIPS) 5 MIPS RAM Bytes 368 Data EEPROM 256 bytes 48 / 71
  • 50. Pin Diagram of PIC16F877 50 / 71
  • 51. Pin Diagram of PIC16F877... 51 / 71
  • 52. Pin Diagram of PIC16F877... I 1 The first pin is the master clear pin of this IC. It resets the microcontroller and is active low, meaning that it should constantly be given a voltage of 5V and if 0 V are given then the controller is reset. Resetting the controller will bring it back to the first line of the program that has been burned into the IC. 52 / 71
  • 53. Pin Diagram of PIC16F877... II A push button and a resistor is connected to the pin. The pin is already being supplied by constant 5V. When we want to reset the IC we just have to push the button which will bring the MCLR pin to 0 potential thereby resetting the controller. 2 PIN 2: RA0/AN0 PORTA consists of 6 pins, from pin 2 to pin 7, all of these are bidirectional input/output pins. Pin 2 is the first pin of this port. This pin can also be used as an analog pin AN0. It is built in analog to digital converter. 3 PIN 3: RA1/AN1 This can be the analog input 1. 4 PIN 4: RA2/AN2/Vref- It can also act as the analog input2. Or negative analog reference voltage can be given to it. 53 / 71
  • 54. Pin Diagram of PIC16F877... III 5 PIN 5: RA3/AN3/Vref+ It can act as the analog input 3. Or can act as the analog positive reference voltage. 6 PIN 6: RA0/T0CKI To timer0 this pin can act as the clock input pin, the type of output is open drain. 7 PIN 7: RA5/SS/AN4 This can be the analog input 4. There is synchronous serial port in the controller also and this pin can be used as the slave select for that port. 8 PIN 8: RE0/RD/AN5 PORTE starts from pin 8 to pin 10 and this is also a bidirectional input output port. It can be the analog input 5 or for parallel slave port it can act as a read control pin which will be active low. 54 / 71
  • 55. Pin Diagram of PIC16F877... IV 9 PIN 9: RE1/WR/AN6 It can be the analog input 6. And for the parallel slave port it can act as the write control which will be active low. 10 PIN 10: RE2/CS/A7 It can be the analog input 7, or for the parallel slave port it can act as the control select which will also be active low just like read and write control pins. 11 PIN 11 and 32: VDD These two pins are the positive supply for the input/output and logic pins. Both of them should be connected to 5V. 12 PIN 12 and 31: VSS These pins are the ground reference for input/output and logic pins. They should be connected to 0 potential. 13 PIN 13: OSC1/CLKIN This is the oscillator input or the external clock input pin. 55 / 71
  • 56. Pin Diagram of PIC16F877... V 14 PIN 14: OSC2/CLKOUT This is the oscillator output pin. A crystal resonator is connected between pin 13 and 14 to provide external clock to the microcontroller. 1 4 of the frequency of OSC1 is outputted by OSC2 in case of RC mode. This indicates the instruction cycle rate. 56 / 71
  • 57. Pin Diagram of PIC16F877... VI 15 PIN 15: RC0/T1OCO/T1CKI PORTC consists of 8 pins. It is also a bidirectional input output port. Of them, pin 15 is the first. It can be the clock input of timer 1 or the oscillator output of timer 2. 16 PIN 16: RC1/T1OSI/CCP2 It can be the oscillator input of timer 1 or the capture 2 input/compare 2 output/ PWM 2 output. 17 PIN 17: RC2/CCP1 It can be the capture 1 input/ compare 1 output/ PWM 1 output. 18 PIN 18: RC3/SCK/SCL It can be the output for SPI or I2C modes and can be the input/output for synchronous serial clock. 19 PIN 23: RC4/SDI/SDA It can be the SPI data in pin. Or in I2C mode it can be data input/output pin. 57 / 71
  • 58. Pin Diagram of PIC16F877... VII 20 PIN 24: RC5/SDO It can be the data out of SPI in the SPI mode. 21 PIN 25: RC6/TX/CK It can be the synchronous clock or USART Asynchronous transmit pin. 22 PIN 26: RC7/RX/DT It can be the synchronous data pin or the USART receive pin. 23 PIN 19,20,21,22,27,28,29,30: All of these pins belong to PORTD which is again a bidirectional input and output port. When the microprocessor bus is to be interfaced, it can act as the parallel slave port. 24 PIN 33-40: PORT B All these pins belong to PORTB. Out of which RB0 can be used as the external interrupt pin and RB6 and RB7 can be used as in-circuit debugger pins. 58 / 71
  • 59. Pin Diagram of PIC16F877... 59 / 71
  • 60. Pin Diagram of PIC16F877... 60 / 71
  • 61. CPU Architecture: The CPU uses Harvard architecture with separate Program and Variable (data) memory interface. This facilitates instruction fetch and the operation on data/accessing of variables simultaneously. Figure : CPU Architecture of PIC microcontroller 61 / 71
  • 62. PIC Memory Organization: I PIC microcontroller has 13 bits of program memory address. Hence it can address up to 8k of program memory. The program counter is 13-bit. PIC 16C6X or 16C7X program memory is 2k or 4k. While addressing 2k of program memory, only 11-bits are required. Hence two most significant bits of the program counter are ignored. Similarly, while addressing 4k of memory, 12 bits are required. Hence the MSB of the program counter is ignored. 62 / 71
  • 63. PIC Memory Organization: II Figure : Program Memory Map 63 / 71
  • 64. PIC Memory Organization: III The program memory map of PIC16C74A is shown in Fig 6. On reset, the program counter is cleared and the program starts at 00H. Here a ’goto’ instruction is required that takes the processor to the mainline program. When a peripheral interrupt, that is enabled, is received, the processor goes to 004H. A suitable branching to the interrupt service routine (ISR) is written at 004H. Data memory (Register Files): Data Memory is also known as Register File. Register File consists of two components. 1 General purpose register file (same as RAM). 2 Special purpose register file (similar to SFR in 8051). 64 / 71
  • 65. PIC Memory Organization: IV Figure : Data Memory Map 65 / 71
  • 66. PIC Memory Organization: V The special purpose register file consists of input/output ports and control registers. Addressing from 00H to FFH requires 8 bits of address. However, the instructions that use direct addressing modes in PIC to address these register files use 7 bits of instruction only. Therefore the register bank select (RP0) bit in the STATUS register is used to select one of the register banks. In indirect addressing FSR register is used as a pointer to anywhere from 00H to FFH in the data memory. 66 / 71
  • 68. Que - 1 2018 (SLR - TJ-221) - Marks 1 PIC 16F877 devices . . . . . . bit program counter capable of addressing . . . . . . program memory. (a) 8, 256K x 8 (b) 16, 64K x 8 (c) 13, 8K x 14 (d) 14, 8K x 13 Answer (c) 13, 8K x 14 68 / 71
  • 69. Que - 2 2018 (SLR - TJ-221) - Marks 1 PIC16F877 is a . . . . . . bit microcontroller (a) 8 (b) 16 (c) 32 (d) None of the above Answer (a) 8 69 / 71
  • 70. References Muhammad Ali Mazidi, Rolin D. McKinlay, and Danny Causey. PIC Microcontroller and Embedded Systems - Using Assembly and C for PIC18. Pearson International Edition, Upper Saddle River, NJ, 2008. Martin P. Bates. Programming 8 - bit PIC Microcontrollers in C with Interactive Hardware Simulation. Newnes Press Private Limited, United Kingdom, 2008. 70 / 71
  • 71. Thank you Please send your feedback at nbahadure@gmail.com For download and more information [Click Here] 71 / 71