so inf

Upload: akash-gaur

Post on 10-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 so inf

    1/35

    S O INFOTECH (P) LTD. ( DUCAT-NOIDA )

    TRAINING REPORT ON

    PIC MICROCONTROLLER

    BY AKASH GAUR

  • 8/8/2019 so inf

    2/35

    y ACKNOWLEDGEMENT.

    y PREFACE.

    y CERTIFICATE.

    y S O INFOTECH (P) LTD.

    AN OVERVIEW.

    COMPANY PARTNER DUCAT (INDIA)

    EMBEDDED SYSTEMS

    OVERVIEW

    y MICROCONTROLLERS

    INTRODUCTION.

    MICROPROCESSORS versus

    MICROCONTROLLERS

    y PIC (SERIES NO. :- 16F877)

    INTRODUCTION

    STATUSREGISTER

    PIN DIAGRAM

    INSTRUCTION SET

    REFRENCES

  • 8/8/2019 so inf

    3/35

    ACKNOWLEDGEMENT

    I take this opportunity to express my sincere gratitude towards my college Training and

    placement officer for forwarding my training letter toS O INFOTECH (DUCAT), Noidaand 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 ofS O INFOTECH AND DUCAT

    family for making me feel comfortable and helping me in every possible manner.

    AKASH GAUR

  • 8/8/2019 so inf

    4/35

    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.

  • 8/8/2019 so inf

    5/35

    SO INFOTECH is a leading India based software development outsourcing company focused ondelivering 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 clientsby leveraging our business-to-IT connect and deeply committed people. Our clients include industryleaders, they have found in us a right-size partner who combines scale, stabili ty and customer-centricityStrong domain connectITS solutions have a strong domain focus that helps our clients in different industries maximize thevalue of their IT spend.

  • 8/8/2019 so inf

    6/35

  • 8/8/2019 so inf

    7/35

  • 8/8/2019 so inf

    8/35

    Backed by a team of professionals

    who havesuccessfully trainedand

    placedstudents. DUCAT offersa wide

    spectrum of technicalcoursesand

    application coursesdesigned to suit

    every skilllevel,as wellas theability

    to consult directly with organizations

    to tailor madelearning plans for any

    number ofemployees. Our products

    andservices havea wideappealand

    areapplicable thosein varied

    positionsincluding network

    administrators,systemsanalysts,

    systemsarchitects, test engineers,

    softwaredevelopers, help deskstaff,IT managers,senior executives,

    administrativeassistantsand business

    professionals.

  • 8/8/2019 so inf

    9/35

    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 embeddedas

    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 ofend-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 theyinvolve 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 orenclosure. 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

  • 8/8/2019 so inf

    10/35

    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-

  • 8/8/2019 so inf

    11/35

    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 194050s, 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

  • 8/8/2019 so inf

    12/35

    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 manyexternal 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 testnew revisions compared with the design and construction of a new circuit not using an

    embedded processor.

  • 8/8/2019 so inf

    13/35

    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, computerizedparts 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.

  • 8/8/2019 so inf

    14/35

  • 8/8/2019 so inf

    15/35

    general rpose t e kind sed ina P .

    i rocontrollersare freq entl found inautomobiles, officemachines, toys, andappliances.

    hemicrocontroller is the integrationofanumberofuseful functions intoasingle I

    package. hese functionsare:

    y heability toexecuteastoredset of instructions tocarry out userdefined tasks.

    y heability tobeable toaccessexternal memorychips tobothreadand ritedatafromand to thememory.

    Basically, amicrocontroller isadevice hich integratesanumberof thecomponentsofamicroprocessorsystemontoasinglemicrochip.

    Soamicrocontrollercombinesonto thesamemicrochip :

    y he PU core microprocessor)

    y emory both R and RA )y Someparallel digital I/

    y Also, amicrocontrollerispart ofanembeddedsystem, hich isessentially theholecircuit board. Look up embeddedsystem"on Wikipedia.

    y hedifference is that microcontrollerincorporates featuresof

    microprocessor(CPU,ALU,Registers)along ith th epresenceofadded features like

    presenceof RA ,R ,I\ ports,counteretc. eremicrocontrollercontrol the

    operationofmachineusing fixedprogrammestored in Rom that doesn't change ith

    lifetime

    microprocessordoesnt have internal ramandrom

    hereasmicrocontrollerhas them.

    microprocessordoesnt have input andoutput ports

    hereasmicrocontrollerha them.

    microprocessorisused forprocessingdata

    hereasmicrocontroller isused tocontrol

    PIC microcontroller

  • 8/8/2019 so inf

    16/35

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

  • 8/8/2019 so inf

    17/35

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

  • 8/8/2019 so inf

    18/35

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

    ighperformance RISCCPU nly 35 single ord instructions to learn

  • 8/8/2019 so inf

    19/35

    All singlecycle instructionsexcept for programbranches hichare t ocycle peratingspeed: DC clock inputDC ns instructioncycle Up to8Kx14 ordsofFLAS Program emory,Up to 368x8bytesof Data emory(RA )

    Pinout compatible to the PIC16C73B/74B/76/77 Interrupt capability(up to14 sources) Eight level deephardwarestack Direct, indirect andrelativeaddressingmodes Power-on Reset (P R) Power-up imer(PWR )and

    scillatorStart-up imer(OS ) Watchdog imer(WD )with itsownon-chip RCoscillator forreliableoperation Programmablecodeprotection Powersaving SLEEP mode Selectableoscillatoroptions

    Fullystaticdesign In-Circuit Serial Programming(ICSP)via twopins Single 5V In-Circuit Serial Programmingcapability In-Circuit Debuggingvia twopins Processorread/writeaccess toprogrammemory Wideoperatingvoltagerange: . V to 5.5V igh Sink/SourceCurrent: 5 mACommercial, Industrial and Extended temperature ranges Low-powerconsumption:- < .6mA typical @ 3V, 4

    - A typical @ 3V, 3 k- < 1A typical standbycurrent

    Peripheral Features:

    imer0: 8-bit timer/counterwith8-bit prescaler imer1: 16-bit timer/counterwithprescaler,canbe incrementedduring SLEEP viaexternalcrystal/clock imer2: 8-bit timer/counterwith8-bit periodregister, prescalerandpostscaler woCapture, Compare, PW modules -Capture is16-bit, max. resolution is12.5 ns

  • 8/8/2019 so inf

    20/35

    -Compare is16-bit, max. resolution is200ns- PW max. resolution is10-bit10-bit multi-channel Analog-to-Digital converter

    Synchronous Serial Port (SSP)with SPI(Master

    mode)and I2C(Master/Slave) Universal Synchronous Asynchronous Receiver

    ransmitter(USAR /SCI)with 9-bit addressdetection Parallel Slave Port (PSP)8 -bitswide, withexternal RD, WR andCS controls(40/44-pinonly) Brown-out detectioncircuitry forBrown-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

  • 8/8/2019 so inf

    21/35

    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 :

  • 8/8/2019 so inf

    22/35

    PIC16F877 PINOUT DESCRIPTION :

  • 8/8/2019 so inf

    23/35

    PIN NAME DESCRIPTION

    OSC1/CLKI

    Oscillatorcrystal input/external clock source

    . input.

    OSC2/CLKOU

    Oscillatorcrystal output. Connects tocrystal orresonatorincrystal oscillatormode. In RCmode, OSC2pinoutputsCLKOU

    whichhas1/4 the frequencyofOSC1, anddenotes the instructioncyclerate.

    MCLR/VPP MasterClear(Reset) input orprogrammingvoltage input.

    hispin isanactive low RESE

    to thedevice.

    POR

    A isabi-directional I/Oport.

    RA0/A

    0 RA0canalsobeanalog input0.

    RA1/A

    1 RA1canalsobeanalog input1.

    RA2/A

    2/VREF- RA2canalsobeanalog input2ornegativeanalogreferencevoltage.

    RA3/A

    3/VREF+ RA3 canalsobeanalog input3 orpositiveanalogreferencevoltage.

    RA4/

    0CKI RA4 canalsobe theclock input to the

    imer0 timer/counter. Output isopendrain type.

    RA5/SS/A

    4 RA5 canalsobeanalog input4 ortheslaveselect forthesynchronousserial port.

    POR

    B isabi-directional I/Oport. POR

    B canbesoftwareprogrammed forinternal weak pull-uponall inputs.

    RB0/I

    RB0canalsobe theexternal interrupt pin.

    RB1 asport B

    RB2 asport B

  • 8/8/2019 so inf

    24/35

    RB3/P M RB3 canalsobe the lowvoltageprogramming input.

    RB4 Interrupt-on-changepin.

    RB5 Interrupt-on-changepin.

    RB6/P C Interrupt-on-changepinorIn-Circuit Debuggerpin.Serial programmingclock.

    RB7/P D Interrupt-on-changepinorIn-Circuit Debuggerpin.Serial programmingdata.

    POR

    C isabi-directional I/Oport.

    RC0/

    1OSO/

    1CKI RC0canalsobe the

    imer1oscillatoroutput ora

    imer1clock input.

    RC1/

    1OSI/CCP2 RC1canalsobe the

    imer1oscillatorinput orCapture2 input/Compare2output/PWM2output.

    RC2/CCP1 RC2canalsobe theCapture1 input/Compare1output/PWM1output.

    RC3/SCK/SCL RC3 canalsobe thesynchronousserial clock output. forboth SPI and I2Cmodes.

    RC4/SDI/SDA RC4 canalsobe the SPI Data In(SPI mode)or data I/O(I2Cmode).

    RC5/SDO RC5 canalsobe the SPI DataOut (SPI mode).

    RC6/

    X/CK RC6canalsobe the USAR

    Asynchronous

    r ansmitorSynchronousClock.

    RC7/RX/D

    RC7canalsobe the USAR

    Asynchronous Rec eiveorSynchronous Data.

    POR D isabi-directional I/Oport orparallel slaveportwhen interfacing toamicroprocessorbus.

    RD0/PSP0 asport D andparallel slave port

  • 8/8/2019 so inf

    25/35

    RD1/PSP1 asport D andparallel slave port

    RD2/PSP2 asport D andparallel slave port

    RD3/PSP3 asport D andparallel slave port

    RD4/PSP4 asport D andparallel slave port

    RD5/PSP5 asport D andparallel slave port

    RD6/PSP6 asport D andparallel slave port

    RD7/PSP7 asport D andparallel slave port

    POR

    E isabi-directional I/Oport.

    RE0/RD/A 5 RE0canalsobereadcontrol forthepa rallel slaveport, oranalog input5.

    RE1/WR/A 6 RE1canalsobewritecontrol fortheparallel slaveport, oranalog input6.

    RE2/CS/A 7 RE2canalsobeselect control fortheparallel slaveport, oranalog input7.

    VSS roundreference forlogicand I/Opins.

    VDD Positivesupply forlogicand I /Opins.

    C

    hesepinsarenot internallyconnected.

    hese pinsshouldbe left unconnected.

  • 8/8/2019 so inf

    26/35

    STATUS REGISTER :

    The STATUS registercontains thearithmeticstatusof the ALU, the RESETstatusand thebank select bits fordatamemory. The STATUS registercanbe thedestination forany instruction, aswithanyotherregister. If the STATUS register isthedestination foran instruction that affects the Z, DCorCbits, then thewrite tothese threebits isdisabled. Thesebitsareset orclearedaccording to the device logic. Furthermore, theTOand PD bitsarenot writable, therefore, theresultofan instructionwith the STATUS registerasdestinationmaybedifferent than

    IRP: RegisterBank Select bit (used forindirect addressing)

    RP1:RP0: RegisterBank Select bits(used fordirect addressing)

    11 = Bank 3 (180h-1FFh)10 = Bank 2(100h-17Fh)01 = Bank 1(80h-FFh)00 = Bank 0(00h-7Fh)Eachbank is128bytes

    TO: Time-out bit

    IRP RP1 RP0 TO PD Z DC C

  • 8/8/2019 so inf

    27/35

    1 = Afterpower-up, CLRWDT instruction, or SLEEP instruction0 = A WDT time-out occurred

    PD: Power-downbit

    1 = Afterpower-uporby theCLRWDT instruction0 = Byexecutionof the SLEEP instruction

    Z: Zerobit1 = Theresult ofanarithmeticorlogicoperation is ero 0 = Theresult ofanarithmeticorlogicoperation isnot ero

    DC: Digit carry/borrowbit (ADDWF, ADDLW,SUBLW,SUBWF instructions)(forborrow, thepolarity is reversed)1 = A carry-out from the 4th loworderbit of theresult occurred 0 = ocarry-out from the 4th loworderbit of theresult

    C: Carry/borrowbit (ADDWF, ADDLW,SUBLW,SUBWF instructions)1 = A carry-out from theMost Significant bit of theresult occurred0 = ocarry-out from theMost Significant bit of theresult occurred

    OPTION-REG REGISTER:

    TheOPTION_RE Registerisareadableandwritable register, whichcontainsvariouscontrol bits toconfigure theTMR0prescaler/WDTpostscaler(singleassignableregisterknownalsoas theprescaler), the External INT Interrupt, TMR0and theweak pull-upson PORTB

    RBPU INTDEG T0CS T0SE PSA PS2 PS1 PS0

  • 8/8/2019 so inf

    28/35

    RBPU: PORTB Pull-up Enablebit

    1 = PORTB pull-upsaredisabled0 = PORTB pull-upsareenabledby individual port latchvalues

    INTEDG: Interrupt Edge Select bit1 = Interrupt onrisingedgeof RB0/INTpin 0 = Interrupt on fallingedgeof RB0/INTpin

    T0CS: TMR0Clock Source Select bit

    1 = Transitionon RA4/T0CKI pin 0 = Internal instructioncycleclock (CLKOUT)

    T0SE: TMR0 Source Edge Select bit1 = Increment onhigh-to-low transitionon RA4/T0CKI pin 0 = Increment on low-to-high transitionon RA4/T0CKI pin

    PSA: PrescalerAssignment bit1 = Prescalerisassigned to the WDT 0 = Prescalerisassigned to theTimer0module

    PS2:PS0: PrescalerRate Select bits

    PORT A and the TRIS A Register

    PORTA isa6-bit wide, bi-directional port. ThecorrespondingdatadirectionregisterisTRISA. SettingaTRISA bit (= 1)will make thecorresponding PORTA pinan input (i.e., put thecorrespondingoutput driverinaHi -Impedancemode). ClearingaTRISA bit (= 0)willmake thecorresponding PORTA pinanoutput (i.e., putthecontentsof theoutput latchon theselectedpin).

  • 8/8/2019 so inf

    29/35

    PORT A FUNCTIONSName Function

    RA0/AN0 Input/output oranalog input.RA1/AN1 Input/output oranalog input.RA2/AN2 Input/output oranalog input.RA3/AN3/VREF Input/output oranalog input orVREF.RA4/T0CKI Input/output orexternal clock input forTimer0. Output isopendrain type.

    RA5/SS/AN4 Input/output orslaveselect input forsynchronousserial port oranalog input.

    PORT B and the TRIS B Register

    PORTB isan8-bit wide, bi-directional port. ThecorrespondingdatadirectionregisterisTRISB. SettingaTRISB bit (= 1)will make thecorresponding PORTB pin an input (i.e., put thecorrespondingoutput driverinaHi -Impedancemode). ClearingaTRISB bit (= 0)willmake thecorresponding PORTB pinanoutput (i.e., putthecontentsof theoutput latchon theselectedpin).

    PORTB FUNCTIONS

    RB0/INT Input/output pinorexternal interrupt input. Internal softwareprogrammableweak pull-up.

    RB1 Input/output pin. Internal softwareprogrammableweak pull-up.RB2 Input/output pin. Internal softwareprogrammableweak pull-up.RB3/P M(3) Input/output pinorprogrammingpin in LVP mode. Internal software

    programmableweak pull-up.RB4 Input/output pin(with interrupt -on-change). Internal softwareRB5 Input/output pin(with interrupt -on-change). Internal softwareRB6/P C Input/output pin(with interrupt -on-change)orIn-Circuit Debuggerpin.

    Internal softwareprogrammableweak pull-up. Serial programmingclock.RB7/P D Input/output pin(with interrupt -on-change)orIn-Circuit Debuggerpin.

    Internal softwareprogrammableweak pull-up. Serial programmingdata.

    PORT C and the TRIS C Register

    PORTC isan8-bit wide, bi-directional port. Thecorresponding datadirectionregister isTRISC. Settinga TRISCbit (= 1)will make thecorresponding PORTC pinan input (i.e., put thecorrespondingoutput driverin aHi-Impedancemode). ClearingaTRISCbit (= 0)willmake thecorresponding PORTCpinanoutput (i.e., putthecontentsof theoutput latchon theselectedpin).

  • 8/8/2019 so inf

    30/35

    PORT D and TRIS D Registers

    PORTD andTRISD arenot implementedon the PIC16F873 orPIC16F876.PORTD isan8-bit port with Schmitt Trigger input buffers.Eachpin is individuallyconfigureableasan input oroutput.PORTD canbeconfiguredasan8 -bit widemicroprocessorport (parallel slaveport)bysettingcontrol bitPSPMODE (TRISE). In thismode, the input buffers

    PORT D FUNCTIONS

    RD0/PSP0 Input/output port p inorparallel slaveport bit0.

    RD1/PSP1 Input/output port pinorparallel slaveport bit1 .

    RD2/PSP2 Input/output port pinorparallel slaveport bit2.

    RD3/PSP3 Input/output port pinorparallel slaveport bit3 .

    RD4/PSP4 Input/output port pi norparallel slaveport bit4.

    RD5/PSP5 Input/output port pinorparallel slaveport bit5 .

    RD6/PSP6 Input/output port pin orparallel slaveport bit6.

    RD7/PSP7 Input/output port pinorparallel slaveport bit7 .

    PORT E and TRIS E Register

    PORTE andTRISE arenot implementedon the PIC16F873 orPIC16F876.PORTE has threepins(RE0/RD/AN5, RE1/WR/AN6,and RE2/CS/AN7)whichare individuallyconfigureable as inputsoroutputs. Thesepinshave Schmitt Triggerinput buffers.The PORTE pinsbecome the I/Ocontrol inputs forthe microprocessorport whenbit PSPMODE (TRISE) is

  • 8/8/2019 so inf

    31/35

    set. In thismode, theusermust makecertain that the TRISE bitsareset, and that thepinsareconfigured asdigital inputs. Alsoensure that ADCON1 isconfigured fordigital I/O. In thismode, the input buffersareTTL.

    Program MemoryOrganization

    The PIC16F87X deviceshavea13-bit programcountercapableofaddressingan8Kx14 programmemoryspace. The PIC16F877/876deviceshave8Kx14wordsofFLASHprogrammemory.

  • 8/8/2019 so inf

    32/35

    Data MemoryOrganization

    Thedatamemory ispartitioned intomultiplebanks whichcontain the eneral Purpose Registersand the Special Function Registers. Bits RP1(STATUS) and RP0(STATUS)are thebank select bits. Eachbankextendsup to7Fh(128bytes). The lower locationsofeachbank arereserved forthe Special

  • 8/8/2019 so inf

    33/35

    Function Registers. Above the Special Function Registers are eneral Purpose Registers, implementedas static RAM. All implementedbankscontain SpecialFunction Registers. Some frequentlyused SpecialFunction Registers fromonebank maybemirrored in anotherbank forcodereductionand quickeraccess.

    REFRENCES

    [1] "PICmicro Family Tree", PIC16F Seminar Presentation http:/ / www. microchip. com. tw/

    PDF/ 2004_spring/

    PIC16F%20seminar%20presentation. pdf

    RP1 : RP0 BANK

    0 : 0 1

    0 : 1 2

    1 : 0 3

    1 : 1 4

  • 8/8/2019 so inf

    34/35

    [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 SixBillionth 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)

  • 8/8/2019 so inf

    35/35

    S B D TO : S B TTEDB :

    Er Sachi ku ar AKASH GAUR/E 7 BATCH/

    Er Amitkumar