Transcription of PIC16F87X - Microchip Technology
1 1998-2013 Microchip Technology 1 PIC16F87 XDevices Included in this Data Sheet: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 inputDC - 200 ns instruction cycle 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 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) andOscillator 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 Low power, high speed CMOS FLASH/EEPROM Technology 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: to High Sink/Source Current.
2 25 mA Commercial, Industrial and Extended temperature ranges Low-power consumption: - < mA typical @ 3V, 4 MHz-20 A typical @ 3V, 32 kHz-< 1 A typical standby currentPin Diagram 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 periodregister, prescaler and postscaler Two Capture, Compare, PWM modules- Capture is 16-bit, max. resolution is 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, withexternal RD, WR and CS controls (40/44-pin only) Brown-out detection circuitry forBrown-out Reset (BOR)
3 PIC16F873 PIC16F874 PIC16F876 PIC16F877RB7/PGDRB6/PGCRB5RB4RB3/PGMRB2R B1RB0/INTVDDVSSRD7/PSP7RD6/PSP6RD5/PSP5R D4/PSP4RC7/RX/DTRC6/TX/CKRC5/SDORC4/SDI/ SDARD3/PSP3RD2/PSP2 MCLR/VPPRA0/AN0RA1/AN1RA2/AN2/VREF-RA3/A N3/VREF+RA4/T0 CKIRA5/AN4/SSRE0/RD/AN5RE1/WR/AN6RE2/CS/ AN7 VDDVSSOSC1/CLKINOSC2/CLKOUTRC0/T1 OSO/T1 CKIRC1/T1 OSI/CCP2RC2/CCP1RC3/SCK/SCLRD0/PSP0RD1/P SP11234567891011121314151617181920403938 3736353433323130292827262524232221 PIC16F877/874 PDIP28/40-Pin 8-Bit CMOS FLASH MicrocontrollersPIC16F87 XDS30292D-page 2 1998-2013 Microchip Technology DiagramsPIC16F876/8731011234561879121314 1516171819202324252627282221 MCLR/VPPRA0/AN0RA1/AN1RA2/AN2/VREF-RA3/A N3/VREF+RA4/T0 CKIRA5/AN4/SSVSSOSC1/CLKINOSC2/CLKOUTRC0 /T1 OSO/T1 CKIRC1/T1 OSI/CCP2RC2/CCP1RC3/SCK/SCLRB7/PGDRB6/PG CRB5RB4RB3/PGMRB2RB1RB0/INTVDDVSSRC7/RX/ DTRC6/TX/CKRC5/SDORC4/SDI/SDA10111213141 5161718192021222324252644876543212728293 0313233343536373839404142439 PIC16F877RA4/T0 CKIRA5/AN4/SSRE0/RD/AN5 OSC1/CLKINOSC2/CLKOUTRC0/T1 OSO/T1CK1 NCRE1/WR/AN6RE2/CS/AN7 VDDVSSRB3/PGMRB2RB1RB0/INTVDDVSSRD7/PSP7 RD6/PSP6RD5/PSP5RD4/PSP4RC7/RX/DTRA3/AN3 /VREF+RA2/AN2/VREF-RA1/AN1RA0/AN0 MCLR/VPPNCRB7/PGDRB6/PGCRB5RB4 NCNCRC6/TX/CKRC5/SDORC4/SDI/SDARD3/PSP3R D2/PSP2RD1/PSP1RD0/PSP0RC3/SCK/SCLRC2/CC P1RC1/T1 OSI/CCP210112345611819202122121314153887 4443424140391617293031323323242526272836 34359 PIC16F87737RA3/AN3/VREF+RA2/AN2/VREF-RA1 /AN1RA0/AN0 MCLR/VPPNCRB7/PGDRB6/PGCRB5RB4 NCRC6/TX/CKRC5/SDORC4/SDI/SDARD3/PSP3RD2 /PSP2RD1/PSP1RD0/PSP0RC3/SCK/SCLRC2/CCP1 RC1/T1 OSI/CCP2 NCNCRC0/T1 OSO/T1 CKIOSC2/CLKOUTOSC1/CLKINVSSVDDRE2/AN7/CS RE1/AN6/WRRE0/AN5/RDRA5/AN4/SSRA4/T0 CKIRC7/RX/DTRD4/PSP4RD5/PSP5RD6/PSP6RD7/ PSP7 VSSVDDRB0/INTRB1RB2RB3/PGMPLCCQFPPDIP, SOICPIC16F874 PIC16F874 1998-2013 Microchip Technology 3 PIC16F87 XKey FeaturesPIC MCU Mid-Range Reference Manual (DS33023)
4 PIC16F873 PIC16F874 PIC16F876 PIC16F877 Operating FrequencyDC - 20 MHzDC - 20 MHzDC - 20 MHzDC - 20 MHzRESETS (and Delays)POR, BOR (PWRT, OST)POR, BOR (PWRT, OST)POR, BOR (PWRT, OST)POR, BOR (PWRT, OST)FLASH Program Memory (14-bit words)4K4K8K8 KData Memory (bytes)192192368368 EEPROM Data Memory128128256256 Interrupts13141314I/O PortsPorts A,B,CPorts A,B,C,D,EPorts A,B,CPorts A,B,C,D,ETimers3333 Capture/Compare/PWM Modules2222 Serial CommunicationsMSSP, USARTMSSP, USARTMSSP, USARTMSSP, USARTP arallel Communications PSP PSP10-bit Analog-to-Digital Module5 input channels 8 input channels 5 input channels 8 input channelsInstruction Set35 instructions35 instructions35 instructions35 instructionsPIC16F87 XDS30292D-page 4 1998-2013 Microchip Technology of Overview .. Ports .. EEPROM and FLASH Program Module .. Module .. Module .. Modules .. Synchronous Serial Port (MSSP) Module .. Addressable Universal Synchronous Asynchronous Receiver Transmitter (USART).
5 Analog-to-Digital Converter (A/D) Special Features of the Instruction Set Development Support .. Electrical DC and AC Characteristics Graphs and Packaging Information .. 189 Appendix A: Revision History .. 197 Appendix B: Device Differences .. 197 Appendix C: Conversion Considerations .. 198 Index .. 199On-Line Support .. 207 Reader Response .. 208 PIC16F87X Product Identification System .. 209TO OUR VALUED CUSTOMERSIt is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchipproducts. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined andenhanced as new volumes and updates are introduced. If you have any questions or comments regarding this publication, please contact the Marketing Communications Department viaE-mail at or fax the Reader Response Form in the back of this data sheet to (480) welcome your Current Data SheetTo obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at: can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any last character of the literature number is the version number, ( , DS30000A is version A of document DS30000).
6 ErrataAn errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for currentdevices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revisionof silicon and revision of document to which it determine if an errata sheet exists for a particular device, please check with one of the following: Microchip s Worldwide Web site; Your local Microchip sales office (see last page) The Microchip Corporate Literature Center; FAX: (480) 792-7277 When contacting a sales office or the literature center, please specify which device, revision of silicon and data sheet (include liter-ature number) you are Notification SystemRegister on our web site at to receive the most current information on all of our products. 1998-2013 Microchip Technology OVERVIEWThis document contains device specific information may be found in the PIC MCUMid-Range Reference Manual (DS33023), which maybe obtained from your local Microchip Sales Represen-tative or downloaded from the Microchip website.
7 TheReference Manual should be considered a complemen-tary document to this data sheet, and is highly recom-mended reading for a better understanding of the devicearchitecture and operation of the peripheral are four devices (PIC16F873, PIC16F874,PIC16F876 and PIC16F877) covered by this datasheet. The PIC16F876/873 devices come in 28-pinpackages and the PIC16F877/874 devices come in40-pin packages. The Parallel Slave Port is notimplemented on the 28-pin following device block diagrams are sorted by pinnumber; 28-pin for Figure 1-1 and 40-pin for Figure 28-pin and 40-pin pinouts are listed in Table 1-1and Table 1-2, 1-1:PIC16F873 AND PIC16F876 BLOCK DIAGRAMFLASHP rogramMemory13 Data Bus814 ProgramBusInstruction regProgram Counter8 Level Stack(13-bit)RAMFileRegistersDirect Addr7 RAM Addr(1)9 Addr MUXI ndirectAddrFSR regSTATUS regMUXALUW regPower-upTimerOscillatorStart-up TimerPower-onResetWatchdogTimerInstructi onDecode &ControlTimingGenerationOSC1/CLKINOSC2/C LKOUTMCLRVDD, VSSPORTAPORTBPORTCRA4/T0 CKIRA5/AN4/SSRB0/INTRC0/T1 OSO/T1 CKIRC1/T1 OSI/CCP2RC2/CCP1RC3/SCK/SCLRC4/SDI/SDARC 5/SDORC6/TX/CKRC7/RX/DT88 Brown-outResetNote 1.
8 Higher order bits are from the STATUS ,2 Synchronous10-bit A/DTimer0 Timer1 Timer2 Serial PortRA3/AN3/VREF+RA2/AN2/VREF-RA1/AN1RA0 /AN083 Data EEPROMRB1RB2RB3/PGMRB4RB5RB6/PGCRB7/PGDD eviceProgram FLASHData MemoryData EEPROMPIC16F8734K192 Bytes128 BytesPIC16F8768K368 Bytes256 BytesIn-CircuitDebuggerLow VoltageProgrammingPIC16F87 XDS30292D-page 6 1998-2013 Microchip Technology 1-2:PIC16F874 AND PIC16F877 BLOCK DIAGRAMFLASHP rogramMemory13 Data Bus814 ProgramBusInstruction regProgram Counter8 Level Stack(13-bit)RAMFileRegistersDirect Addr7 RAM Addr(1)9 Addr MUXI ndirectAddrFSR regSTATUS regMUXALUW regPower-upTimerOscillatorStart-up TimerPower-onResetWatchdogTimerInstructi onDecode &ControlTimingGenerationOSC1/CLKINOSC2/C LKOUTMCLRVDD, VSSPORTAPORTBPORTCPORTDPORTERA4/T0 CKIRA5/AN4/SSRC0/T1 OSO/T1 CKIRC1/T1 OSI/CCP2RC2/CCP1RC3/SCK/SCLRC4/SDI/SDARC 5/SDORC6/TX/CKRC7/RX/DTRE0/AN5/RDRE1/AN6 /WRRE2/AN7/CS88 Brown-outResetNote 1:Higher order bits are from the STATUS ,2 Synchronous10-bit A/DTimer0 Timer1 Timer2 Serial PortRA3/AN3/VREF+RA2/AN2/VREF-RA1/AN1RA0 /AN0 Parallel Slave Port83 Data EEPROMRB0/INTRB1RB2RB3/PGMRB4RB5RB6/PGCR B7/PGDD eviceProgram FLASHData MemoryData EEPROMPIC16F8744K192 Bytes128 BytesPIC16F8778K368 Bytes256 BytesIn-CircuitDebuggerLow-VoltageProgra mmingRD0/PSP0RD1/PSP1RD2/PSP2RD3/PSP3RD4 /PSP4RD5/PSP5RD6/PSP6RD7/PSP7 1998-2013 Microchip Technology 7 PIC16F87X TABLE 1-1:PIC16F873 AND PIC16F876 PINOUT DESCRIPTIONPin NameDIPPin#SOICPin#I/O/PTypeBufferTypeDe scriptionOSC1/CLKIN99 IST/CMOS(3)Oscillator crystal input/external clock source Oscillator crystal output.
9 Connects to crystal or resonator in crystal oscillator mode. In RC mode, the OSC2 pin outputs CLKOUT which has 1/4 the frequency of OSC1, and denotes the instruction cycle Clear (Reset) input or programming voltage input. This pin is an active low RESET to the device. PORTA is a bi-directional I/O can also be analog can also be analog can also be analog input2 or negative analog reference +55I/OTTLRA3 can also be analog input3 or positive analogreference can also be the clock input to the Timer0 module. Output is open drain can also be analog input4 or the slave selectfor the synchronous serial is a bi-directional I/O port. PORTB can be software programmed for internal weak pull-up on all inputs. RB0/INT2121I/OTTL/ST(1)RB0 can also be the external interrupt can also be the low voltage programming (2)Interrupt-on-change pin or In-Circuit Debugger pin. Serial programming (2)Interrupt-on-change pin or In-Circuit Debugger pin.
10 Serial programming is a bi-directional I/O can also be the Timer1 oscillator output or Timer1 clock can also be the Timer1 oscillator input or Capture2 input/Compare2 output/PWM2 can also be the Capture1 input/Compare1 output/PWM1 can also be the synchronous serial clock input/output for both SPI and I2C can also be the SPI Data In (SPI mode) or data I/O (I2C mode).RC5/SDO1616I/OSTRC5 can also be the SPI Data Out (SPI mode).RC6/TX/CK1717I/OSTRC6 can also be the USART Asynchronous Transmit or Synchronous can also be the USART Asynchronous Receive or Synchronous , 198, 19P Ground reference for logic and I/O Positive supply for logic and I/O : I = inputO = outputI/O = input/outputP = power = Not usedTTL = TTL inputST = Schmitt Trigger inputNote 1:This buffer is a Schmitt Trigger input when configured as the external :This buffer is a Schmitt Trigger input when used in Serial Programming :This buffer is a Schmitt Trigger input when configured in RC oscillator mode and a CMOS input 8 1998-2013 Microchip Technology 1-2:PIC16F874 AND PIC16F877 PINOUT DESCRIPTIONPin NameDIPPin#PLCCPin#QFPPin#I/O/PTy p eBufferTy peDescriptionOSC1/CLKIN131430 IST/CMOS(4)Oscillator crystal input/external clock source Oscillator crystal output.