Vous êtes sur la page 1sur 34

S O INFOTECH (P) LTD.

( DUCAT-NOIDA )

TRAINING REPORT ON
PIC MICROCONTROLLER

BY AKASH GAUR
 ACKNOWLEDGEMENT.
 PREFACE.
 CERTIFICATE.
 S O INFOTECH (P) LTD.
 AN OVERVIEW.
 COMPANY PARTNER – DUCAT (INDIA)

EMBEDDED SYSTEMS
 OVERVIEW

 MICROCONTROLLERS
 INTRODUCTION.
 MICROPROCESSORS versus
MICROCONTROLLERS
 PIC (SERIES NO. :- 16F877)
 INTRODUCTION
 STATUS REGISTER
 PIN DIAGRAM
 INSTRUCTION SET

REFRENCES
ACKNOWLEDGEMENT

I take this opportunity to express my sincere gratitude towards my college Training and
placement officer for forwarding my training letter to S O INFOTECH (DUCAT), Noida
and also to Ms. MENKA SURI (HR MANAGER), for accepting my letter and allowing
me to complete my training in S O INFOTECH (DUCAT ) NOIDA..

I would like to express my deep satisfaction and gratitude towards Ms. MANVI for his
timely guidance and help extended during each stage of my project.      

Finally, I would like to thank each and every member of S O INFOTECH AND DUCAT
family for making me feel comfortable and helping me in every possible manner.

AKASH GAUR…
PREFACE

The six to eight weeks training is a part of our 4-year B.TECH course.
Practical industrial training mainly aims at making one aware of industrial
environment; which means that one gets to know the limitation, constraint
and freedom under which an engineer works. One also gets an opportunity
to watch from close quarter that indicates manager relation. This training
mainly involves industrial and complete knowledge about designing,
assembling and manufacturing process of various equipments
manufactured by an industry.
SO INFOTECH is a leading India based software development outsourcing company focused on
delivering the best and most cost-effective solutions to our clients in areas such as e-finance, e-
business and media.
IT Provide Maintenance Services ("off sourcing") for companies ranging from the Global 2000 to
promising startups Combining proven expertise in technology.

S O Infotech is a global IT services and solutions provider. IT provide the winning edge to our clients
by leveraging our business-to-IT connect and deeply committed people. Our clients include industry
leaders, they have found in us a right-size partner who combines scale, stability and customer-
centricity
Strong domain connect
IT’S solutions have a strong domain focus that helps our clients in different industries maximize the
value of their IT spend.
SOINFOTECH PVT.LTD provides complete IT Solution services:

SOFTWARE DEVELOPMENT

SOINFOTECH develops softwares for various clients covering every aspect of life.
We accomplish it with a combination of business and technical knowledge on the
requirement of the clients. With experienced and dedicated lot, we are able to go
with the chosen framework and documentation standards. We use documented
systems to provide full satisfaction on the quality...

SOFTWARE MAINTENANCE

India has emerged as a leading provider of software services and products. Along
with software development services an added area that is gaining much attention is software
support and maintenance services. ...

WEBSITE DESIGN SERVICES

SO INFO, provides a full range of website design services at affordable cost. We


are known for our clarity in work, whether it be design style, graphics, content placement or
simple artwork. We have designed websites for entrepreneurs, large and small businesses
dealing with everyday products. Our proven methodology ensures to deliver a user friendly
website that has high functionality and performance....

MULTIMEDIA DEVELOPMENT

SOINFOTECH has been in the field of Multimedia Presentations ever since its
inception. Computer Based Tutorials, Corporate Presentations, Product Presentations, 3D
and 2D Animations and Catalogue Designing...
TESTING SOLUTIONS

SOINFOTECH offers Manual and Automated Testing Services. We provide


customized, effective and efficient solutions to our clients. Software quality is one of the
critical factors, which influence the business prospects...

WEB SOLUTION

Dominion architecture-based software development era is at its end. Business


worldwide is shifting to complex and multitude standards. Subsequently Web Solution is the
need of the hour.

TECHNICAL WRITING

SOINFOTECH offers Technical Writing Services. Our services cover two very
important areas: User Manual and Courseware Development. User Manual covers critical
writing areas...
SEO
SOINFOTECH offers world-class search engine marketing and optimization services that
include SEO consulting services, market research, SEO analysis, and much more…
Backed by a team of professionals
who have successfully trained and
placed students. DUCAT offers a
wide spectrum of technical courses
and application courses designed to
suit every skill level, as well as the
ability to consult directly with
organizations to tailor made learning
plans for any number of employees.
 
  Our products and services have a
wide appeal and are applicable those
in varied positions including network
administrators, systems analysts,
systems architects, test engineers,
software developers, help desk staff,
IT managers, senior executives,
administrative assistants and
business professionals.
     
 

 
EMBEDDED SYSTEM

An embedded system is a computer system


designed to perform one or a few dedicated
functions[1] [2] often with real-time
computing constraints. It is embedded as
part of a complete device often including
hardware and mechanical parts. By contrast,
a general-purpose computer, such as a
personal computer (PC), is designed to be
flexible and to meet a wide range of
end-user needs. Embedded systems control
many devices in common use today.[3]
Embedded systems are controlled by one or
more main processing cores that are
typically either microcontrollers or digital
signal processors (DSP).[4] The key
characteristic, however, is being dedicated
to handle a particular task, which may
require very powerful processors. For
example, air traffic control systems may usefully be viewed as embedded, even though they
involve mainframe
computers and dedicated regional and national networks between airports and radar sites.
(Each radar probably includes one or more embedded systems of its own.)
Since the embedded system is dedicated to specific tasks, design engineers can optimize it to
reduce the size and cost of the product and increase the reliability and performance. Some
embedded systems are mass-produced, benefiting
from economies of scale. Physically, embedded systems range from portable devices such as
digital watches and MP3 players, to large
stationary installations like traffic lights, factory controllers, or the systems controlling nuclear
power plants. Complexity varies from low, with a single microcontroller chip, to very high
with multiple units, peripherals and networks mounted inside a large chassis or enclosure. In
general, "embedded system" is not a strictly definable term, as most systems have some
element of extensibility or
programmability. For example, handheld computers share some elements with embedded
systems such as the operating systems and microprocessors which power them, but they allow
different applications to be loaded and
peripherals to be connected. Moreover, even systems which don't expose programmability as a
primary feature generally need to support software updates. On a continuum from "general
purpose" to "embedded", large
application systems will have subcomponents at most points even if the system as a whole is
"designed to perform one or a few dedicated functions", and is thus appropriate to call
"embedded".

Variety of embedded systems

Embedded systems span all aspects of


modern life and there are many examples of their use.Telecommunications systems employ
numerous embedded systems from telephone switches for the network to mobile phones at the
end-user. Computer networking uses dedicated routers and network bridges to route data.
Consumer electronics include personal digital assistants (PDAs), mp3 players, mobile phones,
videogame consoles, digital cameras, DVD players, GPS receivers, and printers. Many
household appliances, such as microwave ovens, washing machines and dishwashers, are
including embedded systems to provide flexibility, efficiency and features. Advanced HVAC
systems use networked thermostats to more accurately and efficiently control temperature that
can change by time of day and season. Home automation uses wired- and wireless-networking
that can be used to control lights, climate, security, audio/visual, surveillance, etc., all of which
use embedded devices for sensing and controlling. Transportation systems from flight to
automobiles increasingly use embedded systems. New airplanes contain advanced avionics
such as inertial guidance systems and GPS receivers that also have considerable safety
requirements. Various electric motors — brushless DC motors, induction motors and DC
motors — are using electric/electronic motor controllers. Automobiles, electric vehicles, and
hybrid vehicles are increasingly using embedded systems to maximize efficiency and reduce
pollution. Other automotive safety systems include anti-lock braking system (ABS), Electronic
stability Control (ESC/ESP), traction control (TCS) and automatic four-wheel drive.
Medical equipment is continuing to advance with more embedded systems for vital signs
monitoring, electronic stethoscopes for amplifying sounds, and various medical imaging (PET,
SPECT, CT, MRI) for non-invasive internal
inspections.
In addition to commonly described embedded systems based on small computers, a new class
of miniature wireless devices called motes are quickly gaining popularity as the field of
wireless sensor networking rises. Wireless sensor
networking, WSN, makes use of miniaturization made possible by advanced IC design to
couple full wireless subsystems to sophisticated sensors, enabling people and companies to
measure a myriad of things in the physical
world and act on this information through IT monitoring and control systems. These motes are
completely self contained, and will typically run off a battery source for many years before the
batteries need to be changed or
charged.

History
In the earliest years of computers in the 1940–50s, computers were sometimes dedicated to a
single task, but were far too large and expensive for most kinds of tasks performed by
embedded computers of today. Over time however,
the concept of programmable controllers evolved from traditional electromechanical
sequencers, via solid state devices, to the use of computer technology.
One of the first recognizably modern embedded systems was the Apollo Guidance Computer,
developed by Charles Stark Draper at the MIT Instrumentation Laboratory. At the project's
inception, the Apollo guidance computer was
considered the riskiest item in the Apollo project as it employed the then newly developed
monolithic integrated circuits to reduce the size and weight. An early mass-produced
embedded system was the Autonetics D-17 guidance
computer for the Minuteman missile, released in 1961. It was built from transistor logic and
had a hard disk for main memory. When the Minuteman II went into production in 1966, the
D-17 was replaced with a new computer that
was the first high-volume use of integrated circuits. This program alone reduced prices on
quad nand gate ICs from $1000/each to $3/each, permitting their use in commercial products.
Since these early applications in the 1969s, embedded systems have come down in price and
there has been a
dramatic rise in processing power and functionality. The first microprocessor for example, the
Intel 4004, was designed for calculators and other small systems but still required many
external memory and support chips. In 1978
National Engineering Manufacturers Association released a "standard" for programmable
microcontrollers, including almost any computer-based controllers, such as single board
computers, numerical, and event-based controllers.
As the cost of microprocessors and microcontrollers fell it became feasible to replace
expensive knob-based analog components such as potentiometers and variable capacitors with
up/down buttons or knobs read out by a microprocessor even in some consumer products. By
the mid-1980s, most of the common previously external system components had been
integrated into the same chip as the processor and this modern form of the microcontroller
allowed an even more widespread use, which by the end of the decade were the norm rather
than the exception for almost all electronics devices.
The integration of microcontrollers has further increased the applications for which embedded
systems are used into areas where traditionally a computer would not have been considered. A
general purpose and comparatively low-cost
microcontroller may often be programmed to fulfill the same role as a large number of
separate components. Although in this context an embedded system is usually more complex
than a traditional solution, most of the
complexity is contained within the microcontroller itself. Very few additional components
may be needed and most of the design effort is in the software. The intangible nature of
software makes it much easier to prototype and test
new revisions compared with the design and construction of a new circuit not using an
embedded processor.

Characteristics

1. Embedded systems are designed to do some specific task, rather than be a general-purpose
computer for multiple
tasks. Some also have real-time performance constraints that must be met, for reasons such as
safety and
usability; others may have low or no performance requirements, allowing the system hardware
to be simplified to
reduce costs.

2. Embedded systems are not always standalone devices. Many embedded systems consist of
small, computerized
parts within a larger device that serves a more general purpose. For example, the Gibson
Robot Guitar features an
embedded system for tuning the strings, but the overall purpose of the Robot Guitar is, of
course, to play music.[5]
Similarly, an embedded system in an automobile provides a specific function as a subsystem of
the car itself.

3. The program instructions written for embedded systems are referred to as firmware, and are
stored in read-only
memory or Flash memory chips. They run with limited computer hardware resources: little
memory, small or
non-existent keyboard and/or screen.

Microcontroller

A microcontroller (sometimes abbreviated µC, uC or MCU) is a small computer on


a single integrated circuit containing a processor core, memory, and
programmable input/outputperipherals. Program memory in the form of NOR
flash or OTP ROM is also often included on chip, as well as a typically small amount
of RAM. Microcontrollers are designed for embedded applications, in contrast to
the microprocessors used in personal computers or other general purpose
applications.

Microcontrollers are used in automatically controlled products and devices, such as


automobile engine control systems, implantable medical devices, remote controls,
office machines, appliances, power tools, and toys. By reducing the size and cost
compared to a design that uses a separate microprocessor, memory, and
input/output devices, microcontrollers make it economical to digitally control even
more devices and processes. Mixed signal microcontrollers are common, integrating
analog components needed to control non-digital electronic systems.

Some microcontrollers may use four-bit words and operate at clock rate frequencies
as low as 4 kHz, for low power consumption (milliwatts or microwatts). They will
generally have the ability to retain functionality while waiting for an event such as a
button press or other interrupt; power consumption while sleeping (CPU clock and
most peripherals off) may be just nanowatts, making many of them well suited for
long lasting battery applications. Other microcontrollers may serve performance-
critical roles, where they may need to act more like a digital signal processor (DSP),
with higher clock speeds and power consumption.

MICROCONTROLLER VERSUS MICROPROCESSOR

A microcontroller is a specialized form of microprocessor that is designed to be self-


sufficient and cost-effective, where a microprocessor is typically designed to be
general purpose (the kind used in a PC).

Microcontrollers are frequently found in automobiles, office machines, toys, and


appliances. 

The microcontroller is the integration of a number of useful functions into a single IC


package. These functions are: 

 The ability to execute a stored set of instructions to carry out user defined tasks.
 The ability to be able to access external memory chips to both read and write data
from and to the memory.

Basically, a microcontroller is a device which integrates a number of the components


of a microprocessor system onto a single microchip. 
So a microcontroller combines onto the same microchip : 

 The CPU core (microprocessor)


 Memory (both ROM and RAM)
 Some parallel digital I/O
 Also, a microcontroller is part of an embedded system, which is essentially the
whole circuit board. Look up "embedded system" on Wikipedia.
 The difference is that microcontroller incorporates features of
microprocessor(CPU,ALU,Registers)along with the presence of added features like
presence of RAM,ROM,I\O ports,counter etc.Here microcontroller control the
operation of machine using fixed programme stored in Rom that doesn't change with
lifetime

microprocessor doesnt have internal ram and rom where as microcontroller has them.

microprocessor doesnt have input and output ports where as microcontroller ha them.

microprocessor is used for processing data where as microcontroller is used to control

PIC microcontroller

A long time ago General Instruments produced a chip called the PIC1650, described as a
Programmable Intelligent Computer. This chip is the mother of all PIC chips, functionally
close to the current 16C54. It was intended as a peripheral for their CP1600 microprocessor.
Maybe that is why most people think PIC stands for Peripheral Interface Controller.
Microchip has never used PIC as an abbreviation, just as PIC. And recently Microchip has
started calling its PICs microcontrollers PICmicro MCU's.

PIC is a family of Harvard architecture microcontrollers made by


Microchip Technology, derived from the PIC1640[1] originally
developed by General Instrument's Microelectronics Division. The
name PIC initially referred to "Programmable Interface
Controller".
PICs are popular with both industrial developers and hobbyists alike
due to their low cost, wide availability, large user base, extensive
collection of application notes, availability of low cost or free
development tools, and serial programming (and re-programming with
flash memory) capability.
Microchip announced on February 2008 the shipment of its six
billionth PIC processor.

Core architecture
The PIC architecture is distinctively minimalist. It is characterized by
the following features:
• Separate code and data spaces (Harvard architecture)
• A small number of fixed length instructions
• Most instructions are single cycle execution (4 clock cycles), with single delay cycles upon
branches and skips
• A single accumulator (W), the use of which (as source operand) is implied (i.e. is not
encoded in the opcode)
• All RAM locations function as registers as both source and/or destination of math and other
functions.[5]
• A hardware stack for storing return addresses
• A fairly small amount of addressable data space (typically 256 bytes), extended through
banking
• Data space mapped CPU, port, and peripheral registers
• The program counter is also mapped into the data space and writable (this is used to
implement indirect jumps).
Unlike most other CPUs, there is no distinction between memory space and register space
because the RAM serves
the job of both memory and registers, and the RAM is usually just referred to as the register
file or simply as the
registers.
Pic family

PIC 16x
The PIC 16 family is considered to be a good, general purpose family of PICs. PIC 16s
generally have 3 output ports
to work with. Here are some models in this family that were once common:

• PIC16F877A -- the largest chip of the 16F87x family; has 8 analog inputs
• PIC16F88 -- has 7 analog inputs
• PIC16F628 -- Cheaper than the PIC16F84A, with a built-in 4MHz clock and a UART, but
lacks any analog inputs

PIC 12x

The PIC 12 series are all very small chips, with 8 pins, and 4 available I/O pins. These are
used only when space is a
huge factor, and the PIC doesn't have many responsibilities

PIC 18x

The PIC 18x series are available in a 28 and 40-pin DIP package. They have more ports, more
ADC, etc... PIC 18s
are generally considered to be very high-end microcontrollers, and are even sometimes called
full-fledged CPUs.
Microchip is currently (as of 2007) producing 6 Flash microcontrollers with a USB interface.
All are in the PIC18Fx
family. (The 28 pin PIC18F2450, PIC18F2455, PIC18F2550; and the 40/44 pin PIC18F4450,
PIC18F4455,
PIC18F4550 ).

PIC16F87X

Devices Included in this series :

• PIC16F873
• PIC16F874
• PIC16F876
• PIC16F877

Microcontroller Core Features:

• High performance RISC CPU


• Only 35 single word instructions to learn
• All single cycle instructions except for program
branches which are two cycle
• Operating speed: DC - 20 MHz clock input
DC - 200 ns instruction cycle
• Up to 8K x 14 words of FLASH Program Memory,
Up to 368 x 8 bytes of Data Memory (RAM)
• Pinout compatible to the PIC16C73B/74B/76/77
• Interrupt capability (up to 14 sources)
• Eight level deep hardware stack
• Direct, indirect and relative addressing modes
• Power-on Reset (POR)
• Power-up Timer (PWRT) and
Oscillator Start-up Timer (OST)
• Watchdog Timer (WDT) with its own on-chip RC
oscillator for reliable operation
• Programmable code protection
• Power saving SLEEP mode
• Selectable oscillator options
• Fully static design
• In-Circuit Serial Programming(ICSP) via two
pins
• Single 5V In-Circuit Serial Programming capability
• In-Circuit Debugging via two pins
• Processor read/write access to program memory
• Wide operating voltage range: 2.0V to 5.5V
• High Sink/Source Current: 25 mA
• Commercial, Industrial and Extended temperature
ranges
• Low-power consumption:
- < 0.6 mA typical @ 3V, 4 MHz
- 20 A typical @ 3V, 32 kHz
- < 1 A typical standby current

Peripheral Features:

• Timer0: 8-bit timer/counter with 8-bit prescaler


• Timer1: 16-bit timer/counter with prescaler,
can be incremented during SLEEP via external
crystal/clock
• Timer2: 8-bit timer/counter with 8-bit period
register, prescaler and postscaler
• Two Capture, Compare, PWM modules
- Capture is 16-bit, max. resolution is 12.5 ns
- Compare is 16-bit, max. resolution is 200 ns
- PWM max. resolution is 10-bit
• 10-bit multi-channel Analog-to-Digital converter
• Synchronous Serial Port (SSP) with SPI(Master
mode) and I2C(Master/Slave)
• Universal Synchronous Asynchronous Receiver
Transmitter (USART/SCI) with 9-bit address
detection
• Parallel Slave Port (PSP) 8-bits wide, with
external RD, WR and CS controls (40/44-pin only)
• Brown-out detection circuitry for
Brown-out Reset (BOR)
KEY FEATURES OF 16F877

Operating Frequency DC - 20 MHz

RESETS (and Delays) POR, BOR


(PWRT, OST)
FLASH Program Memory 8K
(14-bit words)

Data Memory (bytes) 368

EEPROM Data Memory 256

Interrupts 14

I/O Ports Ports A,B,C,D,E

Timers

Capture/Compare/PWM Modules 2

Serial Communications MSSP, USART

Parallel Communications PSP

10-bit Analog-to-Digital Module 8 input channels

Instruction Set 35 instructions


PIN DESCRIPTION OF PIC 16F877 :
PIC16F877 PINOUT DESCRIPTION :

PIN NAME DESCRIPTION

OSC1/CLKIN Oscillator crystal input/external clock source


. input.

OSC2/CLKOUT Oscillator crystal output. Connects to crystal or resonator


in crystal oscillator mode. In RC mode, OSC2 pin outputs
CLKOUT which has 1/4 the frequency of OSC1, and
denotes the instruction cycle rate.

MCLR/VPP Master Clear (Reset) input or programming voltage input.


This pin is an active low RESET to the device.

PORT A is a bi-directional I/O port.

RA0/AN0 RA0 can also be analog input0.

RA1/AN1 RA1 can also be analog input1.

RA2/AN2/VREF- RA2 can also be analog input2 or negative


analog reference voltage .

RA3/AN3/VREF+ RA3 can also be analog input3 or positive


analog reference voltage.

RA4/T0CKI RA4 can also be the clock input to the Timer0 timer/
counter. Output is open drain type.

RA5/SS/AN4 RA5 can also be analog input4 or the slave select for
the synchronous serial port.

PORT B is a bi-directional I/O port. PORTB can be software


programmed for internal weak pull-up on all inputs.

RB0/INT RB0 can also be the external interrupt pin.

RB1 as port B

RB2 as port B

RB3/PGM RB3 can also be the low voltage programming input.

RB4 Interrupt-on-change pin.

RB5 Interrupt-on-change pin.

RB6/PGC Interrupt-on-change pin or In-Circuit Debugger pin.


Serial programming clock.

RB7/PGD Interrupt-on-change pin or In-Circuit Debugger pin.


Serial programming data .

PORT C is a bi-directional I/O port.

RC0/T1OSO/T1CKI RC0 can also be the Timer1 oscillator output or a


Timer1 clock input.

RC1/T1OSI/CCP2 RC1 can also be the Timer1 oscillator input or


Capture2 input/Compare2 output/PWM2 output.

RC2/CCP1 RC2 can also be the Capture1 input/Compare1


output/PWM1 output.

RC3/SCK/SCL RC3 can also be the synchronous serial clock output


. for both SPI and I2C modes.

RC4/SDI/SDA RC4 can also be the SPI Data In (SPI mode) or


data I/O (I2C mode).
RC5/SDO RC5 can also be the SPI Data Out (SPI mode).

RC6/TX/CK RC6 can also be the USART Asynchronous Transmit


or Synchronous Clock.

RC7/RX/DT RC7 can also be the USART Asynchronous Receive


or Synchronous Data.

PORT D is a bi-directional I/O port or parallel slave port


when interfacing to a microprocessor bus .

RD0/PSP0 as port D and parallel slave port

RD1/PSP1 as port D and parallel slave port

RD2/PSP2 as port D and parallel slave port

RD3/PSP3 as port D and parallel slave port

RD4/PSP4 as port D and parallel slave port

RD5/PSP5 as port D and parallel slave port

RD6/PSP6 as port D and parallel slave port

RD7/PSP7 as port D and parallel slave port

PORT E is a bi-directional I/O port.

RE0/RD/AN5 RE0 can also be read control for the parallel slave
port, or analog input5.

RE1/WR/AN6 RE1 can also be write control for the parallel slave
port, or analog input6.

RE2/CS/AN7 RE2 can also be select control for the parallel slave
port, or analog input7.

VSS Ground reference for logic and I/O pins.

VDD Positive supply for logic and I/O pins.

NC These pins are not internally connected. These pins


should be left unconnected.

STATUS REGISTER :
The STATUS register contains the arithmetic status of the ALU, the RESET status
and the bank select bits for data memory. The STATUS register can be the
destination for any instruction, as with any other register. If the STATUS register is
the destination for an instruction that affects the Z, DC or C bits, then the write to
these three bits is disabled. These bits are set or cleared according to the
device logic. Furthermore, the TO and PD bits are not writable, therefore, the result
of an instruction with the STATUS register as destination may be different than

IRP RP1 RP0 TO PD Z DC C


IRP: Register Bank Select bit (used for indirect addressing)

RP1:RP0: Register Bank Select bits (used for direct addressing)


11 = Bank 3 (180h - 1FFh)
10 = Bank 2 (100h - 17Fh)
01 = Bank 1 (80h - FFh)
00 = Bank 0 (00h - 7Fh)
Each bank is 128 bytes

TO: Time-out bit


1 = After power-up, CLRWDT instruction, or SLEEP instruction
0 = A WDT time-out occurred

PD: Power-down bit


1 = After power-up or by the CLRWDT instruction
0 = By execution of the SLEEP instruction

Z: Zero bit
1 = The result of an arithmetic or logic operation is zero
0 = The result of an arithmetic or logic operation is not zero

DC: Digit carry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions)


(for borrow, the polarity is reversed)
1 = A carry-out from the 4th low order bit of the result occurred
0 = No carry-out from the 4th low order bit of the result

C: Carry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions)


1 = A carry-out from the Most Significant bit of the result occurred
0 = No carry-out from the Most Significant bit of the result occurred

OPTION-REG REGISTER:

The OPTION_REG Register is a readable and writable register, which contains


various control bits to configure the TMR0 prescaler/WDT postscaler (single
assignable register known also as the prescaler), the External INT Interrupt, TMR0
and the weak pull-ups on PORTB
RBPU INTDEG T0CS T0SE PSA PS2 PS1 PS0

RBPU: PORTB Pull-up Enable bit


1 = PORTB pull-ups are disabled
0 = PORTB pull-ups are enabled by individual port latch values

INTEDG: Interrupt Edge Select bit


1 = Interrupt on rising edge of RB0/INT pin
0 = Interrupt on falling edge of RB0/INT pin

T0CS: TMR0 Clock Source Select bit


1 = Transition on RA4/T0CKI pin
0 = Internal instruction cycle clock (CLKOUT)

T0SE: TMR0 Source Edge Select bit


1 = Increment on high-to-low transition on RA4/T0CKI pin
0 = Increment on low-to-high transition on RA4/T0CKI pin

PSA: Prescaler Assignment bit


1 = Prescaler is assigned to the WDT
0 = Prescaler is assigned to the Timer0 module

PS2:PS0: Prescaler Rate Select bits


PORT A and the TRIS A Register
PORTA is a 6-bit wide, bi-directional port. The correspondingdata direction register is
TRISA. Setting aTRISA bit (= 1) will make the corresponding PORTA pin
an input (i.e., put the corresponding output driver in aHi-Impedance mode). Clearing
a TRISA bit (= 0) willmake the corresponding PORTA pin an output (i.e., put
the contents of the output latch on the selected pin).

PORT A FUNCTIONS
Name Function

RA0/AN0 Input/output or analog input.


RA1/AN1 Input/output or analog input.
RA2/AN2 Input/output or analog input.
RA3/AN3/VREF Input/output or analog input or VREF.
RA4/T0CKI Input/output or external clock input for Timer0. Output is open drain type.
RA5/SS/AN4 Input/output or slave select input for synchronous serial port or analog input.

PORT B and the TRIS B Register

PORTB is an 8-bit wide, bi-directional port. The correspondingdata direction register


is TRISB. Setting aTRISB bit (= 1) will make the corresponding PORTB pin
an input (i.e., put the corresponding output driver in aHi-Impedance mode). Clearing
a TRISB bit (= 0) willmake the corresponding PORTB pin an output (i.e., put
the contents of the output latch on the selected pin).

PORTB FUNCTIONS

RB0/INT Input/output pin or external interrupt input. Internal software


programmable weak pull-up.
RB1 Input/output pin. Internal software programmable weak pull-up.
RB2 Input/output pin. Internal software programmable weak pull-up.
RB3/PGM(3) Input/output pin or programming pin in LVP mode. Internal software
programmable weak pull-up.
RB4 Input/output pin (with interrupt-on-change). Internal software
RB5 Input/output pin (with interrupt-on-change). Internal software
RB6/PGC Input/output pin (with interrupt-on-change) or In-Circuit Debugger pin.
Internal software programmable weak pull-up. Serial programming clock.
RB7/PGD Input/output pin (with interrupt-on-change) or In-Circuit Debugger pin.
Internal software programmable weak pull-up. Serial programming data.
PORT C and the TRIS C Register

PORTC is an 8-bit wide, bi-directional port. The corresponding


data direction register is TRISC. Setting a
TRISC bit (= 1) will make the corresponding PORTC
pin an input (i.e., put the corresponding output driver in
a Hi-Impedance mode). Clearing a TRISC bit (= 0) will
make the corresponding PORTC pin an output (i.e., put
the contents of the output latch on the selected pin).

PORT D and TRIS D Registers

PORTD and TRISD are not implemented on the


PIC16F873 or PIC16F876.
PORTD is an 8-bit port with Schmitt Trigger input buffers.
Each pin is individually configureable as an input or
output.
PORTD can be configured as an 8-bit wide microprocessor
port (parallel slave port) by setting control bit
PSPMODE (TRISE<4>). In this mode, the input buffers

PORT D FUNCTIONS

RD0/PSP0 Input/output port pin or parallel slave port bit0.

RD1/PSP1 Input/output port pin or parallel slave port bit1.

RD2/PSP2 Input/output port pin or parallel slave port bit2.

RD3/PSP3 Input/output port pin or parallel slave port bit3.

RD4/PSP4 Input/output port pin or parallel slave port bit4.

RD5/PSP5 Input/output port pin or parallel slave port bit5.

RD6/PSP6 Input/output port pin or parallel slave port bit6.

RD7/PSP7 Input/output port pin or parallel slave port bit7.


PORT E and TRIS E Register

PORTE and TRISE are not implemented on the


PIC16F873 or PIC16F876.
PORTE has three pins (RE0/RD/AN5, RE1/WR/AN6,
and RE2/CS/AN7) which are individually configureable
as inputs or outputs. These pins have Schmitt Trigger
input buffers.
The PORTE pins become the I/O control inputs for the
microprocessor port when bit PSPMODE (TRISE<4>) is
set. In this mode, the user must make certain that the
TRISE<2:0> bits are set, and that the pins are configured
as digital inputs. Also ensure that ADCON1 is configured
for digital I/O. In this mode, the input buffers are TTL.

Program Memory Organization


The PIC16F87X devices have a 13-bit program counter
capable of addressing an 8K x 14 program memory
space. The PIC16F877/876 devices have 8K x 14
words of FLASH program memory.
Data Memory Organization

The data memory is partitioned into multiple banks


which contain the General Purpose Registers and the
Special Function Registers. Bits RP1 (STATUS<6>)
and RP0 (STATUS<5>) are the bank select bits. Each bank
extends up to 7Fh (128 bytes). The lower locations of each
bank are reserved for the Special
Function Registers. Above the Special Function Registers
are General Purpose Registers, implemented as
static RAM. All implemented banks contain Special
Function Registers. Some frequently used Special
Function Registers from one bank may be mirrored in
another bank for code reduction and quicker access.

RP1 : RP0 BANK

0:0 1

0:1 2

1:0 3

1:1 4

REFRENCES
[1] "PICmicro Family Tree", PIC16F Seminar Presentation http:/ / www. microchip. com. tw/
PDF/ 2004_spring/
PIC16F%20seminar%20presentation. pdf
[2] "MOS DATA 1976", General Instrument 1976 Databook

[3] "1977 Data Catalog", Micro Electronics from General Instrument Corporation http:/ /
www. rhoent. com/ pic16xx. pdf

[4] Microchip Technology (27 February 2008). "Microchip Technology Delivers Six Billionth
PIC Microcontroller" (http:/ / www. microchip.
com/ stellent/ idcplg?IdcService=SS_GET_PAGE& nodeId=2018& mcparam=en534302).
Press release. .

[5] http:/ / ww1. microchip. com/ downloads/ en/ DeviceDoc/ 35007b. pdf

[6] "AN869: External Memory Interfacing Techniques for the PIC18F8XXX" (http:/ / ww1.
microchip. com/ downloads/ en/ AppNotes/ 00869b.
pdf). . Retrieved 24 August 2009.

[7] "PIC Paging and PCLATH" (http:/ / massmind. org/ techref/ microchip/ pages. htm)

[8] http:/ / mdubuc. freeshell. org/ Sdcc/

[9] http:/ / www. microchipc. com/ sourcecode/

[10] (http:/ / www. microchip. com/ stellent/ idcplg?IdcService=SS_GET_PAGE&


nodeId=2018& mcparam=en013529)
SUBMITTED TO : SUBMITTED BY :
Er. Sachin kumar AKASH GAUR/E.C-07 BATCH/04
Er. Amit kumar

Vous aimerez peut-être aussi