pic16f870

1
Escola de Educação Profissional SENAI Nilo Peçanha Curso Técnico em Eletrônica PIC16F870 Prof. Diego Volpini Fonte: Microchip PIC16F870 10 11 2 3 4 5 6 1 8 7 9 12 13 14 15 16 17 18 19 20 23 24 25 26 27 28 22 21 MCLR /VPP/THV RA0/AN0 RA1/AN1 RA2/AN2/VREF- RA3/AN3/VREF+ RA4/T0CKI RA5/AN4 VSS OSC1/CLKI OSC2/CLKO RC0/T1OSO/T1CKI RC1/T1OSI RC2/CCP1 RC3 RB7/PGD RB6/PGC RB5 RB4 RB3/PGM RB2 RB1 RB0/INT VDD VSS RC7/RX/DT RC6/TX/CK RC5 RC4 FLASH Program Memory 13 Data Bus 8 14 Program Bus Instruction reg Program Counter 8 Level Stack (13-bit) RAM File Registers Direct Addr 7 RAM Addr (1) 9 Addr MUX Indirect Addr FSR reg STATUS reg MUX ALU W reg Power-up Timer Oscillator Start-up Timer Power-on Reset Watchdog Timer Instruction Decode & Control Timing Generation OSC1/CLKI OSC2/CLKO MCLR VDD, VSS PORTA PORTB PORTC RA4/T0CKI RA5/AN4 RB0/INT RC0/T1OSO/T1CKI RC1/T1OSI RC2/CCP1 RC3 RC4 RC5 RC6/TX/CK RC7/RX/DT 8 8 Brown-out Reset USART CCP1 10-bit A/D Timer0 Timer1 Timer2 RA3/AN3/VREF+ RA2/AN2/VREF- RA1/AN1 RA0/AN0 8 3 Data EEPROM RB1 RB2 RB3/PGM RB4 RB5 RB6/PGC RB7/PGD Device Program FLASH Data Memory Data EEPROM PIC16F870 2K 128 Bytes 64 Bytes In-Circuit Debugger Low-Voltage Programming Pin Name DIP Pin# SOIC Pin# I/O/P Type Buffer Type Description OSC1/CLKI 9 9 I ST/CMOS (3) Oscillator crystal input/external clock source input. OSC2/CLKO 10 10 O Oscillator crystal output. Connects to crystal or resonator in Crystal Oscillator mode. In RC mode, the OSC2 pin outputs CLKO, which has 1/4 the frequency of OSC1, and denotes the instruction cycle rate. MCLR /VPP/THV 1 1 I/P ST Master Clear (Reset) input or programming voltage input or High Voltage Test mode control. This pin is an active low RESET to the device. PORTA is a bi-directional I/O port. RA0/AN0 2 2 I/O TTL RA0 can also be analog input 0. RA1/AN1 3 3 I/O TTL RA1 can also be analog input 1. RA2/AN2/VREF- 4 4 I/O TTL RA2 can also be analog input 2 or negative analog reference voltage. RA3/AN3/VREF+ 5 5 I/O TTL RA3 can also be analog input 3 or positive analog reference voltage. RA4/T0CKI 6 6 I/O ST/OD RA4 can also be the clock input to the Timer0 module. Output is open drain type. RA5/AN4 7 7 I/O TTL RA5 can also be analog input 4. PORTB is a bi-directional I/O port. PORTB can be software programmed for internal weak pull-up on all inputs. RB0/INT 21 21 I/O TTL/ST (1) RB0 can also be the external interrupt pin. RB1 22 22 I/O TTL RB2 23 23 I/O TTL RB3/PGM 24 24 I/O TTL/ST (1) RB3 can also be the low voltage programming input. RB4 25 25 I/O TTL Interrupt-on-change pin. RB5 26 26 I/O TTL Interrupt-on-change pin. RB6/PGC 27 27 I/O TTL/ST (2) Interrupt-on-change pin or In-Circuit Debugger pin. Serial programming clock. RB7/PGD 28 28 I/O TTL/ST (2) Interrupt-on-change pin or In-Circuit Debugger pin. Serial programming data. PORTC is a bi-directional I/O port. RC0/T1OSO/T1CKI 11 11 I/O ST RC0 can also be the Timer1 oscillator output or Timer1 clock input. RC1/T1OSI 12 12 I/O ST RC1 can also be the Timer1 oscillator input. RC2/CCP1 13 13 I/O ST RC2 can also be the Capture1 input/Compare1 output/ PWM1 output. RC3 14 14 I/O ST RC4 15 15 I/O ST RC5 16 16 I/O ST RC6/TX/CK 17 17 I/O ST RC6 can also be the USART Asynchronous Transmit or Synchronous Clock. RC7/RX/DT 18 18 I/O ST RC7 can also be the USART Asynchronous Receive or Synchronous Data. VSS 8, 19 8, 19 P Ground reference for logic and I/O pins. VDD 20 20 P Positive supply for logic and I/O pins. Legend: I = input O = output I/O = input/output P = power OD = Open Drain — = Not used TTL = TTL input ST = Schmitt Trigger input Note 1: This buffer is a Schmitt Trigger input when configured as the external interrupt or LVP mode. 2: This buffer is a Schmitt Trigger input when used in Serial Programming mode. 3: This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise. Características Gerais RISC CPU (35 instruções) Clock: De 0 à 20 Mhz (à 200 ns por instrução) FLASH Program Memory: 2K EEPROM Data Memory: 64 bytes Data Memory (RAM): 128 bytes Pinagem compatível com a família PIC16 Interrupções (11 fontes) Power-on Reset (POR) Power-up Timer (PWRT) Watchdog Timer (WDT) Brown-out Reset (BOR) Code Protection Data Protection SLEEP Mode Oscilador selecionável In-Circuit-Serial Programming (ICSP) via dois pinos Tensão de operação: 2 à 5,5 Volts Corrente de saída: 25 mA Baixo consumo de potência: < 1,6mA @ 5V, 4 MHz 20uA @ 3V, 32KHz < 1uA em SLEEP Mode Três Timers (TIMER0, TIMER1 e TIMER2) Compare, Capture e PWM módulo (CCP) Conversor A/D de múltiplos canais Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI)

Upload: diego-volpini

Post on 16-Sep-2015

213 views

Category:

Documents


0 download

DESCRIPTION

Arquitetura PIC16F870

TRANSCRIPT

  • Escola de Educao Profissional SENAI Nilo Peanha Curso Tcnico em Eletrnica

    PIC16F870

    Prof. Diego Volpini Fonte: Microchip

    PIC16F870/871

    DS30569B-page 2 2003 Microchip Technology Inc.

    Pin Diagrams

    PIC

    16F8

    70

    1011

    23456

    1

    87

    9

    121314 15

    1617181920

    232425262728

    2221

    MCLR/VPP/THVRA0/AN0RA1/AN1

    RA2/AN2/VREF-RA3/AN3/VREF+

    RA4/T0CKIRA5/AN4

    VSSOSC1/CLKI

    OSC2/CLKORC0/T1OSO/T1CKI

    RC1/T1OSIRC2/CCP1

    RC3

    RB7/PGDRB6/PGCRB5RB4RB3/PGMRB2RB1RB0/INTVDDVSSRC7/RX/DTRC6/TX/CKRC5RC4

    1011121314151617

    18 19 20 21 22 23 24 25 26

    44

    87

    6 5 4 3 2 1

    27 28

    29303132333435363738394

    0414243

    9

    PIC16F871

    RA4/T0CKIRA5/AN4

    RE0/RD/AN5

    OSC1/CLKIOSC2/CLKO

    RC0/T1OSO/T1CK1NC

    RE1/WR/AN6RE2/CS/AN7

    VDDVSS

    RB3/PGMRB2RB1RB0/INTVDDVSSRD7/PSP7RD6/PSP6RD5/PSP5RD4/PSP4RC7/RX/DT

    RA3

    /AN

    3/VR

    EF+

    RA2

    /AN

    2/V R

    EF-

    RA1

    /AN

    1R

    A0/A

    N0

    MC

    LR/V

    PP

    /TH

    VN

    CR

    B7/P

    GD

    RB6

    /PG

    CR

    B5R

    B4N

    CN

    CR

    C6/

    TX/C

    KR

    C5

    RC

    4R

    D3/

    PSP

    3R

    D2/

    PSP

    2R

    D1/

    PSP

    1R

    D0/

    PSP

    0R

    C3

    RC

    2/C

    CP1

    RC

    1/T1

    OSI

    1011

    23456

    1

    18 19 20 21 2212 13 14 15

    38

    87

    44 43 42 41 40 3916 17

    2930313233

    232425262728

    36 3435

    9

    PIC16F871

    37

    RA3

    /AN

    3/VR

    EF+

    RA2

    /AN

    2/V R

    EF-

    RA1

    /AN

    1R

    A0/A

    N0

    MC

    LR/V

    PP

    /TH

    V

    NC

    RB7

    /PG

    DR

    B6/P

    GC

    RB5

    RB4N

    CR

    C6/

    TX/C

    KR

    C5

    RC

    4R

    D3/

    PSP3

    RD

    2/PS

    P2R

    D1/

    PSP1

    RD

    0/PS

    P0R

    C3

    RC

    2/C

    CP1

    RC

    1/T1

    OSI

    NC

    NCRC0/T1OSO/T1CKIOSC2/CLKOOSC1/CLKIVSSVDDRE2/CS/AN7RE1/WR/AN6RE0/RD/AN5RA5/AN4RA4/T0CKI

    RC7/RX/DTRD4/PSP4RD5/PSP5RD6/PSP6RD7/PSP7

    VSSVDD

    RB0/INTRB1RB2

    RB3/PGM

    PLCC

    TQFP

    DIP, SOIC, SSOP

    2003 Microchip Technology Inc. DS30569B-page 5

    PIC16F870/8711.0 DEVICE OVERVIEWThis document contains device specific information.Additional information may be found in the PICmicroTMMid-Range MCU Family Reference Manual(DS33023), which may be obtained from your localMicrochip Sales Representative or downloaded fromthe Microchip web site. The Reference Manual shouldbe considered a complementary document to this datasheet, and is highly recommended reading for a betterunderstanding of the device architecture and operationof the peripheral modules.

    There are two devices (PIC16F870 and PIC16F871)covered by this data sheet. The PIC16F870 devicecomes in a 28-pin package and the PIC16F871 devicecomes in a 40-pin package. The 28-pin device does nothave a Parallel Slave Port implemented.The following two figures are device block diagramssorted by pin number: 28-pin for Figure 1-1 and 40-pinfor Figure 1-2. The 28-pin and 40-pin pinouts are listedin Table 1-1 and Table 1-2, respectively.

    FIGURE 1-1: PIC16F870 BLOCK DIAGRAM

    FLASHProgramMemory

    13 Data Bus 8

    14ProgramBus

    Instruction reg

    Program Counter

    8 Level Stack(13-bit)

    RAMFile

    Registers

    Direct Addr 7

    RAM Addr (1) 9Addr MUX

    IndirectAddr

    FSR reg

    STATUS reg

    MUX

    ALU

    W reg

    Power-upTimer

    OscillatorStart-up Timer

    Power-onReset

    WatchdogTimer

    InstructionDecode &

    Control

    TimingGeneration

    OSC1/CLKIOSC2/CLKO

    MCLR VDD, VSS

    PORTA

    PORTB

    PORTC

    RA4/T0CKIRA5/AN4

    RB0/INT

    RC0/T1OSO/T1CKIRC1/T1OSIRC2/CCP1RC3RC4RC5RC6/TX/CKRC7/RX/DT

    8

    8

    Brown-outReset

    Note 1: Higher order bits are from the STATUS register.

    USARTCCP1

    10-bit A/DTimer0 Timer1 Timer2

    RA3/AN3/VREF+RA2/AN2/VREF-RA1/AN1RA0/AN0

    8

    3

    Data EEPROM

    RB1RB2RB3/PGMRB4RB5RB6/PGCRB7/PGD

    Device Program FLASH Data Memory Data EEPROMPIC16F870 2K 128 Bytes 64 Bytes

    In-CircuitDebugger

    Low-VoltageProgramming

    2003 Microchip Technology Inc. DS30569B-page 7

    PIC16F870/871 TABLE 1-1: PIC16F870 PINOUT DESCRIPTION

    Pin Name DIPPin#SOICPin#

    I/O/PType

    BufferType Description

    OSC1/CLKI 9 9 I ST/CMOS(3) Oscillator crystal input/external clock source input.OSC2/CLKO 10 10 O Oscillator crystal output. Connects to crystal or resonator in

    Crystal Oscillator mode. In RC mode, the OSC2 pin outputs CLKO, which has 1/4 the frequency of OSC1, and denotes the instruction cycle rate.

    MCLR/VPP/THV 1 1 I/P ST Master Clear (Reset) input or programming voltage input or High Voltage Test mode control. This pin is an active low RESET to the device. PORTA is a bi-directional I/O port.

    RA0/AN0 2 2 I/O TTL RA0 can also be analog input 0.RA1/AN1 3 3 I/O TTL RA1 can also be analog input 1.RA2/AN2/VREF- 4 4 I/O TTL RA2 can also be analog input 2 or negative analog reference

    voltage.RA3/AN3/VREF+ 5 5 I/O TTL RA3 can also be analog input 3 or positive analog reference

    voltage.RA4/T0CKI 6 6 I/O ST/OD RA4 can also be the clock input to the Timer0 module. Output

    is open drain type.RA5/AN4 7 7 I/O TTL RA5 can also be analog input 4.

    PORTB is a bi-directional I/O port. PORTB can be software programmed for internal weak pull-up on all inputs.

    RB0/INT 21 21 I/O TTL/ST(1) RB0 can also be the external interrupt pin.RB1 22 22 I/O TTLRB2 23 23 I/O TTLRB3/PGM 24 24 I/O TTL/ST(1) RB3 can also be the low voltage programming input.RB4 25 25 I/O TTL Interrupt-on-change pin.RB5 26 26 I/O TTL Interrupt-on-change pin.RB6/PGC 27 27 I/O TTL/ST(2) Interrupt-on-change pin or In-Circuit Debugger pin. Serial

    programming clock.RB7/PGD 28 28 I/O TTL/ST(2) Interrupt-on-change pin or In-Circuit Debugger pin. Serial

    programming data.PORTC is a bi-directional I/O port.

    RC0/T1OSO/T1CKI 11 11 I/O ST RC0 can also be the Timer1 oscillator output or Timer1 clockinput.

    RC1/T1OSI 12 12 I/O ST RC1 can also be the Timer1 oscillator input. RC2/CCP1 13 13 I/O ST RC2 can also be the Capture1 input/Compare1 output/

    PWM1 output.RC3 14 14 I/O STRC4 15 15 I/O STRC5 16 16 I/O STRC6/TX/CK 17 17 I/O ST RC6 can also be the USART Asynchronous Transmit or

    Synchronous Clock.RC7/RX/DT 18 18 I/O ST RC7 can also be the USART Asynchronous Receive or

    Synchronous Data.VSS 8, 19 8, 19 P Ground reference for logic and I/O pins.VDD 20 20 P Positive supply for logic and I/O pins.Legend: I = input O = output I/O = input/output P = power

    OD = Open Drain = Not used TTL = TTL input ST = Schmitt Trigger inputNote 1: This buffer is a Schmitt Trigger input when configured as the external interrupt or LVP mode.

    2: This buffer is a Schmitt Trigger input when used in Serial Programming mode.3: This buffer is a Schmitt Trigger input when configured in RC Oscillator mode and a CMOS input otherwise.

    Caractersticas Gerais

    - RISC CPU (35 instrues)

    - Clock: De 0 20 Mhz ( 200 ns por instruo)

    - FLASH Program Memory: 2K

    - EEPROM Data Memory: 64 bytes

    - Data Memory (RAM): 128 bytes

    - Pinagem compatvel com a famlia PIC16

    - Interrupes (11 fontes)

    - Power-on Reset (POR)

    - Power-up Timer (PWRT)

    - Watchdog Timer (WDT)

    - Brown-out Reset (BOR)

    - Code Protection

    - Data Protection

    - SLEEP Mode

    - Oscilador selecionvel

    - In-Circuit-Serial Programming (ICSP) via dois pinos

    - Tenso de operao: 2 5,5 Volts

    - Corrente de sada: 25 mA

    - Baixo consumo de potncia:

    - < 1,6mA @ 5V, 4 MHz - 20uA @ 3V, 32KHz - < 1uA em SLEEP Mode

    - Trs Timers (TIMER0, TIMER1 e TIMER2)

    - Compare, Capture e PWM mdulo (CCP)

    - Conversor A/D de mltiplos canais

    - Universal Synchronous Asynchronous Receiver

    Transmitter (USART/SCI)