Professional Documents
Culture Documents
PIC16F87X: 28/40-Pin 8-Bit CMOS FLASH Microcontrollers
PIC16F87X: 28/40-Pin 8-Bit CMOS FLASH Microcontrollers
PIC16F877/874
Up to 368 x 8 bytes of Data Memory (RAM) RE0/RD/AN5 8 33 RB0/INT
Up to 256 x 8 bytes of EEPROM data memory RE1/WR/AN6 9 32 VDD
★ • Pinout compatible to the PIC16C73/74/76/77 RE2/CS/AN7 10 31 VSS
VDD 11 30 RD7/PSP7
• Interrupt capability (up to 14 internal/external VSS 12 29 RD6/PSP6
interrupt sources) OSC1/CLKIN 13 28 RD5/PSP5
OSC2/CLKOUT 14 27 RD4/PSP4
• Eight level deep hardware stack RC0/T1OSO/T1CKI RC7/RX/DT
15 26
• Direct, indirect, and relative addressing modes RC1/T1OSI/CCP2 16 25 RC6/TX/CK
RC2/CCP1 17 24 RC5/SDO
• Power-on Reset (POR)
RC3/SCK/SCL 18 23 RC4/SDI/SDA
• Power-up Timer (PWRT) and RD0/PSP0 19 22 RD3/PSP3
Oscillator Start-up Timer (OST) RD1/PSP1 20 21 RD2/PSP2
DIP, SOIC
MCLR/VPP/THV 1 28 RB7/PGD
RA0/AN0 2 27 RB6/PGC
RA1/AN1 3 26 RB5
PIC16F876/873
RA2/AN2/VREF- 4 25 RB4
RA3/AN3/VREF+ 5 24 RB3/PGM
RA4/T0CKI 6 23 RB2
RA5/AN4/SS 7 22 RB1
VSS 8 21 RB0/INT
OSC1/CLKIN 9 20 VDD
OSC2/CLKOUT 10 19 VSS
RC0/T1OSO/T1CKI 11 18 RC7/RX/DT
RC1/T1OSI/CCP2 12 17 RC6/TX/CK
RC2/CCP1 13 16 RC5/SDO
RC3/SCK/SCL 14 15 RC4/SDI/SDA
RA3/AN3/VREF+
MCLR/VPP/THV
RA2/AN2/VREF-
RB7/PGD
RB6/PGC
RA1/AN1
RA0/AN0
PLCC
RB5
RB4
NC
NC
6
5
4
3
2
1
43
42
41
40
44
RA4/T0CKI 7 39 RB3/PGM
RA5/AN4/SS 8 38 RB2
RE0/RD/AN5 9 37 RB1
RE1/WR/AN6 10 36 RB0/INT
RE2/CS/AN7 11 PIC16F877 35 VDD
VDD 12 34 VSS
VSS 13
PIC16F874 33 RD7/PSP7
OSC1/CLKIN 14 32 RD6/PSP6
OSC2/CLKOUT 15 31 RD5/PSP5
RC0/T1OSO/T1CK1 16 30 RD4/PSP4
NC 17 9 RC7/RX/DT
18
19
20
21
22
23
24
25
26
27
282
RC1/T1OSI/CCP2
RC3/SCK/SCL
RC4/SDI/SDA
RC1/T1OSI/CCP2
RC3/SCK/SCL
RC2/CCP1
RD0/PSP0
RD1/PSP1
RD2/PSP2
RD3/PSP3
RC5/SDO
RC6/TX/CK
NC
RC4/SDI/SDA
RC6/TX/CK
RC2/CCP1
RD3/PSP3
RD2/PSP2
RD1/PSP1
RD0/PSP0
RC5/SDO
NC
QFP
44
43
42
41
40
39
37
36
35
34
38
RC7/RX/DT 1 33 NC
RD4/PSP4 2 32 RC0/T1OSO/T1CKI
RD5/PSP5 3 31 OSC2/CLKOUT
RD6/PSP6 4 30 OSC1/CLKIN
RD7/PSP7 5 PIC16F877 29 VSS
VSS 6 28 VDD
VDD 7
PIC16F874 27 RE2/AN7/CS
RB0/INT 8 26 RE1/AN6/WR
RB1 9 25 RE0/AN5/RD
RB2 10 24 RA5/AN4
RB3/PGM 11 23 RA4/T0CKI
12
13
14
15
16
17
18
19
20
21
22
RA3/AN3/VREF+
MCLR/VPP/THV
RB6/PGC
RB7/PGD
RA0/AN0
RA1/AN1
NC
NC
RB4
RB5
RA2/AN2/VREF-
Key Features
PICmicro™ Mid-Range Reference PIC16F873 PIC16F874 PIC16F876 PIC16F877
Manual (DS33023)
Operating Frequency DC - 20 MHz DC - 20 MHz DC - 20 MHz DC - 20 MHz
Resets (and Delays) POR, BOR POR, BOR POR, BOR POR, BOR
(PWRT, OST) (PWRT, OST) (PWRT, OST) (PWRT, OST)
FLASH Program Memory 4K 4K 8K 8K
(14-bit words)
Data Memory (bytes) 192 192 368 368
EEPROM Data Memory 128 128 256 256
Interrupts 13 14 13 14
I/O Ports Ports A,B,C Ports A,B,C,D,E Ports A,B,C Ports A,B,C,D,E
Timers 3 3 3 3
Capture/Compare/PWM modules 2 2 2 2
Serial Communications MSSP, USART MSSP, USART MSSP, USART MSSP, USART
Parallel Communications — PSP — PSP
10-bit Analog-to-Digital Module 5 input channels 8 input channels 5 input channels 8 input channels
Instruction Set 35 Instructions 35 Instructions 35 Instructions 35 Instructions
RE0/AN5/RD
RE1/AN6/WR
MCLR VDD, VSS
RE2/AN7/CS
RE0/RD/AN5 8 9 25 I/O ST/TTL(3) RE0 can also be read control for the parallel slave port,
or analog input5.
RE1/WR/AN6 9 10 26 I/O ST/TTL(3) RE1 can also be write control for the parallel slave port,
or analog input6.
RE2/CS/AN7 10 11 27 I/O ST/TTL(3) RE2 can also be select control for the parallel slave
port, or analog input7.
VSS 12,31 13,34 6,29 P — Ground reference for logic and I/O pins.
VDD 11,32 12,35 7,28 P — Positive supply for logic and I/O pins.
NC — 1,17,28, 12,13, — These pins are not internally connected. These pins should
40 33,34 be left unconnected.
Legend: I = input O = output I/O = input/output P = power
— = Not used TTL = TTL input ST = Schmitt Trigger input
Note 1: This buffer is a Schmitt Trigger input when configured as an external interrupt.
2: This buffer is a Schmitt Trigger input when used in serial programming mode.
3: This buffer is a Schmitt Trigger input when configured as general purpose I/O and a TTL input when used in the Parallel
Slave Port mode (for interfacing to a microprocessor bus).
4: This buffer is a Schmitt Trigger input when configured in RC oscillator mode and a CMOS input otherwise.
CALL, RETURN 13
RETFIE, RETLW
Stack Level 1
1FFFh
Stack Level 2
Stack Level 8
17FFh
1800h
Page 3
1FFFh
File
Address
General General
Purpose Purpose accesses accesses
Register Register
20h-7Fh A0h - FFh
96 Bytes 96 Bytes 16Fh 1EFh
170h 1F0h
Bank 0
00h(4) INDF Addressing this location uses contents of FSR to address data memory (not a physical register) 0000 0000 0000 0000
02h(4) PCL Program Counter's (PC) Least Significant Byte 0000 0000 0000 0000
(4)
03h STATUS IRP RP1 RP0 TO PD Z DC C 0001 1xxx 000q quuu
04h(4) FSR Indirect data memory address pointer xxxx xxxx uuuu uuuu
05h PORTA — — PORTA Data Latch when written: PORTA pins when read --0x 0000 --0u 0000
06h PORTB PORTB Data Latch when written: PORTB pins when read xxxx xxxx uuuu uuuu
07h PORTC PORTC Data Latch when written: PORTC pins when read xxxx xxxx uuuu uuuu
08h(5) PORTD PORTD Data Latch when written: PORTD pins when read xxxx xxxx uuuu uuuu
0Ah(1,4) PCLATH — — — Write Buffer for the upper 5 bits of the Program Counter ---0 0000 ---0 0000
0Bh(4) INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
0Ch PIR1 PSPIF(3) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
0Dh PIR2 — (6) — EEIF BCLIF — — CCP2IF -r-0 0--0 -r-0 0--0
0Eh TMR1L Holding register for the Least Significant Byte of the 16-bit TMR1 register xxxx xxxx uuuu uuuu
0Fh TMR1H Holding register for the Most Significant Byte of the 16-bit TMR1 register xxxx xxxx uuuu uuuu
10h T1CON — — T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON --00 0000 --uu uuuu
12h T2CON — TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000
13h SSPBUF Synchronous Serial Port Receive Buffer/Transmit Register xxxx xxxx uuuu uuuu
14h SSPCON WCOL SSPOV SSPEN CKP SSPM3 SSPM2 SSPM1 SSPM0 0000 0000 0000 0000
17h CCP1CON — — CCP1X CCP1Y CCP1M3 CCP1M2 CCP1M1 CCP1M0 --00 0000 --00 0000
18h RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 0000 000x
19h TXREG USART Transmit Data Register 0000 0000 0000 0000
1Ah RCREG USART Receive Data Register 0000 0000 0000 0000
1Dh CCP2CON — — CCP2X CCP2Y CCP2M3 CCP2M2 CCP2M1 CCP2M0 --00 0000 --00 0000
1Eh ADRESH A/D Result Register High Byte xxxx xxxx uuuu uuuu
GO/
1Fh ADCON0 ADCS1 ADCS0 CHS2 CHS1 CHS0 — ADON 0000 00-0 0000 00-0
DONE
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented read as '0', r = reserved.
Shaded locations are unimplemented, read as ‘0’.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the
PC<12:8> whose
contents are transferred to the upper byte of the program counter.
2: Other (non power-up) resets include external reset through MCLR and Watchdog Timer Reset.
3: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
4: These registers can be addressed from any bank.
5: PORTD, PORTE, TRISD, and TRISE are not physically implemented on the 28-pin devices, read as ‘0’.
6: PIR2<6> and PIE2<6> are reserved on these devices, always maintain these bits clear.
Bank 1
80h(4) INDF Addressing this location uses contents of FSR to address data memory (not a physical register) 0000 0000 0000 0000
OPTION_RE
81h RBPU INTEDG T0CS T0SE PSA PS2 PS1 PS0 1111 1111 1111 1111
G
82h(4) PCL Program Counter's (PC) Least Significant Byte 0000 0000 0000 0000
(4)
83h STATUS IRP RP1 RP0 TO PD Z DC C 0001 1xxx 000q quuu
84h(4) FSR Indirect data memory address pointer xxxx xxxx uuuu uuuu
85h TRISA — — PORTA Data Direction Register --11 1111 --11 1111
86h TRISB PORTB Data Direction Register 1111 1111 1111 1111
87h TRISC PORTC Data Direction Register 1111 1111 1111 1111
88h(5) TRISD PORTD Data Direction Register 1111 1111 1111 1111
89h(5) TRISE IBF OBF IBOV PSPMODE — PORTE Data Direction Bits 0000 -111 0000 -111
8Ah(1,4) PCLATH — — — Write Buffer for the upper 5 bits of the Program Counter ---0 0000 ---0 0000
8Bh(4) INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
8Ch PIE1 PSPIE(3) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
8Dh PIE2 — (6) — EEIE BCLIE — — CCP2IE -r-0 0--0 -r-0 0--0
8Fh — Unimplemented — —
90h — Unimplemented — —
91h SSPCON2 GCEN ACKSTAT ACKDT ACKEN RCEN PEN RSEN SEN 0000 0000 0000 0000
94h SSPSTAT SMP CKE D/A P S R/W UA BF 0000 0000 0000 0000
95h — Unimplemented — —
96h — Unimplemented — —
97h — Unimplemented — —
98h TXSTA CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 0000 -010
99h SPBRG Baud Rate Generator Register 0000 0000 0000 0000
9Ah — Unimplemented — —
9Bh — Unimplemented — —
9Ch — Unimplemented — —
9Dh — Unimplemented — —
9Eh ADRESL A/D Result Register Low Byte xxxx xxxx uuuu uuuu
9Fh ADCON1 ADFM — — — PCFG3 PCFG2 PCFG1 PCFG0 --0- 0000 --0- 0000
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented read as '0', r = reserved.
Shaded locations are unimplemented, read as ‘0’.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the
PC<12:8> whose
contents are transferred to the upper byte of the program counter.
2: Other (non power-up) resets include external reset through MCLR and Watchdog Timer Reset.
3: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
4: These registers can be addressed from any bank.
5: PORTD, PORTE, TRISD, and TRISE are not physically implemented on the 28-pin devices, read as ‘0’.
6: PIR2<6> and PIE2<6> are reserved on these devices, always maintain these bits clear.
Bank 2
100h(4) INDF Addressing this location uses contents of FSR to address data memory (not a physical register) 0000 0000 0000 0000
102h(4) PCL Program Counter's (PC) Least Significant Byte 0000 0000 0000 0000
104h(4) FSR Indirect data memory address pointer xxxx xxxx uuuu uuuu
105h — Unimplemented — —
106h PORTB PORTB Data Latch when written: PORTB pins when read xxxx xxxx uuuu uuuu
107h — Unimplemented — —
108h — Unimplemented — —
109h — Unimplemented — —
(1,4) PCLATH — — — Write Buffer for the upper 5 bits of the Program Counter ---0 0000 ---0 0000
10Ah
10Bh(4) INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
10Eh EEDATH — — EEPROM data register high byte xxxx xxxx uuuu uuuu
10Fh EEADRH — — — EEPROM address register high byte xxxx xxxx uuuu uuuu
Bank 3
180h(4) INDF Addressing this location uses contents of FSR to address data memory (not a physical register) 0000 0000 0000 0000
OPTION_RE
181h RBPU INTEDG T0CS T0SE PSA PS2 PS1 PS0 1111 1111 1111 1111
G
182h(4) PCL Program Counter's (PC) Least Significant Byte 0000 0000 0000 0000
184h(4) FSR Indirect data memory address pointer xxxx xxxx uuuu uuuu
185h — Unimplemented — —
186h TRISB PORTB Data Direction Register 1111 1111 1111 1111
187h — Unimplemented — —
188h — Unimplemented — —
189h — Unimplemented — —
Write Buffer for the upper 5 bits of the Program
18Ah(1,4) PCLATH — — —
Counter
---0 0000 ---0 0000
18Bh(4) INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
18Dh EECON2 EEPROM control register2 (not a physical register) ---- ---- ---- ----
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented read as '0', r = reserved.
Shaded locations are unimplemented, read as ‘0’.
Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a holding register for the
PC<12:8> whose
contents are transferred to the upper byte of the program counter.
2: Other (non power-up) resets include external reset through MCLR and Watchdog Timer Reset.
3: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
4: These registers can be addressed from any bank.
5: PORTD, PORTE, TRISD, and TRISE are not physically implemented on the 28-pin devices, read as ‘0’.
6: PIR2<6> and PIE2<6> are reserved on these devices, always maintain these bits clear.
This register contains the individual enable bits for the Note: Bit PEIE (INTCON<6>) must be set to
peripheral interrupts. enable any peripheral interrupt.
Note 1: PSPIE is reserved on 28-pin devices, always maintain this bit clear.
Data
Memory(1)
05h PORTA — — RA5 RA4 RA3 RA2 RA1 RA0 --0x 0000 --0u 0000
85h TRISA — — PORTA Data Direction Register --11 1111 --11 1111
9Fh ADCON1 ADFM — — — PCFG3 PCFG2 PCFG1 PCFG0 --0- 0000 --0- 0000
Legend: x = unknown, u = unchanged, - = unimplemented locations read as '0'. Shaded cells are not used by PORTA.
From other Q D
RD TRIS RB7:RB4 pins RD Port
EN
Q D Q3
RB7:RB6 in serial programming mode
RD Port EN
Value on:
Value on all
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR,
other resets
BOR
06h, 106h PORTB RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 xxxx xxxx uuuu uuuu
86h, 186h TRISB PORTB Data Direction Register 1111 1111 1111 1111
81h, 181h OPTION_ RBPU INTEDG T0CS T0SE PSA PS2 PS1 PS0 1111 1111 1111 1111
REG
Legend: x = unknown, u = unchanged. Shaded cells are not used by PORTB.
Schmitt
RD TRIS Trigger
Peripheral
OE(3) Q D Schmitt
Trigger
EN with
RD SMBus
PORT 0 levels
SSPl input
1
CKE
SSPSTAT<6>
Value on
Value on:
all
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR,
other
BOR
resets
07h PORTC RC7 RC6 RC5 RC4 RC3 RC2 RC1 RC0 xxxx xxxx uuuu uuuu
87h TRISC PORTC Data Direction Register 1111 1111 1111 1111
Legend: x = unknown, u = unchanged.
RD TRIS
Q D
EN
EN
RD PORT
Value on:
Value on all
Addr Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR,
other resets
BOR
09h PORTE — — — — — RE2 RE1 RE0 ---- -xxx ---- -uuu
89h TRISE IBF OBF IBOV PSPMODE — PORTE Data Direction Bits 0000 -111 0000 -111
9Fh ADCON1 ADFM — — — PCFG3 PCFG2 PCFG1 PCFG0 --0- 0000 --0- 0000
Legend: x = unknown, u = unchanged, - = unimplemented read as '0'. Shaded cells are not used by PORTE.
Write
TTL WR
CS
WR
RD
PORTD<7:0>
IBF
OBF
PSPIF
CS
WR
RD
PORTD<7:0>
IBF
OBF
PSPIF
Value on
Value on:
all
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR,
other
BOR
resets
08h PORTD Port data latch when written: Port pins when read xxxx xxxx uuuu uuuu
09h PORTE — — — — — RE2 RE1 RE0 ---- -xxx ---- -uuu
89h TRISE IBF OBF IBOV PSPMODE — PORTE Data Direction Bits 0000 -111 0000 -111
0Ch PIR1 PSPIF ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
8Ch PIE1 PSPIE ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
9Fh ADCON1 ADFM — — — PCFG3 PCFG2 PCFG1 PCFG0 --0- 0000 --0- 0000
Legend: x = unknown, u = unchanged, - = unimplemented read as '0'. Shaded cells are not used by the Parallel
Slave Port.
4.4 Writing to the Data EEPROM Memory the EEDATA register. Then the sequence in
Example 4-2 must be followed to initiate the write cycle.
To write an EEPROM data location, the address must
first be written to the EEADR register and the data to
The write will not initiate if the above sequence is not After a write sequence has been initiated, clearing the
exactly followed (write 55h to EECON2, write AAh to WREN bit will not affect the current write cycle. The WR
EECON2, then set WR bit) for each byte. It is strongly bit will be inhibited from being set unless the WREN bit
recommended that interrupts be disabled during this is set. The WREN bit must be set on a previous instruc-
code segment. tion, both WR and WREN cannot be set with the same
Additionally, the WREN bit in EECON1 must be set to instruction.
enable writes. This mechanism prevents accidental At the completion of the write cycle, the WR bit is
writes to data EEPROM due to unexpected code exe- cleared in hardware and the EEPROM Write Complete
cution (i.e., lost programs). The WREN bit should be Interrupt Flag bit (EEIF) is set. EEIF must be cleared by
kept clear at all times, except when updating the software.
EEPROM. The WREN bit is not cleared by hardware
Depending on the application, good programming To protect against spurious writes to FLASH program
practice may dictate that the value written to the mem- memory, the WRT bit in the configuration word may be
ory should be verified against the original value. This programmed to ‘0’ to prevent writes. WRT and the con-
should be used in applications where excessive writes figuration word cannot be programmed by user code,
can stress bits near the specification limit. only through the use of an external programmer.
Generally a write failure will be a bit which was written 4.9 Operation during Code Protect
as a '1', but reads back as a '0' (due to leakage off the
bit). Each reprogrammable memory block has its own code
protect mechanism. External Read and Write opera-
4.8 Protection Against Spurious Write tions are disabled if either of these mechanisms are
enabled.
4.8.1 EEPROM DATA MEMORY
4.9.3 DATA EEPROM MEMORY
There are conditions when the device may not want to
write to the data EEPROM memory. To protect against The microcontroller itself can both read and write to the
spurious EEPROM writes, various mechanisms have internal Data EEPROM regardless of the state of the
been built in. On power-up, the WREN bit is cleared. code protect configuration bit.
Also, the Power-up Timer (72 ms duration) prevents
EEPROM write. 4.9.4 PROGRAM FLASH MEMORY
The write initiate sequence and the WREN bit together The microcontroller can read and execute instructions
help prevent an accidental write during brown-out, out of the internal FLASH program memory regardless
power glitch, or software malfunction. of the state of the code protect configuration bits. How-
ever the WRT configuration bit and the code protect bits
have different effects on writing to program memory.
Table 7-1 shows the various configurations and status
of reads and writes. To erase the WRT or code protec-
tion bits in the configuration word requires that the
device be fully erased.
Data bus
Fosc/4 0
PSout 8
1
Sync with
1 Internal TMR0
clocks
RA4/T0CKI Programmable 0 PSout
pin Prescaler
T0SE (2 cycle delay)
3
Set interrupt
PS2, PS1, PS0 PSA flag bit T0IF
T0CS on overflow
8
M 1
0
RA4/T0CKI U M
X SYNC
pin U 2 TMR0 reg
1 0
X Cycles
T0SE
T0CS
PSA Set flag bit T0IF
on Overflow
0
M 8-bit Prescaler
U
Watchdog 1 X
8
Timer
8 - to - 1MUX PS2:PS0
PSA
0 1
WDT Enable bit
MUX PSA
WDT
Time-out
TMR1CS = 1
1 = Do not synchronize external clock input
0 = Synchronize external clock input
TMR1CS = 0
This bit is ignored. Timer1 uses the internal clock when TMR1CS = 0.
bit 1: TMR1CS: Timer1 Clock Source Select bit
1 = External clock from pin RC0/T1OSO/T1CKI (on the rising edge)
0 = Internal clock (FOSC/4)
bit 0: TMR1ON: Timer1 On bit
1 = Enables Timer1
0 = Stops Timer1
T1CKI
(Default high)
T1CKI
(Default low)
Note 1: When the T1OSCEN bit is cleared, the inverter and feedback resistor are turned off. This eliminates power drain.
0Bh,8Bh, INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
10Bh,18Bh
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
0Eh TMR1L Holding register for the Least Significant Byte of the 16-bit TMR1 register xxxx xxxx uuuu uuuu
0Fh TMR1H Holding register for the Most Significant Byte of the 16-bit TMR1 register xxxx xxxx uuuu uuuu
10h T1CON — — T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON --00 0000 --uu uuuu
Legend: x = unknown, u = unchanged, - = unimplemented read as '0'. Shaded cells are not used by the Timer1 module.
Note 1: These bits are reserved on the 28-pin devices, always maintain these bits clear.
The output of TMR2 (before the postscaler) is fed to the 4 PR2 reg
Synchronous Serial Port module which optionally uses
it to generate shift clock.
Note 1: TMR2 register output can be software selected
by the SSP Module as a baud clock.
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
12h T2CON — TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000
FIGURE 8-1: CCP1CON REGISTER (ADDRESS 17h) / CCP2CON REGISTER (ADDRESS 1Dh)
In Capture mode, CCPR1H:CCPR1L captures the There are four prescaler settings, specified by bits
16-bit value of the TMR1 register when an event occurs CCP1M3:CCP1M0. Whenever the CCP module is
on pin RC2/CCP1. An event is defined as: turned off, or the CCP module is not in capture mode,
the prescaler counter is cleared. This means that any
• every falling edge
reset will clear the prescaler counter.
• every rising edge
Switching from one capture prescaler to another may
• every 4th rising edge
generate an interrupt. Also, the prescaler counter will
• every 16th rising edge not be cleared, therefore the first capture may be from
An event is selected by control bits CCP1M3:CCP1M0 a non-zero prescaler. Example 8-1 shows the recom-
(CCP1CON<3:0>). When a capture is made, the inter- mended method for switching between capture pres-
rupt request flag bit CCP1IF (PIR1<2>) is set. It must calers. This example also clears the prescaler counter
be cleared in software. If another capture occurs before and will not generate the “false” interrupt.
the value in register CCPR1 is read, the old captured
value will be lost. EXAMPLE 8-1: CHANGING BETWEEN
CAPTURE PRESCALERS
8.1.1 CCP PIN CONFIGURATION
CLRF CCP1CON ;Turn CCP module off
In Capture mode, the RC2/CCP1 pin should be config- MOVLW NEW_CAPT_PS ;Load the W reg with
; the new prescaler
ured as an input by setting the TRISC<2> bit.
; mode value and CCP ON
Note: If the RC2/CCP1 is configured as an out- MOVWF CCP1CON ;Load CCP1CON with this
put, a write to the port can cause a capture ; value
condition.
and Capture
edge detect Enable
TMR1H TMR1L
CCP1CON<3:0>
Q’s
In Compare mode, the 16-bit CCPR1 register value is The user must configure the RC2/CCP1 pin as an out-
constantly compared against the TMR1 register pair put by clearing the TRISC<2> bit.
value. When a match occurs, the RC2/CCP1 pin is:
Note: Clearing the CCP1CON register will force
• driven High the RC2/CCP1 compare output latch to the
• driven Low default low level. This is not the data latch.
• remains Unchanged
8.2.2 TIMER1 MODE SELECTION
The action on the pin is based on the value of control
bits CCP1M3:CCP1M0 (CCP1CON<3:0>). At the Timer1 must be running in Timer mode or Synchro-
same time, interrupt flag bit CCP1IF is set. nized Counter mode if the CCP module is using the
compare feature. In Asynchronous Counter mode, the
FIGURE 8-3: COMPARE MODE compare operation may not work.
OPERATION BLOCK 8.2.3 SOFTWARE INTERRUPT MODE
DIAGRAM
When generate software interrupt is chosen the CCP1
pin is not affected. Only a CCP interrupt is generated (if
Special event trigger will:
enabled).
reset Timer1, but not set interrupt flag bit
TMR1IF (PIR1<0>), and set bit GO/DONE 8.2.4 SPECIAL EVENT TRIGGER
Special Event Trigger (CCP2 only) In this mode, an internal hardware trigger is generated
which may be used to initiate an action.
Set flag bit CCP1IF
(PIR1<2>) The special event trigger output of CCP1 resets the
CCPR1H CCPR1L TMR1 register pair. This allows the CCPR1 register to
effectively be a 16-bit programmable period register for
Q S Output
Logic Comparator Timer1.
RC2/CCP1 R match
Pin The special trigger output of CCP2 resets the TMR1
TRISC<2> TMR1H TMR1L
Output Enable CCP1CON<3:0> register pair, and starts an A/D conversion (if the A/D
Mode Select module is enabled).
Note: The special event trigger from the CCP2
module will not set interrupt flag bit
TMR1IF (PIR1<0>).
TABLE 8-3 REGISTERS ASSOCIATED WITH CAPTURE, COMPARE, AND TIMER1
0Bh,8Bh, INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
10Bh,18Bh
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
87h TRISC PORTC Data Direction Register 1111 1111 1111 1111
0Eh TMR1L Holding register for the Least Significant Byte of the 16-bit TMR1 register xxxx xxxx uuuu uuuu
0Fh TMR1H Holding register for the Most Significant Byte of the 16-bit TMR1register xxxx xxxx uuuu uuuu
10h T1CON — — T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON --00 0000 --uu uuuu
17h CCP1CON — — CCP1X CCP1Y CCP1M3 CCP1M2 CCP1M1 CCP1M0 --00 0000 --00 0000
Legend: x = unknown, u = unchanged, - = unimplemented read as '0'. Shaded cells are not used by Capture and Timer1.
Note 1: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
In Pulse Width Modulation (PWM) mode, the CCP1 pin The PWM period is specified by writing to the PR2 reg-
produces up to a 10-bit resolution PWM output. Since ister. The PWM period can be calculated using the fol-
the CCP1 pin is multiplexed with the PORTC data latch, lowing formula:
the TRISC<2> bit must be cleared to make the CCP1 PWM period = [(PR2) + 1] ¥ 4 ¥ TOSC ¥
pin an output. (TMR2 prescale value)
Note: Clearing the CCP1CON register will force PWM frequency is defined as 1 / [PWM period].
the CCP1 PWM output latch to the default
When TMR2 is equal to PR2, the following three events
low level. This is not the PORTC I/O data
occur on the next increment cycle:
latch.
• TMR2 is cleared
Figure 8-4 shows a simplified block diagram of the CCP
module in PWM mode. • The CCP1 pin is set (exception: if PWM duty
cycle = 0%, the CCP1 pin will not be set)
For a step by step procedure on how to set up the CCP
• The PWM duty cycle is latched from CCPR1L into
module for PWM operation, see Section 8.3.3.
CCPR1H
A PWM output (Figure 8-5) has a time base (period) The CCPR1H register and a 2-bit internal latch are
and a time that the output stays high (duty cycle). The used to double buffer the PWM duty cycle. This double
frequency of the PWM is the inverse of the period buffering is essential for glitchless PWM operation.
(1/period). When the CCPR1H and 2-bit latch match TMR2 con-
catenated with an internal 2-bit Q clock or 2 bits of the
FIGURE 8-5: PWM OUTPUT TMR2 prescaler, the CCP1 pin is cleared.
Maximum PWM resolution (bits) for a given PWM
Period
frequency:
Fosc
log ( Fpwm )
= bits
Duty Cycle
log (2)
TMR2 = PR2
TMR2 = Duty Cycle Note: If the PWM duty cycle value is longer than
the PWM period the CCP1 pin will not be
TMR2 = PR2 cleared.
For an example PWM period and duty cycle calcula-
tion, see the Midrange Reference Manual (DS33023).
PWM Frequency 1.22 kHz 4.88 kHz 19.53 kHz 78.12 kHz 156.3 kHz 208.3 kHz
Timer Prescaler (1, 4, 16) 16 4 1 1 1 1
PR2 Value 0xFF 0xFF 0xFF 0x3F 0x1F 0x17
Maximum Resolution (bits) 10 10 10 8 7 5.5
TABLE 8-5 REGISTERS ASSOCIATED WITH PWM AND TIMER2
0Bh,8Bh, INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
10Bh,18Bh
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
87h TRISC PORTC Data Direction Register 1111 1111 1111 1111
92h PR2 Timer2 module’s period register 1111 1111 1111 1111
12h T2CON — TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 -000 0000 -000 0000
17h CCP1CON — — CCP1X CCP1Y CCP1M3 CCP1M2 CCP1M1 CCP1M0 --00 0000 --00 0000
Legend: x = unknown, u = unchanged, - = unimplemented read as '0'. Shaded cells are not used by PWM and Timer2.
Note 1: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
SDO SDI
SDI SDO
Shift Register Shift Register
(SSPSR) (SSPSR)
PROCESSOR 1 PROCESSOR 2
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
4 clock
SCK modes
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Input
Sample
(SMP = 1)
SSPIF
Next Q4 cycle
after Q2↓
SSPSR to
SSPBUF
SS
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI bit0
(SMP = 0) bit7 bit7
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 cycle
after Q2↓
SSPSR to
SSPBUF
SS
optional
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSPBUF
SDI
(SMP = 0) bit7 bit0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 cycle
after Q2↓
SSPSR to
SSPBUF
SCK
(CKP = 1
CKE = 1)
Write to
SSPBUF
SDI
(SMP = 0) bit7 bit0
Input
Sample
(SMP = 0)
SSPIF
Interrupt
Flag
Next Q4 cycle
after Q2↓
SSPSR to
SSPBUF
0Bh, 8Bh,
INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
10Bh,18Bh
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
(1)
8Ch PIE1 PSPIE ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
13h SSPBUF Synchronous Serial Port Receive Buffer/Transmit Register xxxx xxxx uuuu uuuu
14h SSPCON WCOL SSPOV SSPEN CKP SSPM3 SSPM2 SSPM1 SSPM0 0000 0000 0000 0000
94h SSPSTAT SMP CKE D/A P S R/W UA BF 0000 0000 0000 0000
Legend: x = unknown, u = unchanged, - = unimplemented read as '0'. Shaded cells are not used by the SSP in SPI mode.
Note 1: These bits are reserved on the 28-pin devices, always maintain these bits clear.
Addr Match
FIGURE 9-10: I2C SLAVE MODE BLOCK Match detect
DIAGRAM
Internal SSPADD reg
data bus
Read Write Start and Stop bit Set/Clear S bit
and
detect / generate Clear/Set P bit
SSPBUF reg (SSPSTAT reg)
SCL and Set SSPIF
shift
clock Two pins are used for data transfer. These are the SCL
pin, which is the clock, and the SDA pin, which is the
SSPSR reg
data. The SDA and SCL pins that are automatically
SDA MSb LSb
configured when the I2C mode is enabled. The SSP
module functions are enabled by setting SSP Enable
Match detect Addr Match bit SSPEN (SSPCON<5>).
The MSSP module has six registers for I2C operation.
They are the:
SSPADD reg
• SSP Control Register (SSPCON)
Start and Set, Reset • SSP Control Register2 (SSPCON2)
Stop bit detect S, P bits • SSP Status Register (SSPSTAT)
(SSPSTAT reg)
• Serial Receive/Transmit Buffer (SSPBUF)
• SSP Shift Register (SSPSR) - Not directly acces-
sible
• SSP Address Register (SSPADD)
The SSPCON register allows control of the I 2C opera-
tion. Four mode selection bits (SSPCON<3:0>) allow
one of the following I 2C modes to be selected:
• I 2C Slave mode (7-bit address)
• I 2C Slave mode (10-bit address)
• I 2C Master mode, clock = OSC/4 (SSPADD +1)
Before selecting any I 2C mode, the SCL and SDA pins
must be programmed to inputs by setting the appropri-
ate TRIS bits. Selecting an I 2C mode, by setting the
SSPEN bit, enables the SCL and SDA pins to be used
as the clock and data lines in I 2C mode.
The CKE bit (SSPSTAT<67>) sets the levels of the SDA
and SCL pins in either master or slave mode. When
CKE = 1, the levels will conform to the SMBUS specifi-
cation. When CKE = 0, the levels will conform to the
I2C specification.
9.2.1.3 SLAVE TRANSMISSION An SSP interrupt is generated for each data transfer
byte. The SSPIF flag bit must be cleared in software,
When the R/W bit of the incoming address byte is set and the SSPSTAT register is used to determine the sta-
and an address match occurs, the R/W bit of the tus of the byte transfer. The SSPIF flag bit is set on the
SSPSTAT register is set. The received address is falling edge of the ninth clock pulse.
loaded into the SSPBUF register. The ACK pulse will
be sent on the ninth bit, and the SCL pin is held low. As a slave-transmitter, the ACK pulse from the master-
The transmit data must be loaded into the SSPBUF receiver is latched on the rising edge of the ninth SCL
register, which also loads the SSPSR register. Then the input pulse. If the SDA line was high (not ACK), then the
SCL pin should be enabled by setting bit CKP (SSP- data transfer is complete. When the not ACK is latched
CON<4>). The master must monitor the SCL pin prior by the slave, the slave logic is reset and the slave then
to asserting another clock pulse. The slave devices monitors for another occurrence of the START bit. If the
may be holding off the master by stretching the clock. SDA line was low (ACK), the transmit data must be
The eight data bits are shifted out on the falling edge of loaded into the SSPBUF register, which also loads the
the SCL input. This ensures that the SDA signal is valid SSPSR register. Then the SCL pin should be enabled
during the SCL high time (Figure 9-13). by setting the CKP bit.
SCL S 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 P
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
Data in SCL held low
sampled while CPU
responds to SSPIF
SSPIF
BF (SSPSTAT<0>)
cleared in software From SSP interrupt
SSPBUF is written in software service routine
CKP (SSPCON<4>)
Receive First Byte of Address R/W = 0 Receive Second Byte of Address Receive First Byte of Address R/W=1 Transmitting Data Byte ACK
SDA 1 1 1 1 0 A9 A8 ACK A7 A6 A5 A4 A3 A2 A1 A0 ACK 1 1 1 1 0 A9 A8 ACK D7 D6 D5 D4 D3 D2 D1 D0
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S Sr P
SSPIF
(PIR1<3>)
Cleared in software Cleared in software Cleared in software Bus Master
terminates
transfer
Preliminary
BF (SSPSTAT<0>)
DS30292A-page 75
PIC16F87X
DS30292A-page 76
PIC16F87X
Bus Master
Clock is held low until terminates
update of SSPADD has transfer
tACKEN place
Receive First Byte of Address Receive Second Byte of Address Receive Data Byte
R/W = 0 R/W = 1
SCL 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S P
SSPIF
(PIR1<3>)
Cleared in software Cleared in software
BF (SSPSTAT<0>)
FIGURE 9-15: I2C SLAVE-RECEIVER (10-BIT ADDRESS)
SSPBUF is written with Dummy read of SSPBUF Dummy read of SSPBUF Read of SSPBUF
contents of SSPSR to clear BF flag to clear BF flag clears BF flag
UA (SSPSTAT<1>)
The general call address is one of eight addresses In 10-bit mode, the SSPADD is required to be updated
reserved for specific purposes by the I2C protocol. It for the second half of the address to match, and the UA
consists of all 0’s with R/W = 0 bit is set (SSPSTAT<1>). If the general call address is
sampled when GCEN is set while the slave is config-
The general call address is recognized when the Gen- ured in 10-bit address mode, then the second half of
eral Call Enable bit (GCEN) is enabled (SSPCON2<7> the address is not necessary, the UA bit will not be set,
is set). Following a start-bit detect, 8-bits are shifted and the slave will begin receiving data after the
into SSPSR and the address is compared against acknowledge (Figure 9-16).
SSPADD, and is also compared to the general call
address, fixed in hardware.
FIGURE 9-16: SLAVE MODE GENERAL CALL ADDRESS SEQUENCE (7 OR 10-BIT MODE)
SCL
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
S
SSPIF
BF
(SSPSTAT<0>)
Cleared in software
SSPBUF is read
SSPOV '0'
(SSPCON<6>)
GCEN '1'
(SSPCON2<7>)
While in sleep mode, the I2C module can receive A reset disables the SSP module and terminates the
addresses or data, and when an address match or current transfer.
complete byte transfer occurs wake the processor from
sleep (if the SSP interrupt is enabled).
TABLE 9-3 REGISTERS ASSOCIATED WITH I2C OPERATION
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR, BOR MCLR, WDT
0Bh, 8Bh,
INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
10Bh,18Bh
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
0Dh PIR2 — (2) — EEIF BCLIF — — CCP2IF -r-0 0--0 -r-0 0--0
8Dh PIE2 — (2) — EEIE BCLIE — — CCP2IE -r-0 0--0 -r-0 0--0
13h SSPBUF Synchronous Serial Port Receive Buffer/Transmit Register xxxx xxxx uuuu uuuu
14h SSPCON WCOL SSPOV SSPEN CKP SSPM3 SSPM2 SSPM1 SSPM0 0000 0000 0000 0000
91h SSPCON2 GCEN ACKSTAT ACKDT ACKEN RCEN PEN RSEN SEN 0000 0000 0000 0000
94h SSPSTAT SMP CKE D/A P S R/W UA BF 0000 0000 0000 0000
Legend: x = unknown, u = unchanged, - = unimplemented read as '0'. Shaded cells are not used by the SSP in I2C mode.
Note 1: These bits are reserved on the 28-pin devices, always maintain these bits clear.
2: These bits are reserved on these devices, always maintain these bits clear.
Internal SSPM3:SSPM0,
data bus SSPADD<6:0>
Read Write
SSPBUF Baud
rate
generator
SDA shift
clock cntl
Acknowledge
Generate
SCL
In multi-master mode, the interrupt generation on the The master device generates all of the serial clock
detection of the START and STOP conditions allows pulses and the START and STOP conditions. A trans-
the determination of when the bus is free. The STOP fer is ended with a STOP condition or with a Repeated
(P) and START (S) bits are cleared from a reset or Start condition. Since the Repeated Start condition is
when the MSSP module is disabled. Control of the I 2C also the beginning of the next serial transfer, the I2C
bus may be TACKEN when bit P (SSPSTAT<4>) is set, bus will not be released.
or the bus is idle with both the S and P bits clear. When In Master Transmitter mode serial data is output
the bus is busy, enabling the SSP Interrupt will gener- through SDA, while SCL outputs the serial clock. The
ate the interrupt when the STOP condition occurs. first byte transmitted contains the slave address of the
In multi-master operation, the SDA line must be moni- receiving device, (7 bits) and the Read/Write (R/W) bit.
tored, for abitration, to see if the signal level is the In this case the R/W bit will be logic '0'. Serial data is
expected output level. This check is performed in hard- transmitted 8 bits at a time. After each byte is transmit-
ware, with the result placed in the BCLIF bit. ted, an acknowledge bit is received. START and STOP
The states where arbitration can be lost are: conditions are output to indicate the beginning and the
end of a serial transfer.
• Address Transfer
• Data Transfer In Master receive mode the first byte transmitted con-
• A Start Condition tains the slave address of the transmitting device
• A Repeated Start Condition (7 bits) and the R/W bit. In this case the R/W bit will be
• An Acknowledge Condition logic '1'. Thus the first byte transmitted is a 7-bit slave
address followed by a '1' to indicate receive bit. Serial
9.2.7 I2C MASTER MODE SUPPORT data is received via SDA while SCL outputs the serial
clock. Serial data is received 8 bits at a time. After each
Master Mode is enabled by setting and clearing the byte is received, an acknowledge bit is transmitted.
appropriate SSPM bits in SSPCON and by setting the START and STOP conditions indicate the beginning
SSPEN bit. Once master mode is enabled, the user and end of transmission.
has six options.
The baud rate generator used for SPI mode operation
- Assert a start condition on SDA and SCL. is now used to set the SCL clock frequency for either
- Assert a Repeated Start condition on SDA and 100 kHz, 400 kHz, or 1 MHz I2C operation. The baud
SCL. rate generator reload value is contained in the lower 7
- Write to the SSPBUF register initiating trans- bits of the SSPADD register. The baud rate generator
mission of data/address. will automatically begin counting on a write to the SSP-
- Generate a stop condition on SDA and SCL. BUF. Once the given operation is complete (i.e. trans-
- Configure the I2C port to receive data. mission of the last data bit is followed by ACK) the
- Generate an Acknowledge condition at the end internal clock will automatically stop counting and the
of a received byte of data. SCL pin will remain in its last state
A typical transmit sequence would go as follows:
Note: The MSSP Module, when configured in I2C a) The user generates a Start Condition by setting
Master Mode, does not allow queueing of the START enable bit (SEN) in SSPCON2.
events. For instance: The user is not b) SSPIF is set. The module will wait the required
allowed to initiate a start condition, and start time before any other operation takes
immediately write the SSPBUF register to place.
initiate transmission before the START c) The user loads the SSPBUF with address to
condition is complete. In this case the transmit.
SSPBUF will not be written to, and the
d) Address is shifted out the SDA pin until all 8 bits
WCOL bit will be set, indicating that a write
are transmitted.
to the SSPBUF did not occur.
e) The MSSP Module shifts in the ACK bit from the
slave device, and writes its value into the
SSPCON2 register ( SSPCON2<6>).
f) The module generates an interrupt at the end of
the ninth clock cycle by setting SSPIF.
g) The user loads the SSPBUF with eight bits of
data.
h) DATA is shifted out the SDA pin until all 8 bits
are transmitted.
SDA DX DX-1
BRG decrements
(on Q2 and Q4 cycles)
BRG
03h 02h 01h 00h (hold off) 03h 02h
value
SCL
TBRG
S
SSPEN = 1,
SSPCON<3:0> = 1000
Idle Mode
SEN (SSPCON2<0> = 1)
Yes
No
Yes No No BRG
SCL= 0? SDA = 0? Rollover?
Yes Yes
Reset BRG
Force SDA = 0,
Load BRG with
SSPADD<6:0>,
Set S bit.
No No BRG
SCL = 0? rollover?
Yes
Yes
Reset BRG
Force SCL = 0,
Start Condition Done,
Clear SEN
and set SSPIF
1st Bit
SDA
Falling edge of ninth clock Write to SSPBUF occurs here.
End of Xmit
TBRG
SCL TBRG
Sr = Repeated Start
Start
Idle Mode,
B SSPEN = 1,
SSPCON<3:0> = 1000
RSEN = 1
Force SCL = 0
No
SCL = 0?
Yes
Release SDA,
Load BRG with
SSPADD<6:0>
BRG No
rollover?
Yes
Release SCL
(Clock Arbitration)
No
SCL = 1?
Yes
Bus Collision,
No
Set BCLIF, SDA = 1?
Release SDA,
Clear RSEN
Yes
C A
B
C
A
Yes
No No No BRG
SCL = 1? SDA = 0? rollover?
Yes Yes
Reset BRG
Force SDA = 0,
Load BRG with
SSPADD<6:0>
Set S
No No BRG
SCL = '0'? rollover?
Yes Yes
Force SCL = 0,
Reset BRG Repeated Start
condition done,
Clear RSEN,
Set SSPIF.
Transmission of a data byte, a 7-bit address, or either In transmit mode, the BF bit (SSPSTAT<0>) is set when
half of a 10-bit address is accomplished by simply writ- the CPU writes to SSPBUF and is cleared when all 8
ing a value to SSPBUF register. This action will set the bits are shifted out.
buffer full flag (BF) and allow the baud rate generator to
begin counting and start the next transmission. Each 9.2.11.8 WCOL STATUS FLAG
bit of address/data will be shifted out onto the SDA pin
If the user writes the SSPBUF when a transmit is
after the falling edge of SCL is asserted (see data hold
already in progress (i.e. SSPSR is still shifting out a
time spec). SCL is held low for one baud rate gener-
data byte), then WCOL is set and the contents of the
ator roll over count (TBRG). Data should be valid before
buffer are unchanged (the write doesn’t occur).
SCL is released high (see Data setup time spec).
When the SCL pin is released high, it is held that way WCOL must be cleared in software.
for TBRG, the data on the SDA pin must remain stable
9.2.11.9 ACKSTAT STATUS FLAG
for that duration and some hold time after the next fall-
ing edge of SCL. After the eighth bit is shifted out (the In transmit mode, the ACKSTAT bit (SSPCON2<6>) is
falling edge of the eighth clock), the BF flag is cleared cleared when the slave has sent an acknowledge
and the master releases SDA allowing the slave device (ACK = 0), and is set when the slave does not acknowl-
being addressed to respond with an ACK bit during the edge (ACK = 1). A slave sends an acknowledge when
ninth bit time, if an address match occurs or if data was it has recognized its address (including a general call),
received properly. The status of ACK is read into the or when the slave has properly received its data.
ACKDT on the falling edge of the ninth clock. If the
master receives an acknowledge, the acknowledge
status bit (ACKSTAT) is cleared. If not, the bit is set.
After the ninth clock the SSPIF is set, and the master
clock (baud rate generator) is suspended until the next
data byte is loaded into the SSPBUF leaving SCL low
and SDA unchanged (Figure 9-26).
After the write to the SSPBUF, each bit of address will
be shifted out on the falling edge of SCL until all seven
address bits and the R/W bit are completed. On the fall-
ing edge of the eighth clock the master will de-assert
the SDA pin allowing the slave to respond with an
acknowledge. On the falling edge of the ninth clock the
master will sample the SDA pin to see if the address
was recognized by a slave. The status of the ACK bit is
loaded into the ACKSTAT status bit (SSPCON2<6>).
Following the falling edge of the ninth clock transmis-
sion of the address, the SSPIF is set, the BF flag is
cleared, and the baud rate generator is turned off until
another write to the SSPBUF takes place, holding SCL
low and allowing SDA to float.
Idle Mode
Write SSPBUF
Num_Clocks = 0,
BF = 1
Force SCL = 0
Release SDA so
Yes
Num_Clocks slave can drive ACK,
= 8? Force BF = 0
No
Load BRG with
Load BRG with SSPADD<6:0>,
SSPADD<6:0>, start BRG count
start BRG count,
SDA = Current Data bit
BRG No
rollover?
BRG No
rollover?
Yes
Yes
Yes
Read SDA and place into
ACKSTAT bit (SSPCON2<6>)
No No No
BRG SDA = Yes
rollover? SCL = 0? Data bit?
Force SCL = 0,
Yes
Set SSPIF
Yes Reset BRG
Num_Clocks
= Num_Clocks + 1
SDA A7 A6 A5 A4 A3 A2 A1 ACK = 0 D7 D6 D5 D4 D3 D2 D1 D0
BF (SSPSTAT<0>)
Preliminary
SSPBUF written SSPBUF is written in software
SEN
PEN
R/W
FIGURE 9-26: I 2C MASTER MODE TIMING (TRANSMISSION, 7 OR 10-BIT ADDRESS)
DS30292A-page 89
PIC16F87X
PIC16F87X
9.2.12 I2C MASTER MODE RECEPTION
Idle mode
RCEN = 1
Num_Clocks = 0,
Release SDA
Force SCL=0,
Load BRG w/
SSPADD<6:0>,
start count
BRG No
rollover?
Yes
Release SCL
(Clock Arbitration)
No
SCL = 1?
Yes
Sample SDA,
Shift data into SSPSR
BRG No SCL = 0? No
rollover?
Yes Yes
Num_Clocks
= Num_Clocks + 1
No
Num_Clocks
= 8?
Yes
Force SCL = 0,
Set SSPIF,
Set BF.
Move contents of SSPSR
into SSPBUF,
Clear RCEN.
Bus Master
ACK is not sent terminates
transfer
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SCL S P
Data shifted in on falling edge of CLK Set SSPIF at end
of receive Set SSPIF interrupt
Set SSPIF interrupt at end of acknow-
Set SSPIF interrupt ledge sequence
at end of receive
at end of acknowledge
SSPIF sequence
Set P bit
Cleared in software Cleared in software Cleared in software Cleared in software (SSPSTAT<4>)
SDA = 0, SCL = 1 Cleared in
while CPU software and SSPIF
responds to SSPIF
BF
(SSPSTAT<0>) Last bit is shifted into SSPSR and
contents are unloaded into SSPBUF
SSPOV
FIGURE 9-28: I 2C MASTER MODE TIMING (RECEPTION 7-BIT ADDRESS)
ACKEN
Tbrg Tbrg
SDA D0 ACK
SCL 8 9
SSPIF
Idle mode
Set ACKEN
Force SCL = 0
BRG Yes
rollover?
No
No
SCL = 0?
Yes
No BRG
rollover?
Yes
SDA = 1?
Yes
No
Force SCL = 1
Yes
SDA ACK
P
TBRG TBRG TBRG
SCL brought high after TBRG
Idle Mode,
SSPEN = 1,
SSPCON<3:0> = 1000
Force SDA = 0
SCL doesn’t change
BRG No
rollover?
Yes
No
SDA = 0? Release SDA,
Start BRG
Yes
Start BRG
BRG No
rollover?
BRG No Yes
rollover?
Bus Collision detected,
No
Yes P bit Set? Set BCLIF,
Clear PEN
De-assert SCL,
SCL = 1
Yes
Yes
Clock arbitration occurs when the master, during any While in sleep mode, the I2C module can receive
receive, transmit, or repeated start/stop condition, de- addresses or data, and when an address match or
asserts the SCL pin (SCL allowed to float high). When complete byte transfer occurs wake the processor from
the SCL pin is allowed to float high, the baud rate gen- sleep ( if the SSP interrupt is enabled).
erator (BRG) is suspended from counting until the SCL
pin is actually sampled high. When the SCL pin is sam- 9.2.17 EFFECTS OF A RESET
pled high, the baud rate generator is reloaded with the
A reset disables the SSP module and terminates the
contents of SSPADD<6:0> and begins counting. This
current transfer.
ensures that the SCL high time will always be at least
one BRG rollover count in the event that the clock is
held low by an external device (Figure 9-33).
SCL
SDA
SDA
BCLIF
SDA
SCL
Set SEN, enable start SEN cleared automatically because of bus collision.
condition if SDA = 1, SCL=1 SSP module reset into idle state.
SEN
SDA sampled low before
START condition. Set BCLIF.
S bit and SSPIF set because
BCLIF SDA = 0, SCL = 1
SSPIF and BCLIF are
cleared in software.
SSPIF
SDA = 0, SCL = 1
TBRG TBRG
SDA
FIGURE 9-37: BRG RESET DUE TO SDA COLLISION DURING START CONDITION
SDA = 0, SCL = 1
Set S Set SSPIF
Less than TBRG
TBRG
SCL S
SCL pulled low after BRG
Timeout
SEN
Set SEN, enable start
sequence if SDA = 1, SCL = 1
BCLIF '0'
SSPIF
SDA = 0, SCL = 1 Interrupts cleared
Set SSPIF in software.
SDA
SCL
RSEN
BCLIF
Cleared in software
S '0' '0'
TBRG TBRG
SDA
SCL
S '0' '0'
PEN
BCLIF
P '0' '0'
SDA
Assert SDA SCL goes low before SDA goes high
Set BCLIF
SCL
PEN
BCLIF
P '0'
SSPIF '0'
Rp Rp DEVICE
Rs Rs
SDA
SCL
Cb=10 - 400 pF
NOTE: I2C devices with input levels related to VDD must have one common supply
line to which the pull up resistor is also connected.
The Universal Synchronous Asynchronous Receiver Bit SPEN (RCSTA<7>), and bits TRISC<7:6>, have to
Transmitter (USART) module is one of the two serial be set in order to configure pins RC6/TX/CK and RC7/
I/O modules. (USART is also known as a Serial Com- RX/DT as the Universal Synchronous Asynchronous
munications Interface or SCI). The USART can be con- Receiver Transmitter.
figured as a full duplex asynchronous system that can The USART module also has a multi-processor com-
communicate with peripheral devices such as CRT ter- munication capability using 9-bit address detection.
minals and personal computers, or it can be configured
as a half duplex synchronous system that can commu-
nicate with peripheral devices such as A/D or D/A inte-
grated circuits, Serial EEPROMs etc.
FIGURE 10-1: TXSTA: TRANSMIT STATUS AND CONTROL REGISTER (ADDRESS 98h)
10.1.1 SAMPLING
Value on
Value on:
all
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR,
other
BOR
resets
98h TXSTA CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 0000 -010
18h RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 0000 000x
99h SPBRG Baud Rate Generator Register 0000 0000 0000 0000
Legend: x = unknown, - = unimplemented read as '0'. Shaded cells are not used by the BRG.
• Baud Rate Generator 1. Initialize the SPBRG register for the appropriate
baud rate. If a high speed baud rate is desired,
• Sampling Circuit
set bit BRGH. (Section 10.1)
• Asynchronous Transmitter
2. Enable the asynchronous serial port by clearing
• Asynchronous Receiver bit SYNC and setting bit SPEN.
10.2.1 USART ASYNCHRONOUS TRANSMITTER 3. If interrupts are desired, then set enable bit
TXIE.
The USART transmitter block diagram is shown in 4. If 9-bit transmission is desired, then set transmit
Figure 10-3. The heart of the transmitter is the transmit bit TX9.
(serial) shift register (TSR). The shift register obtains its
5. Enable the transmission by setting bit TXEN,
data from the read/write transmit buffer, TXREG. The
which will also set bit TXIF.
TXREG register is loaded with data in software. The
TSR register is not loaded until the STOP bit has been 6. If 9-bit transmission is selected, the ninth bit
transmitted from the previous load. As soon as the should be loaded in bit TX9D.
STOP bit is transmitted, the TSR is loaded with new 7. Load data to the TXREG register (starts trans-
data from the TXREG register (if available). Once the mission).
TXREG register transfers the data to the TSR register
TX9
Baud Rate Generator
TX9D
Write to TXREG
Word 1
BRG output
(shift clock)
RC6/TX/CK (pin)
Start Bit Bit 0 Bit 1 Bit 7/8 Stop Bit
WORD 1
TXIF bit
(Transmit buffer
reg. empty flag)
WORD 1
TRMT bit Transmit Shift Reg
(Transmit shift
reg. empty flag)
Write to TXREG
Word 1 Word 2
BRG output
(shift clock)
RC6/TX/CK (pin)
Start Bit Bit 0 Bit 1 Bit 7/8 Stop Bit Start Bit Bit 0
TXIF bit
(interrupt reg. flag) WORD 1 WORD 2
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
18h RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 0000 000x
98h TXSTA CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 0000 -010
99h SPBRG Baud Rate Generator Register 0000 0000 0000 0000
Legend: x = unknown, - = unimplemented locations read as '0'. Shaded cells are not used for Asynchronous Transmission.
Note 1: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
SPBRG
∏ 64 MSb RSR register LSb
or
∏ 16
Baud Rate Generator Stop (8) 7 ∑ ∑ ∑ 1 0 Start
RC7/RX/DT
Pin Buffer Data
and Control Recovery RX9
SPEN
RX9 Enable
ADDEN Load of
RX9 Receive
Buffer
ADDEN
RSR<8> 8
Interrupt RCIF
Data Bus
RCIE
Load RSR
Bit8 = 0, Data Byte Bit8 = 1, Address Byte WORD 1
RCREG
Read
RCIF
Note: This timing diagram shows a data byte followed by an address byte. The data byte is not read into the RCREG (receive buffer)
because ADDEN = 1.
Load RSR
Bit8 = 1, Address Byte Bit8 = 0, Data Byte WORD 1
RCREG
Read
RCIF
Note: This timing diagram shows an address byte followed by a data byte. The data byte is not read into the RCREG (receive buffer)
because ADEN was not updated and still = 0.
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
18h RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 0000 000x
1Ah RCREG USART Receive Register 0000 0000 0000 0000
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
98h TXSTA CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 0000 -010
99h SPBRG Baud Rate Generator Register 0000 0000 0000 0000
Legend: x = unknown, - = unimplemented locations read as '0'. Shaded cells are not used for Asynchronous Reception.
Note 1: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
Value on:
Value on all
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR,
other Resets
BOR
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
18h RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 0000 000x
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
98h TXSTA CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 0000 -010
Q1Q2 Q3Q4 Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2 Q3Q4 Q3Q4 Q1Q2 Q3Q4 Q1Q2 Q3Q4 Q1Q2 Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4
Write to
TXREG reg
Write word1 Write word2
TXIF bit
(Interrupt flag)
TRMT
TRMT bit
'1' '1'
TXEN bit
Note: Sync master mode; SPBRG = '0'. Continuous transmission of two 8-bit words.
RC6/TX/CK pin
Write to
TXREG reg
TXIF bit
TRMT bit
TXEN bit
Value on:
Value on all
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR,
other Resets
BOR
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
18h RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 0000 000x
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
98h TXSTA CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 0000 -010
99h SPBRG Baud Rate Generator Register 0000 0000 0000 0000
Legend: x = unknown, - = unimplemented read as '0'. Shaded cells are not used for Synchronous Master Reception.
Note 1: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
RC7/RX/DT pin bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7
RC6/TX/CK pin
Write to
bit SREN
SREN bit
CREN bit '0' '0'
RCIF bit
(interrupt)
Read
RXREG
Note: Timing diagram demonstrates SYNC master mode with bit SREN = '1' and bit BRGH = '0'.
Value on:
Value on all
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR,
other Resets
BOR
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
18h RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 0000 000x
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
98h TXSTA CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 0000 -010
99h SPBRG Baud Rate Generator Register 0000 0000 0000 0000
Legend: x = unknown, - = unimplemented read as '0'. Shaded cells are not used for Synchronous Slave Transmission.
Note 1: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
Value on:
Value on all
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 POR,
other Resets
BOR
0Ch PIR1 PSPIF(1) ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
18h RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 0000 000x
98h TXSTA CSRC TX9 TXEN SYNC — BRGH TRMT TX9D 0000 -010 0000 -010
99h SPBRG Baud Rate Generator Register 0000 0000 0000 0000
Legend: x = unknown, - = unimplemented read as '0'. Shaded cells are not used for Synchronous Slave Reception.
Note 1: Bits PSPIE and PSPIF are reserved on the 28-pin devices, always maintain these bits clear.
PCFG3: AN7(1) AN6(1) AN5(1) AN4 AN3 AN2 AN1 AN0 CHAN /
VREF+ VREF-
PCFG0 RE2 RE1 RE0 RA5 RA3 RA2 RA1 RA0 REFS
0000 A A A A A A A A VDD VSS 8/0
0001 A A A A VREF+ A A A RA3 VSS 7/1
0010 D D D A A A A A VDD VSS 5/0
0011 D D D A VREF+ A A A RA3 VSS 4/1
0100 D D D D A D A A VDD VSS 3/0
0101 D D D D VREF+ D A A RA3 VSS 2/1
011x D D D D D D D D VDD VSS 0/0
1000 A A A A VREF+ VREF- A A RA3 RA2 6/2
1001 D D A A A A A A VDD VSS 6/0
1010 D D A A VREF+ A A A RA3 VSS 5/1
1011 D D A A VREF+ VREF- A A RA3 RA2 4/2
1100 D D D A VREF+ VREF- A A RA3 RA2 3/2
1101 D D D D VREF+ VREF- A A RA3 RA2 2/2
1110 D D D D D D D A VDD VSS 1/0
1111 D D D D VREF+ VREF- D A RA3 RA2 1/2
A = Analog input
D = Digital I/O
Note 1: These channels are not available on the 28-pin devices.
111
RE2/AN7(1)
110
RE1/AN6(1)
101
RE0/AN5(1)
100
RA5/AN4
VAIN
(Input voltage) 011
RA3/AN3/VREF+
010
A/D RA2/AN2/VREF-
Converter
001
RA1/AN1
VDD 000
RA0/AN0
X000 or
VREF+ X010 or
X100
(Reference
voltage) X001 or
X011 or
X101
PCFG3:PCFG0
00XX or 0X0X or
1000 or 1010 or
1100
VREF-
1001 or
(Reference 1011 or
voltage) 1101
VSS
PCFG3:PCFG0
Note 1: Not available on 28-pin devices.
Note 1: The reference voltage (VREF) has no effect on the equation, since it cancels itself out.
Note 2: The charge holding capacitor (CHOLD) is not discharged after each conversion.
Note 3: The maximum recommended impedance for analog sources is 10 kΩ. This is required to meet the pin leak-
age specification.
Note 4: After a conversion has completed, a 2.0TAD delay must complete before acquisition can begin again. Dur-
ing this time the holding capacitor is not connected to the selected A/D input channel.
CHOLD
VA CPIN I leakage = DAC capacitance
5 pF VT = 0.6V ± 500 nA = 120 pF
VSS
Tcy to TAD TAD1 TAD2 TAD3 TAD4 TAD5 TAD6 TAD7 TAD8 TAD9 TAD10 TAD11
b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
Conversion Starts
Holding capacitor is disconnected from analog input (typically 100 ns)
Set GO bit
Next Q4: ADRES is loaded,
GO bit is cleared,
ADIF bit is set,
holding capacitor is connected to analog input.
Yes
ADON = 0?
No
Acquire
Selected Channel
Yes
GO = 0?
No
No No
No No
Wait 2TAD
11.4.1 A/D RESULT REGISTERS SLEEP. If the A/D interrupt is not enabled, the A/D mod-
ule will then be turned off, although the ADON bit will
The ADRESH:ADRESL register pair is the location remain set.
where the 10-bit A/D result is loaded at the completion
of the A/D conversion. This register pair is 16-bits wide. When the A/D clock source is another clock option (not
The A/D module gives the flexibility to left or right justify RC), a SLEEP instruction will cause the present conver-
the 10-bit result in the 16-bit result register. The A/D sion to be aborted and the A/D module to be turned off,
Format Select bit (ADFM) controls this justification. though the ADON bit will remain set.
Figure 11-8 shows the operation of the A/D result justi- Turning off the A/D places the A/D module in its lowest
fication. The extra bits are loaded with ’0’s’. When an current consumption state.
A/D result will not overwrite these locations (A/D dis-
Note: For the A/D module to operate in SLEEP,
able), these registers may be used as two general pur-
the A/D clock source must be set to RC
pose 8-bit registers.
(ADCS1:ADCS0 = 11). To allow the con-
11.5 A/D Operation During Sleep version to occur during SLEEP, ensure the
SLEEP instruction immediately follows the
The A/D module can operate during SLEEP mode. This instruction that sets the GO/DONE bit.
requires that the A/D clock source be set to RC
(ADCS1:ADCS0 = 11). When the RC clock source is
selected, the A/D module waits one instruction cycle
before starting the conversion. This allows the SLEEP
instruction to be executed, which eliminates all digital
switching noise from the conversion. When the conver-
sion is completed the GO/DONE bit will be cleared, and
the result loaded into the ADRES register. If the A/D
interrupt is enabled, the device will wake-up from
10-Bit Result
ADFM = 1 ADFM = 0
7 2107 0 7 0765 0
0000 00 0000 00
11.7 A/D Accuracy/Error full scale error is that full scale does not take offset error
into account. Gain error can be calibrated out in soft-
In systems where the device frequency is low, use of ware.
the A/D RC clock is preferred. At moderate to high fre-
Linearity error refers to the uniformity of the code
quencies, TAD should be derived from the device oscil-
changes. Linearity errors cannot be calibrated out of
lator.
the system. Integral non-linearity error measures the
The absolute accuracy specified for the A/D converter actual code transition versus the ideal code transition
includes the sum of all contributions for quantization adjusted by the gain error for each code.
error, integral error, differential error, full scale error, off-
Differential non-linearity measures the maximum
set error, and monotonicity. It is defined as the maxi-
actual code width versus the ideal code width. This
mum deviation from an actual transition versus an ideal
measure is unadjusted.
transition for any code. The absolute error of the A/D
converter is specified at < ±1 LSb for VDD = VREF (over The maximum pin leakage current is specified in the
the device’s specified operating range). However, the Device Data Sheet electrical specification parameter
accuracy of the A/D converter will degrade as VREF #D060.
diverges from VDD. In systems where the device frequency is low, use of
For a given range of analog inputs, the output digital the A/D RC clock is preferred. At moderate to high fre-
code will be the same. This is due to the quantization of quencies, TAD should be derived from the device oscil-
the analog input to a digital code. Quantization error is lator. TAD must not violate the minimum and should be
typically ± 1/2 LSb and is inherent in the analog to dig- minimized to reduce inaccuracies due to noise and
ital conversion process. The only way to reduce quanti- sampling capacitor bleed off.
zation error is to increase the resolution of the A/D In systems where the device will enter SLEEP mode
converter or oversample. after the start of the A/D conversion, the RC clock
Offset error measures the first actual transition of a source selection is required. In this mode, the digital
code versus the first ideal transition of a code. Offset noise from the modules in SLEEP are stopped. This
error shifts the entire transfer function. Offset error can method gives high accuracy.
be calibrated out of a system or introduced into a sys-
tem through the interaction of the total leakage current
and source impedance at the analog input.
Gain error measures the maximum deviation of the last
actual transition and the last ideal transition adjusted
for offset error. This error appears as a change in slope
of the transfer function. The difference in gain error to
1022.5 LSb
1023.5 LSb
1022 LSb
1023 LSb
0.5 LSb
1.5 LSb
2.5 LSb
(VAIN) equals Analog VREF / 1024 (Figure 11-9).
1 LSb
2 LSb
3 LSb
Analog input voltage
11.10 References
A good reference for the undestanding A/D converter is
the "Analog-Digital Conversion Handbook" third edi-
tion, published by Prentice Hall (ISBN 0-13-03-2848-0).
POR,
Addr Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 MCLR, WDT
BOR
0Bh INTCON GIE PEIE T0IE INTE RBIE T0IF INTF RBIF 0000 000x 0000 000u
(1)
0Ch PIR1 PSPIF ADIF RCIF TXIF SSPIF CCP1IF TMR2IF TMR1IF 0000 0000 0000 0000
8Ch PIE1 PSPIE(1) ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE 0000 0000 0000 0000
1Eh ADRESH A/D Result Register High Byte xxxx xxxx uuuu uuuu
1Fh ADCON0 ADCS1 ADCS0 CHS2 CHS1 CHS0 GO/DONE — ADON 0000 00-0 0000 00-0
9Fh ADCON1 ADFM — — — PCFG3 PCFG2 PCFG1 PCFG0 --0- 0000 --0- 0000
85h TRISA — — PORTA Data Direction Register --11 1111 --11 1111
05h PORTA — — PORTA Data Latch when written: PORTA pins when read --0x 0000 --0u 0000
89h(1) TRISE IBF OBF IBOV PSPMODE — PORTE Data Direction Bits 0000 -111 0000 -111
CP1 CP0 BKBUG - WRT CPD LVP BODEN CP1 CP0 PWRTE WDTE F0SC1 F0SC0 Register: CONFIG
bit13 bit0 Address 2007h
bit 13-12:
bit 5-4: CP1:CP0: Flash Program Memory Code Protection bits (2)
11 = Code protection off
10 = 1F00h to 1FFFh code protected (PIC16F877, 876)
10 = 0F00h to 0FFFh code protected (PIC16F874, 873)
01 = 1000h to 1FFFh code protected (PIC16F877, 876)
01 = 0800h to 0FFFh code protected (PIC16F874, 873)
00 = 0000h to 1FFFh code protected (PIC16F877, 876)
00 = 0000h to 0FFFh code protected (PIC16F874, 873)
bit 11: DEBUG: In-Circuit Debugger Mode
1 = In-Circuit Debugger disabled, RB6 and RB7 are general purpose I/O pins.
0 = In-Circuit Debugger enabled, RB6 and RB7 are dedicated to the debugger.
bit 10: Unimplemented: Read as ‘1’
bit 9: WRT: Flash Program Memory Write Enable
1 = Unprotected program memory may be written to by EECON control
0 = Unprotected program memory may not be written to by EECON control
bit 8: CPD: Data EE Memory Code Protection
1 = Code protection off
0 = Data EEPROM memory code protected
bit 7: LVP: Low voltage programming Enable bit
1 = RB3/PGM pin has PGM function, low voltage programming enabled
0 = RB3 is digital I/O, HV on MCLR must be used for programming
bit 6: BODEN: Brown-out Reset Enable bit (1)
1 = BOR enabled
0 = BOR disabled
bit 3: PWRTE: Power-up Timer Enable bit (1)
1 = PWRT disabled
0 = PWRT enabled
bit 2: WDTE: Watchdog Timer Enable bit
1 = WDT enabled
0 = WDT disabled
bit 1-0: FOSC1:FOSC0: Oscillator Selection bits
11 = RC oscillator
10 = HS oscillator
01 = XT oscillator
00 = LP oscillator
Note 1: Enabling Brown-out Reset automatically enables Power-up Timer (PWRT) regardless of the value of bit PWRTE.
Ensure the Power-up Timer is enabled anytime Brown-out Reset is enabled.
2: All of the CP1:CP0 pairs have to be given the same value to enable the code protection scheme listed.
MCLR
SLEEP
WDT WDT
Module Time-out
Reset
Vdd rise
detect
Power-on Reset
Vdd
Brown-out
Reset S
BODEN
OST/PWRT
OST
Chip_Reset
10-bit Ripple counter R Q
OSC1
(1) PWRT
On-chip
RC OSC 10-bit Ripple counter
Enable PWRT
Enable OST
Note 1: This is a separate oscillator from the RC oscillator of the CLKIN pin.
POR BOR TO PD
0 x 1 1 Power-on Reset
0 x 0 x Illegal, TO is set on POR
0 x x 0 Illegal, PD is set on POR
1 0 1 1 Brown-out Reset
1 1 0 1 WDT Reset
1 1 0 0 WDT Wake-up
1 1 u u MCLR Reset during normal operation
1 1 1 0 MCLR Reset during SLEEP or interrupt wake-up from SLEEP
Vdd
MCLR
INTERNAL POR
Tpwrt
OST TIME-OUT
INTERNAL RESET
Vdd
MCLR
INTERNAL POR
Tpwrt
OST TIME-OUT
INTERNAL RESET
FIGURE 12-9: TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD): CASE 2
Vdd
MCLR
INTERNAL POR
Tpwrt
OST TIME-OUT
INTERNAL RESET
Vdd 0V 1V
MCLR
INTERNAL POR
Tpwrt
PWRT TIME-OUT
Tost
OST TIME-OUT
INTERNAL RESET
EEIF
EEIE
PSPIF
PSPIE
ADIF Wake-up (If in SLEEP mode)
T0IF
ADIE T0IE
RCIF INTF
RCIE INTE
Interrupt to CPU
TXIF RBIF
TXIE RBIE
SSPIF
SSPIE
PEIE
CCP1IF
CCP1IE GIE
TMR2IF
TMR2IE
TMR1IF
TMR1IE
CCP2IF
CCP2IE
BCLIF
BCLIE
0
M Postscaler
1
WDT Timer U
X 8
8 - to - 1 MUX PS2:PS0
PSA
WDT
Enable Bit
To TMR0 (Figure 5-2)
0 1
MUX PSA
WDT
Note: PSA and PS2:PS0 are bits in the OPTION_REG register. Time-out
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
2007h Config. bits (1) BODEN(1) CP1 CP0 PWRTE(1) WDTE FOSC1 FOSC0
81h,181h OPTION_REG RBPU INTEDG T0CS T0SE PSA PS2 PS1 PS0
Legend: Shaded cells are not used by the Watchdog Timer.
Note 1: See Figure 12-1 for operation of these bits.
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
CLKOUT(4) Tost(2)
INT pin
INTF flag
(INTCON<1>) Interrupt Latency
(Note 2)
GIE bit Processor in
(INTCON<7>)
SLEEP
INSTRUCTION FLOW
PC PC PC+1 PC+2 PC+2 PC + 2 0004h 0005h
Instruction Inst(PC + 1) Inst(PC + 2) Inst(0004h) Inst(0005h)
fetched Inst(PC) = SLEEP
Instruction SLEEP Inst(PC + 1) Dummy cycle Dummy cycle
executed Inst(PC - 1) Inst(0004h)
The MPLAB-ICE Universal In-Circuit Emulator is 14.5 PICSTART Plus Entry Level
intended to provide the product development engineer Development System
with a complete microcontroller design tool set for
PICmicro microcontrollers (MCUs). MPLAB-ICE is sup- The PICSTART programmer is an easy-to-use, low-
plied with the MPLAB Integrated Development Environ- cost prototype programmer. It connects to the PC via
ment (IDE), which allows editing, “make” and one of the COM (RS-232) ports. MPLAB Integrated
download, and source debugging from a single envi- Development Environment software makes using the
ronment. programmer simple and efficient. PICSTART Plus is
not recommended for production programming.
Interchangeable processor modules allow the system
to be easily reconfigured for emulation of different pro- PICSTART Plus supports all PIC12CXXX, PIC14C000,
cessors. The universal architecture of the MPLAB-ICE PIC16C5X, PIC16CXXX and PIC17CXX devices with
allows expansion to support all new Microchip micro- up to 40 pins. Larger pin count devices such as the
controllers. PIC16C923, PIC16C924 and PIC17C756 may be sup-
ported with an adapter socket. PICSTART Plus is CE
The MPLAB-ICE Emulator System has been designed compliant.
as a real-time emulation system with advanced fea-
tures that are generally found on more expensive 14.6 SIMICE Entry-Level Hardware
development tools. The PC compatible 386 (and higher) Simulator
machine platform and Microsoft Windows 3.x or
Windows 95 environment were chosen to best make SIMICE is an entry-level hardware development sys-
these features available to you, the end user. tem designed to operate in a PC-based environment
MPLAB-ICE is available in two versions. with Microchip’s simulator MPLAB™-SIM. Both SIM-
MPLAB-ICE 1000 is a basic, low-cost emulator system ICE and MPLAB-SIM run under Microchip Technol-
with simple trace capabilities. It shares processor mod- ogy’s MPLAB Integrated Development Environment
ules with the MPLAB-ICE 2000. This is a full-featured (IDE) software. Specifically, SIMICE provides hardware
emulator system with enhanced trace, trigger, and data simulation for Microchip’s PIC12C5XX, PIC12CE5XX,
monitoring features. Both systems will operate across and PIC16C5X families of PICmicro 8-bit microcontrol-
the entire operating speed reange of the PICmicro lers. SIMICE works in conjunction with MPLAB-SIM to
MCU. provide non-real-time I/O port emulation. SIMICE
enables a developer to run simulator code for driving
the target system. In addition, the target system can
TABLE 14-1
PIC16F87X
24CXX HCS200
PIC12C5XX PIC14000 PIC16C5X PIC16CXXX PIC16C6X PIC16C7XX PIC16C8X PIC16C9XX PIC17C4X PIC17C7XX 25CXX HCS300
93CXX HCS301
Emulator Products
ü ü ü ü ü ü ü ü ü ü
ICEPIC Low-Cost
In-Circuit Emulator ü ü ü ü ü ü
MPLAB
Integrated
Development ü ü ü ü ü ü ü ü ü ü
Environment
Software Tools
MPLAB C17*
Compiler ü ü
fuzzyTECH-MP
Preliminary
Explorer/Edition
Fuzzy Logic ü ü ü ü ü ü ü ü ü
Dev. Tool
Total Endurance
Software Model ü
PICSTARTPlus
Low-Cost ü ü ü ü ü ü ü ü ü ü
Programmers
SEEVAL
1998 Microchip Technology Inc.
Designers Kit ü
SIMICE ü ü
PICDEM-14A ü
Demo Boards
PICDEM-1 ü ü ü ü
PICDEM-2 ü ü
PICDEM-3 ü
KEELOQ®
Evaluation Kit ü
KEELOQ
Transponder Kit ü
PIC16F87X
15.0 ELECTRICAL CHARACTERISTICS
Absolute Maximum Ratings †
Ambient temperature under bias................................................................................................................ .-55 to +125˚C
Storage temperature .............................................................................................................................. -65˚C to +150˚C
Voltage on any pin with respect to VSS (except VDD, MCLR. and RA4).......................................... -0.3V to (VDD + 0.3V)
Voltage on VDD with respect to VSS ........................................................................................................... -0.3 to +7.5V
Voltage on MCLR with respect to VSS (Note 2)..................................................................................................0 to +14V
Voltage on RA4 with respect to Vss ..................................................................................................................0 to +8.5V
Total power dissipation (Note 1)................................................................................................................................1.0W
Maximum current out of VSS pin ...........................................................................................................................300 mA
Maximum current into VDD pin ..............................................................................................................................250 mA
Input clamp current, IIK (VI < 0 or VI > VDD).....................................................................................................................± 20 mA
Output clamp current, IOK (VO < 0 or VO > VDD) .............................................................................................................± 20 mA
Maximum output current sunk by any I/O pin..........................................................................................................25 mA
Maximum output current sourced by any I/O pin ....................................................................................................25 mA
Maximum current sunk by PORTA, PORTB, and PORTE (combined) (Note 3)....................................................200 mA
Maximum current sourced by PORTA, PORTB, and PORTE (combined) (Note 3) ..............................................200 mA
Maximum current sunk by PORTC and PORTD (combined) (Note 3) ..................................................................200 mA
Maximum current sourced by PORTC and PORTD (combined) (Note 3).............................................................200 mA
Note 1: Power dissipation is calculated as follows: Pdis = VDD x {IDD - ∑ IOH} + ∑ {(VDD - VOH) x IOH} + ∑(VOl x IOL)
Note 2: Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up. Thus,
a series resistor of 50-100Ω should be used when applying a “low” level to the MCLR pin rather than pulling
this pin directly to VSS.
Note 3: PORTD and PORTE are not implemented on the 28-pin devices.
† NOTICE: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at those or any other conditions above those
indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for
extended periods may affect device reliability.
Note: This is an advanced copy of the data sheet and therefore the contents and specifications are subject to
change based on device characterization.
D041 with Schmitt Trigger buffer 0.8VDD - VDD V For entire VDD range
D042 MCLR 0.8VDD - VDD V
D042A OSC1 (XT, HS and LP) 0.7VDD - VDD V Note1
D043 OSC1 (in RC mode) 0.9VDD - VDD V
Ports RC3 and RC4
D044 with Schmitt Trigger buffer 0.7VDD - VDD V For entire VDD range
D044A with SMBus 1.4 - 5.5 V for VDD = 4.5 to 5.5V
D070 PORTB weak pull-up current IPURB 50 250 400 µA VDD = 5V, VPIN = VSS
Input Leakage Current
(Notes 2, 3)
D060 I/O ports IIL - - ±1 µA Vss ≤ VPIN ≤ VDD, Pin at hi-imped-
ance
D061 MCLR, RA4/T0CKI - - ±5 µA Vss ≤ VPIN ≤ VDD
D063 OSC1 - - ±5 µA Vss ≤ VPIN ≤ VDD, XT, HS and LP osc
configuration
*These parameters are characterized but not tested.
†Data in “Typ” column is at 5V, 25°C unless otherwise stated. These parameters are for design guidance only
and are not tested.
Note 1: In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended that the
PIC16F87X be driven with external clock in RC mode.
2: The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels
represent normal operating conditions. Higher leakage current may be measured at different input voltages.
3: Negative current is defined as current sourced by the pin.
VDD/2
RL
CL CL
Pin Pin
VSS VSS
RL = 464Ω
CL = 50 pF for all pins except OSC2, but including PORTD and PORTE outputs as
ports
15 pF for OSC2 output
Note: PORTD and PORTE are not implemented on the 28-pin devices.
OSC1
1 3 3 4 4
2
CLKOUT
Q4 Q1 Q2 Q3
OSC1
10 11
CLKOUT
13 12
19 18
14 16
I/O Pin
(input)
17 15
20, 21
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out 32
OSC
Time-out
Internal
RESET
Watchdog
Timer
RESET
31
34
34
I/O Pins
VDD BVDD
35
TABLE 15-4 RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER,
AND BROWN-OUT RESET REQUIREMENTS
Parameter Sym Characteristic Min Typ† Max Units Conditions
No.
30 TmcL MCLR Pulse Width (low) 2 — — µs VDD = 5V, -40˚C to +125˚C
31* Twdt Watchdog Timer Time-out Period 7 18 33 ms VDD = 5V, -40˚C to +125˚C
(No Prescaler)
32 Tost Oscillation Start-up Timer Period — 1024TOSC — — TOSC = OSC1 period
33* Tpwrt Power up Timer Period 28 72 132 ms VDD = 5V, -40˚C to +125˚C
34 TIOZ I/O Hi-impedance from MCLR Low — — 2.1 µs
or Watchdog Timer Reset
35 TBOR Brown-out Reset pulse width 100 — — µs VDD ≤ BVDD (D005)
* These parameters are characterized but not tested.
† Data in "Typ" column is at 5V, 25˚C unless otherwise stated. These parameters are for design guidance only and are not
tested.
RA4/T0CKI
40 41
42
RC0/T1OSO/T1CKI
45 46
47 48
TMR0 or
TMR1
RC1/T1OSI/CCP2
and RC2/CCP1
(Capture Mode)
50 51
52
RC1/T1OSI/CCP2
and RC2/CCP1
(Compare or PWM Mode)
53 54
RE2/CS
RE0/RD
RE1/WR
65
RD7:RD0
62
64
63
Note: Refer to Figure 15-1 for load conditions.
SS
70
SCK
(CKP = 0)
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76
SS
81
SCK
(CKP = 0)
71 72
79
73
SCK
(CKP = 1)
80
78
75, 76
74
SS
70
SCK
(CKP = 0) 83
71 72
78 79
SCK
(CKP = 1)
79 78
80
75, 76 77
74
73
Refer to Figure 15-1 for load conditions.
82
SS
70
SCK 83
(CKP = 0)
71 72
SCK
(CKP = 1)
80
75, 76 77
SDI
MSb IN BIT6 - - - -1 LSb IN
74
SCL
91 93
90 92
SDA
START STOP
Condition Condition
SDA
Out
Note: Refer to Figure 15-1 for load conditions.
RC6/TX/CK
pin 121
121
RC7/RX/DT
pin
120
122
Note: Refer to Figure 15-1 for load conditions.
RC6/TX/CK
pin 125
RC7/RX/DT
pin
126
ADIF
GO DONE
SAMPLING STOPPED
SAMPLE
Note 1: If the A/D clock source is selected as RC, a time of TCY is added before the A/D clock starts. This allows the
SLEEP instruction to be executed.
MMMMMMMMMMMMMMMMMMMM PIC16F876-04/SO
XXXXXXXXXXXXXXXXXXXXXXXXX
AABBCDE 9810/SAA
* Standard OTP marking consists of Microchip part number, year code, week code, facility code, mask
rev#, and assembly code. For OTP marking beyond this, certain price adders apply. Please check with
your Microchip Sales Office. For QTP devices, any special marking adders are included in QTP price.
MMMMMMMM PIC16F877
XXXXXXXXXX -04/PT
XXXXXXXXXX
AABBCDE 9811HAT
MMMMMMMM PIC16F877
XXXXXXXXXX -20/PQ
XXXXXXXXXX
AABBCDE 9804SAT
MMMMMMMM PIC16F877
XXXXXXXXXX -20/L
XXXXXXXXXX
AABBCDE 9803SAT
2
α
n 1
E1 A1
R L
c
β A2 B1
eB B p
E1
E
p
B
2
n 1
X
α
45 ° L
R2
c
A
A1
R1 φ
β L1 A2
2 α
n 1
E1 A1
A
R L
c
β B1
A2
eB B p
D D1
2
1
B
n
X x 45°
α
L A
R2
c
R1 φ A1
β L1 A2
D D1
2
1
B
n
X x 45°
α
L
R2
c A
R1
β φ A1
L1 A2
E1
E
# leads = n1
D D1
n12 α
CH2 x 45° CH1 x 45° A3
R1 L
A
A1 35°
B1
c R2
B
β A2
p
E2 D2
Units INCHES* MILLIMETERS
Dimension Limits MIN NOM MAX MIN NOM MAX
Number of Pins n 44 44
Pitch p 0.050 1.27
Overall Pack. Height A 0.165 0.173 0.180 4.19 4.38 4.57
Shoulder Height A1 0.095 0.103 0.110 2.41 2.60 2.79
Standoff A2 0.015 0.023 0.030 0.38 0.57 0.76
Side 1 Chamfer Dim. A3 0.024 0.029 0.034 0.61 0.74 0.86
Corner Chamfer (1) CH1 0.040 0.045 0.050 1.02 1.14 1.27
Corner Chamfer (other) CH2 0.000 0.005 0.010 0.00 0.13 0.25
Overall Pack. Width E1 0.685 0.690 0.695 17.40 17.53 17.65
Overall Pack. Length D1 0.685 0.690 0.695 17.40 17.53 17.65
Molded Pack. Width E‡ 0.650 0.653 0.656 16.51 16.59 16.66
Molded Pack. Length D‡ 0.650 0.653 0.656 16.51 16.59 16.66
Footprint Width E2 0.610 0.620 0.630 15.49 15.75 16.00
Footprint Length D2 0.610 0.620 0.630 15.49 15.75 16.00
Pins along Width n1 11 11
Lead Thickness c 0.008 0.010 0.012 0.20 0.25 0.30
Upper Lead Width B1† 0.026 0.029 0.032 0.66 0.74 0.81
Lower Lead Width B 0.015 0.018 0.021 0.38 0.46 0.53
Upper Lead Length L 0.050 0.058 0.065 1.27 1.46 1.65
Shoulder Inside Radius R1 0.003 0.005 0.010 0.08 0.13 0.25
J-Bend Inside Radius R2 0.015 0.025 0.035 0.38 0.64 0.89
Mold Draft Angle Top α 0 5 10 0 5 10
Mold Draft Angle Bottom β 0 5 10 0 5 10
* Controlling Parameter.
† Dimension “B1” does not include dam-bar protrusions. Dam-bar protrusions shall not exceed 0.003”
(0.076 mm) per side or 0.006” (0.152 mm) more than dimension “B1.”
‡ Dimensions “D” and “E” do not include mold flash or protrusions. Mold flash or protrusions shall not
exceed 0.010" (0.254 mm) per side or 0.020" (0.508 mm) more than dimensions “D” or “E.”
JEDEC equivalent:MO-047 AC
Packages 28-pin PDIP, 28-pin windowed CER- 40-pin PDIP, 40-pin windowed CER-
DIP, 28-pin SOIC, 28-pin SSOP DIP, 44-pin TQFP, 44-pin MQFP, 44-
pin PLCC
Timers 3 3
Interrupts 11 or 12 13 or 14
Communication PSP, USART, SSP (SPI, I2C Slave) PSP, USART, SSP (SPI, I2C Master/Slave)
CCP 2 2
From: Name
Company
Address
City / State / ZIP / Country
Telephone: (_______) _________ - _________ FAX: (______) _________ - _________
Application (optional):
Would you like a reply? Y N
Questions:
2. How does this document meet your hardware and software development needs?
3. Do you find the organization of this data sheet easy to follow? If not, why?
4. What additions to the data sheet do you think would enhance the structure and subject?
5. What deletions from the data sheet could be made without affecting the overall usefulness?
8. How would you improve our software, systems, and silicon products?
* JW Devices are UV erasable and can be programmed to any device configuration. JW Devices meet the electrical requirement of
each oscillator type (including LC devices).
All rights reserved. © 1998 Microchip Technology Incorporated. Printed in the USA. 12/98 Printed on recycled paper.
Information contained in this publication regarding device applications and the like is intended for suggestion only and may be superseded by updates. No representation or warranty is given and no
liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use
or otherwise. Use of Microchip’s products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or
otherwise, under any intellectual property rights. The Microchip logo and name are registered trademarks of Microchip Technology Inc. in the U.S.A. and other countries. All rights reserved. All other
trademarks mentioned herein are the property of their respective companies.