Professional Documents
Culture Documents
ECCP (Half-Bridge)
ECCP (Full-Bridge)
Program Memory
MSSP (I2C/SPI)
Data Sheet Index
CapSense (ch)
Data EEPROM
Flash (words)
Comparators
Data SRAM
SR Latch
(8/16-bit)
EUSART
Debug(1)
(bytes)
(bytes)
Timers
I/Os(2)
CCP
XLP
Device
Note: For other small form-factor package availability and marking information, please visit
http://www.microchip.com/packaging or contact your local sales office.
VDD 1 8 VSS
PIC12(L)F1840
RA5 2 7 RA0/ICSPDAT
RA4 3 6 RA1/ICSPCLK
MCLR/VPP/RA3 4 5 RA2
Comparator
Cap Sense
Reference
Modulator
SR Latch
EUSART
Interrupt
Pull-up
Timers
Basic
MSSP
ECCP
ADC
I/O
RA0 7 AN0 DACOUT CPS0 C1IN+ P1B TX SDO IOC MDOUT Y ICSPDAT
CK SS(1) ICDDAT
RA1 6 AN1 VREF CPS1 C1IN0- SRI RX SCL IOC MDMIN Y ICSPCLK
DT SCK ICPCLK
RA2 5 AN2 CPS2 C1OUT SRQ T0CKI CCP1 SDA INT/ MDCIN1 Y
P1A SDI IOC
FLT0
RA3 4 T1G(1) SS IOC Y MCLR
VPP
RA4 3 AN3 CPS3 C1IN1- T1G P1B(1) TX(1) SDO(1) IOC MDCIN2 Y OSC2
T1OSO CK(1) CLKOUT
CLKR
RA5 2 SRNQ T1CKI CCP1(1) RX(1) IOC Y OSC1
T1OSI P1A(1) DT(1) CLKIN
VDD 1 VDD
VSS 8 VSS
Note 1: Alternate pin function selected with the APFCON (Register 12-1) register.
Errata
An errata sheet, describing minor operational differences from the data sheet and recommended workarounds, may exist for current
devices. As device/documentation issues become known to us, we will publish an errata sheet. The errata will specify the revision
of silicon and revision of document to which it applies.
To determine if an errata sheet exists for a particular device, please check with one of the following:
Microchips Worldwide Web site; http://www.microchip.com
Your local Microchip sales office (see last page)
When contacting a sales office, please specify which device, revision of silicon and data sheet (include literature number) you are
using.
Peripheral PIC12(L)F1840
ADC
Capacitive Sensing (CPS) Module
Data EEPROM
Digital-to-Analog Converter (DAC)
Digital Signal Modulator (DSM)
EUSART
Fixed Voltage Reference (FVR)
SR Latch
Capture/Compare/PWM Modules
ECCP1
Comparators
C1
Master Synchronous Serial Ports
MSSP
Timers
Timer0
Timer1
Timer2
Program
Flash Memory
RAM EEPROM
CLKR
Clock
Reference
OSC2/CLKOUT Timing
Generation PORTA
OSC1/CLKIN CPU
INTRC
Oscillator
(Figure 2-1)
MCLR
SR ADC
Timer0 Timer1 10-Bit DAC Comparators
Latch
15 Configuration
15 Data Bus 8
Program Counter
Flash
MUX
Program
Memory 16-Level
8 Level Stack
Stack
RAM
(13-bit)
(15-bit)
Program
14 Program Memory 12 RAM Addr
Bus
Read (PMR)
Addr MUX
Instruction
Instruction Reg
reg Indirect
Direct Addr 7 Addr
5 12 12
15 BSR
FSR Reg
reg
FSR0reg
FSR Reg
FSR1 Reg
FSR reg
15 STATUS Reg
STATUS reg
8
3 MUX
Power-up
Timer
Instruction Oscillator
Decodeand
Decode & Start-up Timer
ALU
Control
OSC1/CLKIN Power-on
Reset 8
Timing Watchdog
OSC2/CLKOUT Generation Timer W Reg
Brown-out
Reset
Internal
Oscillator
Block
VDD VSS
Rollover to Page 1
7FFFh
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared q = Value depends on condition
Note 1: For Borrow, the polarity is reversed. A subtraction is executed by adding the twos complement of the
second operand.
6Fh
70h
Common RAM
(16 bytes)
7Fh
PIC12(L)F1840
BANK 0 BANK 1 BANK 2 BANK 3 BANK 4 BANK 5 BANK 6 BANK 7
000h 080h 100h 180h 200h 280h 300h 380h
Core Registers Core Registers Core Registers Core Registers Core Registers Core Registers Core Registers Core Registers
(Table 3-2) (Table 3-2) (Table 3-2) (Table 3-2) (Table 3-2) (Table 3-2) (Table 3-2) (Table 3-2)
00Bh 08Bh 10Bh 18Bh 20Bh 28Bh 30Bh 38Bh
00Ch PORTA 08Ch TRISA 10Ch LATA 18Ch ANSELA 20Ch WPUA 28Ch 30Ch 38Ch
00Dh 08Dh 10Dh 18Dh 20Dh 28Dh 30Dh 38Dh
00Eh 08Eh 10Eh 18Eh 20Eh 28Eh 30Eh 38Eh
00Fh 08Fh 10Fh 18Fh 20Fh 28Fh 30Fh 38Fh
010h 090h 110h 190h 210h 290h 310h 390h
011h PIR1 091h PIE1 111h CM1CON0 191h EEADRL 211h SSPBUF 291h CCPR1L 311h 391h IOCAP
012h PIR2 092h PIE2 112h CM1CON1 192h EEADRH 212h SSPADD 292h CCPR1H 312h 392h IOCAN
013h 093h 113h 193h EEDATL 213h SSPMASK 293h CCP1CON 313h 393h IOCAF
014h 094h 114h 194h EEDATH 214h SSPSTAT 294h PWM1CON 314h 394h
015h TMR0 095h OPTION_REG 115h CMOUT 195h EECON1 215h SSP1CON1 295h CCP1AS 315h 395h
016h TMR1L 096h PCON 116h BORCON 196h EECON2 216h SSP1CON2 296h PSTR1CON 316h 396h
017h TMR1H 097h WDTCON 117h FVRCON 197h VREGCON(1) 217h SSP1CON3 297h 317h 397h
018h T1CON 098h OSCTUNE 118h DACCON0 198h 218h 298h 318h 398h
019h T1GCON 099h OSCCON 119h DACCON1 199h RCREG 219h 299h 319h 399h
01Ah TMR2 09Ah OSCSTAT 11Ah SRCON0 19Ah TXREG 21Ah 29Ah 31Ah 39Ah CLKRCON
01Bh PR2 09Bh ADRESL 11Bh SRCON1 19Bh SPBRGL 21Bh 29Bh 31Bh 39Bh
01Ch T2CON 09Ch ADRESH 11Ch 19Ch SPBRGH 21Ch 29Ch 31Ch 39Ch MDCON
01Dh 09Dh ADCON0 11Dh APFCON 19Dh RCSTA 21Dh 29Dh 31Dh 39Dh MDSRC
01Eh CPSCON0 09Eh ADCON1 11Eh 19Eh TXSTA 21Eh 29Eh 31Eh 39Eh MDCARL
01Fh CPSCON1 09Fh 11Fh 19Fh BAUDCON 21Fh 29Fh 31Fh 39Fh MDCARH
020h 0A0h 120h 1A0h 220h 2A0h 320h 3A0h
General General General
Purpose Purpose Purpose Unimplemented Unimplemented Unimplemented Unimplemented Unimplemented
Register Register Register Read as 0 Read as 0 Read as 0 Read as 0 Read as 0
80 Bytes 80 Bytes 80 Bytes
06Fh 0EFh 16Fh 1EFh 26Fh 2EFh 36Fh 3EFh
070h 0F0h 170h 1F0h 270h 2F0h 370h 3F0h
Accesses Accesses Accesses Accesses Accesses Accesses Accesses
Common RAM
70h 7Fh 70h 7Fh 70h 7Fh 70h 7Fh 70h 7Fh 70h 7Fh 70h 7Fh
07Fh 0FFh 17Fh 1FFh 27Fh 2FFh 37Fh 3FFh
2011-2015 Microchip Technology Inc.
PIC12(L)F1840
C0Bh C8Bh D0Bh D8Bh E0Bh E8Bh F0Bh
C0Ch C8Ch D0Ch D8Ch E0Ch E8Ch F0Ch
Unimplemented Unimplemented Unimplemented Unimplemented Unimplemented Unimplemented Unimplemented
Read as 0 Read as 0 Read as 0 Read as 0 Read as 0 Read as 0 Read as 0
C6Fh CEFh D6Fh DEFh E6Fh EEFh F6Fh
C70h CF0h D70h DF0h E70h EF0h F70h
Common RAM Common RAM Common RAM Common RAM Common RAM Common RAM Common RAM
DS40001441F-page 18
Unimplemented
Read as 0
FE3h
FE4h STATUS_SHAD
FE5h WREG_SHAD
FE6h BSR_SHAD
FE7h PCLATH_SHAD
FE8h FSR0L_SHAD
FE9h FSR0H_SHAD
FEAh FSR1L_SHAD
FEBh FSR1H_SHAD
FECh
FEDh STKPTR
FEEh TOSL
FEFh TOSH
Legend: = Unimplemented data memory locations,
read as 0.
Bank 0-31
x00h or Addressing this location uses contents of FSR0H/FSR0L to address data memory
INDF0 xxxx xxxx uuuu uuuu
x80h (not a physical register)
x01h or Addressing this location uses contents of FSR1H/FSR1L to address data memory
INDF1 xxxx xxxx uuuu uuuu
x81h (not a physical register)
x02h or
PCL Program Counter (PC) Least Significant Byte 0000 0000 0000 0000
x82h
x03h or
STATUS TO PD Z DC C ---1 1000 ---q quuu
x83h
x04h or
FSR0L Indirect Data Memory Address 0 Low Pointer 0000 0000 uuuu uuuu
x84h
x05h or
FSR0H Indirect Data Memory Address 0 High Pointer 0000 0000 0000 0000
x85h
x06h or
FSR1L Indirect Data Memory Address 1 Low Pointer 0000 0000 uuuu uuuu
x86h
x07h or
FSR1H Indirect Data Memory Address 1 High Pointer 0000 0000 0000 0000
x87h
x08h or
BSR BSR4 BSR3 BSR2 BSR1 BSR0 ---0 0000 ---0 0000
x88h
x09h or
WREG Working Register 0000 0000 uuuu uuuu
x89h
x0Ah or
PCLATH Write Buffer for the upper 7 bits of the Program Counter -000 0000 -000 0000
x8Ah
x0Bh or
INTCON GIE PEIE TMR0IE INTE IOCIE TMR0IF INTF IOCIF 0000 0000 0000 0000
x8Bh
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, read as 0, r = reserved.
Shaded locations are unimplemented, read as 0.
Bank 2
10Ch LATA LATA5 LATA4 LATA2 LATA1 LATA0 --xx -xxx --uu -uuu
10Dh
to Unimplemented
110h
111h CM1CON0 C1ON C1OUT C1OE C1POL C1SP C1HYS C1SYNC 0000 -100 0000 -100
112h CM1CON1 C1INTP C1INTN C1PCH<1:0> C1NCH 0000 ---0 0000 ---0
113h Unimplemented
114h Unimplemented
115h CMOUT MC1OUT ---- ---0 ---- ---0
116h BORCON SBOREN BORFS BORRDY 10-- ---q uu-- ---u
117h FVRCON FVREN FVRRDY TSEN TSRNG CDAFVR<1:0> ADFVR<1:0> 0q00 0000 0q00 0000
118h DACCON0 DACEN DACLPS DACOE DACPSS<1:0> 000- 00-- 000- 00--
119h DACCON1 DACR<4:0> ---0 0000 ---0 0000
11Ah SRCON0 SRLEN SRCLK<2:0> SRQEN SRNQEN SRPS SRPR 0000 0000 0000 0000
11Bh SRCON1 SRSPE SRSCKE Reserved SRSC1E SRRPE SRRCKE Reserved SRRC1E 0000 0000 0000 0000
11Ch Unimplemented
11Dh APFCON RXDTSEL SDOSEL SSSEL --- T1GSEL TXCKSEL P1BSEL CCP1SEL 000- 0000 000- 0000
11Eh Unimplemented
11Fh Unimplemented
Bank 3
18Ch ANSELA ANSA4 ANSA2 ANSA1 ANSA0 ---1 -111 ---1 -111
18Dh
to Unimplemented
190h
191h EEADRL EEPROM/Program Memory Address Register Low Byte 0000 0000 0000 0000
192h EEADRH (3) EEPROM / Program Memory Address Register High Byte 1000 0000 1000 0000
193h EEDATL EEPROM/Program Memory Read Data Register Low Byte xxxx xxxx uuuu uuuu
194h EEDATH EEPROM / Program Memory Read Data Register High Byte --xx xxxx --uu uuuu
195h EECON1 EEPGD CFGS LWLO FREE WRERR WREN WR RD 0000 x000 0000 q000
196h EECON2 EEPROM control register 2 0000 0000 0000 0000
197h VREGCON(2) VREGPM Reserved ---- --01 ---- --01
198h Unimplemented
199h RCREG USART Receive Data Register 0000 0000 0000 0000
19Ah TXREG USART Transmit Data Register 0000 0000 0000 0000
19Bh SPBRGL Baud Rate Generator Data Register Low 0000 0000 0000 0000
19Ch SPBRGH Baud Rate Generator Data Register High 0000 0000 0000 0000
19Dh RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 0000 000x 0000 000x
19Eh TXSTA CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 0000 0010 0000 0010
19Fh BAUDCON ABDOVF RCIDL SCKP BRG16 WUE ABDEN 01-0 0-00 01-0 0-00
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, r = reserved.
Shaded locations are unimplemented, read as 0.
Note 1: These registers can be addressed from any bank.
2: PIC12F1840 only.
3: Unimplemented, read as 1.
Bank 4
20Ch WPUA WPUA5 WPUA4 WPUA3 WPUA2 WPUA1 WPUA0 --11 1111 --11 1111
20Dh
to Unimplemented
210h
211h SSP1BUF Synchronous Serial Port Receive Buffer/Transmit Register xxxx xxxx uuuu uuuu
212h SSP1ADD ADD<7:0> 0000 0000 0000 0000
213h SSP1MSK MSK<7:0> 1111 1111 1111 1111
214h SSP1STAT SMP CKE D/A P S R/W UA BF 0000 0000 0000 0000
215h SSP1CON1 WCOL SSP1OV SSP1EN CKP SSP1M<3:0> 0000 0000 0000 0000
216h SSP1CON2 GCEN ACKSTAT ACKDT ACKEN RCEN PEN RSEN SEN 0000 0000 0000 0000
217h SSP1CON3 ACKTIM PCIE SCIE BOEN SDAHT SBCDE AHEN DHEN 0000 0000 0000 0000
218h
to Unimplemented
21Fh
Bank 5
28Ch
to Unimplemented
290h
291h CCPR1L Capture/Compare/PWM Register 1 (LSB) xxxx xxxx uuuu uuuu
292h CCPR1H Capture/Compare/PWM Register 1 (MSB) xxxx xxxx uuuu uuuu
293h CCP1CON P1M<1:0> DC1B<1:0> CCP1M<3:0> 0000 0000 0000 0000
294h PWM1CON P1RSEN P1DC<6:0> 0000 0000 0000 0000
295h CCP1AS CCP1ASE CCP1AS<2:0> PSS1AC<1:0> PSS1BD<1:0> 0000 0000 0000 0000
296h PSTR1CON STR1SYNC Reserved Reserved STR1B STR1A ---0 rr01 ---0 rr01
297h
to Unimplemented
29Fh
Bank 6
30Ch
to Unimplemented
31Fh
Bank 7
38Ch
to Unimplemented
390h
391h IOCAP IOCAP5 IOCAP4 IOCAP3 IOCAP2 IOCAP1 IOCAP0 --00 0000 --00 0000
392h IOCAN IOCAN5 IOCAN4 IOCAN3 IOCAN2 IOCAN1 IOCAN0 --00 0000 --00 0000
393h IOCAF IOCAF5 IOCAF4 IOCAF3 IOCAF2 IOCAF1 IOCAF0 --00 0000 --00 0000
394h
to Unimplemented
399h
39Ah CLKRCON CLKREN CLKROE CLKRSLR CLKRDC<1:0> CLKRDIV<2:0> 0011 0000 0011 0000
39Bh Unimplemented
39Ch MDCON MDEN MDOE MDSLR MDOPOL MDOUT MDBIT 0010 ---0 0010 ---0
39Dh MDSRC MDMSODIS MDMS<3:0> x--- xxxx u--- uuuu
39Eh MDCARL MDCLODIS MDCLPOL MDCLSYNC MDCL<3:0> xxx- xxxx uuu- uuuu
39Fh MDCARH MDCHODIS MDCHPOL MDCHSYNC MDCH<3:0> xxx- xxxx uuu- uuuu
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, r = reserved.
Shaded locations are unimplemented, read as 0.
Note 1: These registers can be addressed from any bank.
2: PIC12F1840 only.
3: Unimplemented, read as 1.
Banks 8-30
x0Ch/ Unimplemented
x8Ch
x1Fh/
x9Fh
Bank 31
F8Ch Unimplemented
FE3h
FE4h STATUS_ Z_SHAD DC_SHAD C_SHAD ---- -xxx ---- -uuu
SHAD
FE5h WREG_ Working Register Shadow 0000 0000 uuuu uuuu
SHAD
FE6h BSR_ Bank Select Register Shadow ---x xxxx ---u uuuu
SHAD
FE7h PCLATH_ Program Counter Latch High Register Shadow -xxx xxxx uuuu uuuu
SHAD
FE8h FSR0L_ Indirect Data Memory Address 0 Low Pointer Shadow xxxx xxxx uuuu uuuu
SHAD
FE9h FSR0H_ Indirect Data Memory Address 0 High Pointer Shadow xxxx xxxx uuuu uuuu
SHAD
FEAh FSR1L_ Indirect Data Memory Address 1 Low Pointer Shadow xxxx xxxx uuuu uuuu
SHAD
FEBh FSR1H_ Indirect Data Memory Address 1 High Pointer Shadow xxxx xxxx uuuu uuuu
SHAD
FECh Unimplemented
FEDh STKPTR Current Stack Pointer ---1 1111 ---1 1111
FEEh TOSL Top-of-Stack Low byte xxxx xxxx uuuu uuuu
FEFh TOSH Top-of-Stack High byte -xxx xxxx -uuu uuuu
Legend: x = unknown, u = unchanged, q = value depends on condition, - = unimplemented, r = reserved.
Shaded locations are unimplemented, read as 0.
Note 1: These registers can be addressed from any bank.
2: PIC12F1840 only.
3: Unimplemented, read as 1.
0x0C
0x0B
0x0A
Initial Stack Configuration:
0x09
After Reset, the stack is empty. The
0x08 empty stack is initialized so the Stack
Pointer is pointing at 0x1F. If the Stack
0x07
Overflow/Underflow Reset is enabled, the
0x06 TOSH/TOSL registers will return 0. If
the Stack Overflow/Underflow Reset is
0x05 disabled, the TOSH/TOSL registers will
return the contents of stack address 0x0F.
0x04
0x03
0x02
0x01
0x00
Stack Reset Enabled
TOSH:TOSL 0x1F 0x0000 STKPTR = 0x1F
(STVREN = 1)
0x0F
0x0E
0x0D
0x0C
0x0B
0x0A
0x09 This figure shows the stack configuration
after the first CALL or a single interrupt.
0x08 If a RETURN instruction is executed, the
0x07 return address will be placed in the
Program Counter and the Stack Pointer
0x06 decremented to the empty state (0x1F).
0x05
0x04
0x03
0x02
0x01
TOSH:TOSL 0x00 Return Address STKPTR = 0x00
0x0F
0x0E
0x0D
0x0C
After seven CALLs or six CALLs and an
0x0B interrupt, the stack looks like the figure
on the left. A series of RETURN instructions
0x0A will repeatedly place the return addresses
into the Program Counter and pop the stack.
0x09
0x08
0x07
TOSH:TOSL 0x06 Return Address STKPTR = 0x06
0x0000 0x0000
Traditional
Data Memory
0x0FFF 0x0FFF
0x1000
Reserved
0x1FFF
0x2000
Linear
Data Memory
0x29AF
0x29B0
FSR Reserved
0x7FFF
Address
Range 0x8000 0x0000
Program
Flash Memory
0xFFFF 0x7FFF
Note: Not all memory regions are completely implemented. Consult device memory tables for memory limits.
0x7F
Bank 0 Bank 1 Bank 2 Bank 31
0xF20
Bank 30 0x7FFF
0xFFFF
0x29AF 0xF6F
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as 1
0 = Bit is cleared 1 = Bit is set -n = Value when blank or after Bulk Erase
Note 1: Enabling Brown-out Reset does not automatically enable Power-up Timer.
2: The entire data EEPROM will be erased when the code protection is turned off during an erase.
3: The entire program memory will be erased when the code protection is turned off.
Legend:
R = Readable bit P = Programmable bit U = Unimplemented bit, read as 1
0 = Bit is cleared 1 = Bit is set -n = Value when blank or after Bulk Erase
Note 1: The LVP bit cannot be programmed to 0 when Programming mode is entered via LVP.
2: The DEBUG bit in Configuration Words is managed automatically by device development tools including
debuggers and programmers. For normal device operation, this bit should be maintained as a '1'.
3: See Vbor parameter for specific trip point voltages.
4.5 User ID
Four memory locations (8000h-8003h) are designated as
ID locations where the user can store checksum or other
code identification numbers. These locations are
readable and writable during normal execution. See
Section 11.5 User ID, Device ID and Configuration
Word Access for more information on accessing these
memory locations. For more information on checksum
calculation, see the PIC16F/LF1847/PIC12F/LF1840
Memory Programming Specification (DS41439).
R R R R R R R R
DEV<2:0> REV<4:0>
bit 7 bit 0
Legend:
R = Readable bit
1 = Bit is set 0 = Bit is cleared
DEVID<13:0> Values
Device
DEV<8:0> REV<4:0>
PIC12F1840 011 011 100 x xxxx
PIC12LF1840 011 011 110 x xxxx
External
Oscillator LP, XT, HS, RC, EC
OSC2
Sleep
4 x PLL Sleep
OSC1
Oscillator Timer1 FOSC<2:0> = 100 T1OSC CPU and
MUX
T1OSO Peripherals
T1OSCEN
Enable
T1OSI Oscillator IRCF<3:0>
Internal Oscillator
16 MHz
8 MHz
Internal
Oscillator 4 MHz
Block 2 MHz
Clock
Postscaler
1 MHz
HFPLL Control
MUX
16 MHz 500 kHz
(HFINTOSC) 250 kHz
125 kHz FOSC<2:0> SCS<1:0>
500 kHz
Source 500 kHz 62.5 kHz
(MFINTOSC) 31.25 kHz Clock Source Option
31 kHz for other modules
31 kHz
Source
OSC1/CLKIN OSC1/CLKIN
C1 To Internal C1 To Internal
Logic Logic
Quartz
RF(2) Sleep RP(3)
Crystal RF(2) Sleep
OSC2/CLKOUT
C2 RS(1) OSC2/CLKOUT
C2 Ceramic RS(1)
Resonator
Note 1: A series resistor (RS) may be required for
quartz crystals with low drive level. Note 1: A series resistor (RS) may be required for
ceramic resonators with low drive level.
2: The value of RF varies with the Oscillator mode
selected (typically between 2 M to 10 M. 2: The value of RF varies with the Oscillator mode
selected (typically between 2 M to 10 M.
3: An additional parallel feedback resistor (RP)
Note 1: Quartz crystal characteristics vary may be required for proper ceramic resonator
according to type, package and operation.
manufacturer. The user should consult the
manufacturer data sheets for specifications
and recommended application. 5.2.1.3 Oscillator Start-up Timer (OST)
2: Always verify oscillator performance over If the oscillator module is configured for LP, XT or HS
the VDD and temperature range that is modes, the Oscillator Start-up Timer (OST) counts
expected for the application. 1024 oscillations from OSC1. This occurs following a
3: For oscillator design assistance, reference Power-on Reset (POR) and when the Power-up Timer
the following Microchip Applications Notes: (PWRT) has expired (if configured), or a wake-up from
Sleep. During this time, the program counter does not
AN826, Crystal Oscillator Basics and increment and program execution is suspended,
Crystal Selection for rfPIC and PIC unless either FSCM or Two-Speed Start-Up are
Devices (DS00826) enabled. In this case, code will continue to execute at
AN849, Basic PIC Oscillator Design the selected INTOSC frequency while the OST is
(DS00849) counting. The OST ensures that the oscillator circuit,
AN943, Practical PIC Oscillator using a quartz crystal resonator or ceramic resonator,
Analysis and Design (DS00943) has started and is providing a stable system clock to
AN949, Making Your Oscillator Work the oscillator module.
(DS00949) In order to minimize latency between external oscillator
start-up and code execution, the Two-Speed Clock
Start-up mode can be selected (see Section 5.4
Two-Speed Clock Start-up Mode).
C2 T1OSO
LFINTOSC
IRCF <3:0> 0 0
System Clock
LFINTOSC
IRCF <3:0> 0 0
System Clock
LFINTOSC HFINTOSC/MFINTOSC
LFINTOSC turns off unless WDT or FSCM is enabled
LFINTOSC
Oscillator Delay(1) 2-cycle Sync Running
HFINTOSC/
MFINTOSC
IRCF <3:0> =0 0
System Clock
Note 1: See Table 5-1, Oscillator Switching Delays, for more information.
Default system oscillator determined by FOSC The Timer1 oscillator is enabled using the T1OSCEN
bits in Configuration Words control bit in the T1CON register. See Section 21.0
Timer1 Module with Gate Control for more
Timer1 32 kHz crystal oscillator
information about the Timer1 peripheral.
Internal Oscillator Block (INTOSC)
5.3.4 TIMER1 OSCILLATOR READY
5.3.1 SYSTEM CLOCK SELECT (SCS)
(T1OSCR) BIT
BITS
The user must ensure that the Timer1 oscillator is
The System Clock Select (SCS) bits of the OSCCON
ready to be used before it is selected as a system clock
register selects the system clock source that is used for
source. The Timer1 Oscillator Ready (T1OSCR) bit of
the CPU and peripherals.
the OSCSTAT register indicates whether the Timer1
When the SCS bits of the OSCCON register = 00, oscillator is ready to be used. After the T1OSCR bit is
the system clock source is determined by value of set, the SCS bits can be configured to select the Timer1
the FOSC<2:0> bits in the Configuration Words. oscillator.
When the SCS bits of the OSCCON register = 01,
the system clock source is the Timer1 oscillator.
When the SCS bits of the OSCCON register = 1x,
the system clock source is chosen by the internal
oscillator frequency selected by the IRCF<3:0>
bits of the OSCCON register. After a Reset, the
SCS bits of the OSCCON register are always
cleared.
Note: Any automatic clock switch, which may
occur from Two-Speed Start-up or
Fail-Safe Clock Monitor, does not update
the SCS bits of the OSCCON register. The
user can monitor the OSTS bit of the
OSCSTAT register to determine the current
system clock source.
When switching between clock sources, a delay is
required to allow the new clock to stabilize. These
oscillator delays are shown in Table 5-1.
INTOSC
TOST
OSC2
Program Counter PC - N PC PC + 1
System Clock
Sample Clock
System Oscillator
Clock Failure
Output
Note: The system clock is normally at a much higher frequency than the sample clock. The relative frequencies in
this example have been chosen for clarity.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared q = Conditional
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: In this mode, the 25% and 75% duty cycle accuracy will be dependent on the source clock duty cycle.
2: In this mode, the duty cycle will always be equal to the source clock duty cycle, unless a duty cycle of 0%
is selected.
3: To route CLKR to pin, CLKOUTEN of Configuration Words = 1 is required. CLKOUTEN of Configuration
Words = 0 will result in FOSC/4. See Section 6.3 Conflicts with the CLKR Pin for details.
External Reset
MCLRE
MCLR
Sleep
WDT
Time-out
Device
Power-on Reset
Reset
VDD
Brown-out
Reset
BOR
Enable
PWRT
Zero
64 ms
LFINTOSC
PWRTEN
VDD
VBOR
Internal
Reset TPWRT(1)
VDD
VBOR
VDD
VBOR
Internal
Reset TPWRT(1)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared q = Value depends on condition
VDD
Internal POR
TPWRT
Power-Up Timer
MCLR
TMCLR
Internal RESET
Oscillator Modes
External Crystal
TOST
Oscillator Start-Up Timer
Oscillator
FOSC
Internal Oscillator
Oscillator
FOSC
CLKIN
FOSC
Legend:
HC = Bit is cleared by hardware HS = Bit is set by hardware
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -m/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared q = Value depends on condition
TMR0IF Wake-up
TMR0IE (If in Sleep mode)
INTF
Peripheral Interrupts INTE
(TMR1IF) PIR1<0>
IOCIF
(TMR1IE) PIE1<0> Interrupt
IOCIE to CPU
PEIE
PIRn<7>
PIEn<7>
GIE
OSC1
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Interrupt
GIE
Interrupt
GIE
Interrupt
GIE
Interrupt
GIE
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1
CLKOUT (3)
(4)
INT pin
(1)
(1)
INTF (5) Interrupt Latency (2)
GIE
INSTRUCTION FLOW
PC PC PC + 1 PC + 1 0004h 0005h
Instruction
Fetched Inst (PC) Inst (PC + 1) Inst (0004h) Inst (0005h)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: The IOCIF Flag bit is read-only and cleared when all the Interrupt-on-Change flags in the IOCAF register
have been cleared by software.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
GIE bit
(INTCON reg.) Processor in
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) Forced NOP Forced NOP
Executed Inst(PC - 1) Inst(0004h)
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
WDTE<1:0> = 01
SWDTEN
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -m/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
MOVLW 0AAh ;
MOVWF EECON2 ;Write AAh
BSF EECON1, WR ;Set WR bit to begin write
BSF INTCON, GIE ;Enable Interrupts
BCF EECON1, WREN ;Disable writes
BTFSC EECON1, WR ;Wait for write to complete
GOTO $-2 ;Done
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Flash Data INSTR (PC) INSTR (PC + 1) EEDATH,EEDATL INSTR (PC + 3) INSTR (PC + 4)
RD bit
EEDATH
EEDATL
Register
FIGURE 11-2: BLOCK WRITES TO FLASH PROGRAM MEMORY WITH 32 WRITE LATCHES
7 5 0 7 0
EEDATH EEDATA
6 8
14 14 14 14
Program Memory
START_WRITE
BCF EECON1,LWLO ; No more loading latches - Actually start Flash program
; memory write
MOVLW 0AAh ;
Required
TABLE 11-2: USER ID, DEVICE ID AND CONFIGURATION WORD ACCESS (CFGS = 1)
Address Function Read Access Write Access
8000h-8003h User IDs Yes Yes
8006h Device ID/Revision ID Yes No
8007h-8008h Configuration Words 1 and 2 Yes No
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
bit 7-0 EEDAT<7:0>: Read/write value for EEPROM data byte or Least Significant bits of program memory
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
bit 7-0 EEADR<7:0>: Specifies the Least Significant bits for program memory address or EEPROM address
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
S = Bit can only be set x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared HC = Bit is cleared by hardware
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
S = Bit can only be set x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Read LATx
TRISx
D Q
Write LATx
Write PORTx
CK VDD
Data Register
Data Bus
I/O pin
Read PORTx
To digital peripherals
VSS
ANSELx
To analog peripherals
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: Writes to PORTA are actually written to corresponding LATA register. Reads from PORTA register is return
of actual I/O pin values.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: Writes to PORTA are actually written to corresponding LATA register. Reads from PORTA register is return
of actual I/O pin values.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: When setting a pin to an analog input, the corresponding TRIS bit must be set to Input mode in order to
allow external control of the voltage on the pin.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: Global WPUEN bit of the OPTION register must be cleared for individual pull-ups to be enabled.
2: The weak pull-up device is automatically disabled if the pin is in configured as an output.
IOCANx D Q4Q1
Q
CK Edge
Detect
R
RAx
CK write IOCAFx CK
IOCIE
R
Q2
From all other
IOCAFx individual IOC Interrupt
Pin Detectors to CPU core
Q1 Q1 Q1
Q2 Q2 Q2
Q3 Q3 Q3
Q4 Q4 Q4 Q4
Q4Q1 Q4Q1 Q4Q1 Q4Q1
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared HS - Bit is set in hardware
ADFVR<1:0>
2
X1
X2 FVR_buffer1
X4 (To ADC Module)
CDAFVR<1:0> 2
X1
X2 FVR_buffer2
X4 (To Comparators, DAC, CPS)
+
FVREN
_ FVRRDY
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared q = Value depends on condition
VDD
ADPREF = 00
ADPREF = 11
VREF ADPREF = 10
AN0 00000
AN1 00001
AN2 00010
AN3 00011 Ref+ Ref-
ADC
GO/DONE 10
Temp Indicator 11101
DAC_output 11110 0 = Left Justify
ADFM
FVR Buffer1 11111 1 = Right Justify
ADON(1) 16
ADC
ADCS<2:0> 32 MHz 20 MHz 16 MHz 8 MHz 4 MHz 1 MHz
Clock Source
Fosc/2 000 62.5ns(2) 100 ns(2) 125 ns(2) 250 ns(2) 500 ns(2) 2.0 s
(2) (2) (2) (2)
Fosc/4 100 125 ns 200 ns 250 ns 500 ns 1.0 s 4.0 s
Fosc/8 001 0.5 s(2) 400 ns(2) 0.5 s(2) 1.0 s 2.0 s 8.0 s(3)
Fosc/16 101 800 ns 800 ns 1.0 s 2.0 s 4.0 s 16.0 s(3)
(3)
Fosc/32 010 1.0 s 1.6 s 2.0 s 4.0 s 8.0 s 32.0 s(3)
(3) (3)
Fosc/64 110 2.0 s 3.2 s 4.0 s 8.0 s 16.0 s 64.0 s(3)
FRC x11 1.0-6.0 s(1,4) 1.0-6.0 s(1,4) 1.0-6.0 s(1,4) 1.0-6.0 s(1,4) 1.0-6.0 s(1,4) 1.0-6.0 s(1,4)
Legend: Shaded cells are outside of recommended range.
Note 1: The FRC source has a typical TAD time of 1.6 s for VDD.
2: These values violate the minimum required TAD time.
3: For faster conversion times, the selection of another clock source is recommended.
4: The ADC clock period (TAD) and total ADC conversion time can be minimized when the ADC clock is derived from the
system clock FOSC. However, the FRC oscillator source must be used when conversions are to be performed with the
device in Sleep mode.
TCY - 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
On the following cycle:
ADRESH:ADRESL is loaded, GO bit is cleared,
ADIF bit is set, holding capacitor is connected to analog input.
ADRESH ADRESL
(ADFM = 0) MSB LSB
bit 7 bit 0 bit 7 bit 0
Note: A device Reset forces all registers to their Using the Special Event Trigger does not assure proper
Reset state. Thus, the ADC module is ADC timing. It is the users responsibility to ensure that
turned off and any pending conversion is the ADC timing requirements are met.
terminated. Refer to Section 24.0 Capture/Compare/PWM
Modules for more information.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: When selecting the FVR or the VREF+ pin as the source of the positive reference, be aware that a
minimum voltage specification exists. See Section 30.0 Electrical Specifications for details.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
T ACQ = Amplifier Settling Time + Hold Capacitor Charging Time + Temperature Coefficient
= T AMP + T C + T COFF
= 2s + T C + Temperature - 25C 0.05s/C
V AP P LI ED 1 -------------------------- = V CHOLD
1
;[1] VCHOLD charged to within 1/2 lsb
n+1
2 1
TC
----------
RC
V AP P LI ED 1 e = V CHOLD ;[2] VCHOLD charge response to VAPPLIED
Tc
---------
V AP P LI ED 1 e = V A PP LIE D 1 -------------------------- ;combining [1] and [2]
RC 1
n+1
2 1
T C = C HOLD R IC + R SS + R S ln(1/511)
= 12.5pF 1k + 7k + 10k ln(0.001957)
1.72s
Therefore:
T A CQ = 2s + 1.72s + 50C- 25C 0.05 s/C
= 4.97s
Note 1: The reference voltage (VREF) has no effect on the equation, since it cancels itself out.
2: The charge holding capacitor (CHOLD) is not discharged after each conversion.
3: The maximum recommended impedance for analog sources is 10 k. This is required to meet the pin
leakage specification.
VA CPIN I LEAKAGE(1)
VT 0.6V CHOLD = 12.5 pF
5 pF
VSS/VREF-
6V
5V RSS
Legend: CHOLD = Sample/Hold Capacitance VDD 4V
3V
CPIN = Input Capacitance 2V
I LEAKAGE = Leakage current at the pin due to
various junctions
5 6 7 8 9 10 11
RIC = Interconnect Resistance
Sampling Switch
RSS = Resistance of Sampling Switch (k)
SS = Sampling Switch
VT = Threshold Voltage
Full-Scale Range
3FFh
3FEh
3FDh
3FCh
ADC Output Code
3FBh
03h
02h
01h
00h
Analog Input Voltage
0.5 LSB 1.5 LSB
VREF- Zero-Scale
Transition Full-Scale
Transition VREF+
IF DACEN = 1
DACR 4:0
VOUT = VSOURCE+ VSOURCE- ----------------------------- + VSOURCE-
5
2
V OUT = V SOURCE +
V OUT = V SOURCE
FVR BUFFER2
VDD
VSOURCE+
DACR<4:0>
5
VREF
R
R
DACPSS<1:0>
2
R
DACEN
DACLPS R
32-to-1 MUX
32 DAC_output
Steps (To Comparator, CPS and
ADC Modules)
R
R
DACOUT
R
DACOE
VSOURCE-
VSS
PIC MCU
DAC
R
Module
+
Voltage DACOUT Buffered DAC Output
Reference
Output
Impedance
Output Clamped to Positive Voltage Source Output Clamped to Negative Voltage Source
VSOURCE+ VSOURCE+
R R
DACR<4:0> = 11111
R R
DACEN = 0 DACEN = 0
DACLPS = 1 DAC Voltage Ladder DACLPS = 0 DAC Voltage Ladder
(see Figure 17-1) (see Figure 17-1)
R R
DACR<4:0> = 00000
VSOURCE- VSOURCE-
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
SRLEN
SRPS Pulse SRQEN
Gen(2)
SRI
SRSPE S Q
SRCLK SRQ
SRSCKE
sync_C1OUT(3)
SRSC1E
SR
Latch(1)
SRPR Pulse
Gen(2)
SRI
SRRPE R Q
SRCLK SRNQ
SRRCKE SRLEN
sync_C1OUT(3) SRNQEN
SRRC1E
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared S = Bit is set only
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
det
Set C1IF
C1IN0- 0
CPIN ILEAKAGE(1)
VA VT 0.6V
5 pF
Vss
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
FOSC/4
Data Bus
0
8
T0CKI 1
0 Sync
1 2 TCY TMR0
0
From CPSCLK
1 TMR0SE Set Flag bit TMR0IF
TMR0CS 8-bit on Overflow
Prescaler PSA
T0XCS
Overflow to Timer1
PS<2:0>
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
000 1:2
001 1:4
010 1:8
011 1 : 16
100 1 : 32
101 1 : 64
110 1 : 128
111 1 : 256
T1GSS<1:0>
T1GSPM
T1G 00
t1g_in 0
T1GVAL Data Bus
0
From Timer0 01 D Q
Overflow Single Pulse RD
1 T1GCON
Comparator 1 Acq. Control Q1 EN
10 D Q 1
sync_C1OUT
Interrupt Set
CK Q T1GGO/DONE
Reserved 11 TMR1ON det TMR1GIF
R
T1GTM
T1GPOL TMR1GE
TMR1ON
Set flag bit To Comparator Module
TMR1IF on TMR1(2)
Overflow EN Synchronized
0 clock input
TMR1H TMR1L T1CLK
Q D
1
TMR1CS<1:0>
T1SYNC
T1OSO OUT
Cap. Sensing
11
T1OSC Oscillator Prescaler Synchronize(3)
1 1, 2, 4, 8 det
T1OSI 10
EN
2
0
FOSC T1CKPS<1:0>
Internal 01
Clock FOSC/2
T1OSCEN Sleep input
Internal
FOSC/4 Clock
Internal 00
(1) Clock
T1CKI
To Clock Switching Modules
TABLE 21-1: TIMER1 ENABLE The following asynchronous sources may be used:
SELECTIONS Asynchronous event on the T1G pin to Timer1
gate
Timer1
TMR1ON TMR1GE C1 comparator input to Timer1 gate
Operation
0 0 Off 21.2.2 EXTERNAL CLOCK SOURCE
0 1 Off When the external clock source is selected, the Timer1
1 0 Always On module may work as a timer or a counter.
1 1 Count Enabled When enabled to count, Timer1 is incremented on the
rising edge of the external clock input T1CKI or the
capacitive sensing oscillator signal. Either of these
external clock sources can be synchronized to the
microcontroller system clock or they can run
asynchronously.
When used as a timer with a clock oscillator, an
external 32.768 kHz crystal can be used in conjunction
with the dedicated internal oscillator circuit.
Note: In Counter mode, a falling edge must be
registered by the counter prior to the first
incrementing rising edge after any one or
more of the following conditions:
Timer1 enabled after POR
Write to TMR1H or TMR1L
Timer1 is disabled
Timer1 is disabled (TMR1ON = 0)
when T1CKI is high then Timer1 is
enabled (TMR1ON=1) when T1CKI is
low.
The oscillator circuit is enabled by setting the Timer1 gate can also be driven by multiple selectable
T1OSCEN bit of the T1CON register. The oscillator will sources.
continue to run during Sleep.
21.6.1 TIMER1 GATE ENABLE
Note: The oscillator requires a start-up and The Timer1 Gate Enable mode is enabled by setting
stabilization time before use. Thus, the TMR1GE bit of the T1GCON register. The polarity
T1OSCEN should be set and a suitable of the Timer1 Gate Enable mode is configured using
delay observed prior to using Timer1. A the T1GPOL bit of the T1GCON register.
suitable delay similar to the OST delay
can be implemented in software by When Timer1 Gate Enable mode is enabled, Timer1
clearing the TMR1IF bit then presetting will increment on the rising edge of the Timer1 clock
the TMR1H:TMR1L register pair to source. When Timer1 Gate Enable mode is disabled,
FC00h. The TMR1IF flag will be set when no incrementing will occur and Timer1 will hold the
1024 clock cycles have elapsed, thereby current count. See Figure 21-3 for timing details.
indicating that the oscillator is running and
reasonably stable. TABLE 21-3: TIMER1 GATE ENABLE
SELECTIONS
21.5 Timer1 Operation in
T1CLK T1GPOL T1G Timer1 Operation
Asynchronous Counter Mode
0 0 Counts
If the control bit T1SYNC of the T1CON register is set,
0 1 Holds Count
the external clock input is not synchronized. The timer
increments asynchronously to the internal phase 1 0 Holds Count
clocks. If the external clock source is selected then the 1 1 Counts
timer will continue to run during Sleep and can
generate an interrupt on overflow, which will wake-up 21.6.2 TIMER1 GATE SOURCE
the processor. However, special precautions in SELECTION
software are needed to read/write the timer (see
Timer1 gate source selections are shown in Table 21-4.
Section 21.5.1 Reading and Writing Timer1 in
Source selection is controlled by the T1GSS bits of the
Asynchronous Counter Mode).
T1GCON register. The polarity for each available
Note: When switching from synchronous to source is also selectable. Polarity selection is
asynchronous operation, it is possible to controlled by the T1GPOL bit of the T1GCON register.
skip an increment. When switching from
asynchronous to synchronous operation, TABLE 21-4: TIMER1 GATE SOURCES
it is possible to produce an additional
T1GSS Timer1 Gate Source
increment.
00 Timer1 Gate Pin
21.5.1 READING AND WRITING TIMER1 IN 01 Overflow of Timer0
ASYNCHRONOUS COUNTER (TMR0 increments from FFh to 00h)
MODE 10 Comparator 1 Output sync_C1OUT
Reading TMR1H or TMR1L while the timer is running (optionally Timer1 synchronized output)
from an external asynchronous clock will ensure a valid 11 Reserved
read (taken care of in hardware). However, the user
T1CKI = 1
when TMR1
Enabled
T1CKI = 0
when TMR1
Enabled
TMR1GE
T1GPOL
t1g_in
T1CKI
T1GVAL
TMR1GE
T1GPOL
T1GTM
t1g_in
T1CKI
T1GVAL
TMR1GE
T1GPOL
T1GSPM
Cleared by hardware on
T1GGO/ Set by software falling edge of T1GVAL
DONE
Counting enabled on
rising edge of T1G
t1g_in
T1CKI
T1GVAL
Cleared by
TMR1GIF Cleared by software Set by hardware on software
falling edge of T1GVAL
TMR1GE
T1GPOL
T1GSPM
T1GTM
Cleared by hardware on
T1GGO/ Set by software falling edge of T1GVAL
DONE Counting enabled on
rising edge of T1G
t1g_in
T1CKI
T1GVAL
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared HC = Bit is cleared by hardware
Prescaler Reset
FOSC/4 TMRx TMRx Output
1:1, 1:4, 1:16, 1:64
2 Postscaler
Comparator Sets Flag bit TMRxIF
EQ 1:1 to 1:16
TxCKPS<1:0>
PRx 4
TxOUTPS<3:0>
A 4-bit counter/prescaler on the clock input allows direct Timer2 can be optionally used as the shift clock source
input, divide-by-4 and divide-by-16 prescale options. for the MSSP1 module operating in SPI mode.
These options are selected by the prescaler control bits, Additional information is provided in Section 25.1
T2CKPS<1:0> of the T2CON register. The value of Master SSP (MSSP1) Module Overview
TMR2 is compared to that of the Period register, PR2, on
each clock cycle. When the two values match, the 22.4 Timer2 Operation During Sleep
comparator generates a match signal as the timer
Timer2 cannot be operated while the processor is in
output. This signal also resets the value of TMR2 to 00h
Sleep mode. The contents of the TMR2 and PR2
on the next cycle and drives the output
registers will remain unchanged while the processor is
counter/postscaler (see Section 22.2 Timer2
in Sleep mode.
Interrupt).
The TMR2 and PR2 registers are both directly readable
and writable. The TMR2 register is cleared on any
device Reset, whereas the PR2 register initializes to
FFh. Both the prescaler and postscaler counters are
cleared on the following events:
a write to the TMR2 register
a write to the T2CON register
Power-on Reset (POR)
Brown-out Reset (BOR)
MCLR Reset
Watchdog Timer (WDT) Reset
Stack Overflow Reset
Stack Underflow Reset
RESET Instruction
Note: TMR2 is not cleared when T2CON is
written.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
MDCH<3:0>
MDEN
VSS 0000
MDCIN1 0001 EN
MDCIN2 0010 Data Signal
CLKR 0011 Modulator
CCP1 0100
0101 CARH
Reserved *
No Channel * MDCHPOL
Selected *
1111 D
SYNC
MDMS<3:0> Q 1
MDBIT 0000
MDMIN 0001
CCP1 0010
Reserved 0011 0
Reserved 0100
Reserved 0101
Comparator C1 0110 MOD MDCHSYNC
Reserved 0111
MSSP1 SDO1 1000 MDOUT
Reserved 1001
EUSART 1010 MDOE
MDOPOL
Reserved 0011
No Channel *
*
Selected 1111
D
MDCL<3:0> SYNC
Q 1
VSS 0000
MDCIN1 0001
MDCIN2 0010
CLKR 0011 0
CCP1 0100
0101 CARL MDCLSYNC
Reserved *
No Channel *
Selected MDCLPOL
*
1111
Modulator (MOD)
MDCHSYNC = 1
MDCLSYNC = 0
MDCHSYNC = 1
MDCLSYNC = 1
MDCHSYNC = 0
MDCLSYNC = 0
MDCHSYNC = 0
MDCLSYNC = 1
Modulator (MOD)
MDCHSYNC = 0
MDCLSYNC = 0
Modulator (MOD)
MDCHSYNC = 1
MDCLSYNC = 0
Modulator (MOD)
MDCHSYNC = 0
MDCLSYNC = 1
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: The modulated output frequency can be greater and asynchronous from the clock that updates this
register bit, the bit value may not be valid for higher speed modulator or carrier signals.
2: MDBIT must be selected as the modulation source in the MDSRC register for this operation.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: Narrowed carrier pulse widths or spurs may occur in the signal stream if the carrier is not synchronized.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: Narrowed carrier pulse widths or spurs may occur in the signal stream if the carrier is not synchronized.
TABLE 23-1: SUMMARY OF REGISTERS ASSOCIATED WITH DATA SIGNAL MODULATOR MODE
Register
Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
on Page
MDCARH MDCHODIS MDCHPOL MDCHSYNC MDCH<3:0> 169
MDCARL MDCLODIS MDCLPOL MDCLSYNC MDCL<3:0> 170
MDCON MDEN MDOE MDSLR MDOPOL MDOUT MDBIT 167
MDSRC MDMSODIS MDMS<3:0> 168
Legend: = unimplemented, read as 0. Shaded cells are not used in the Data Signal Modulator mode.
is considered the off state. The high portion, also known TMR2 = CCPR1H:CCP1CON<5:4>
as the pulse width, can vary in time and is defined in
TMR2 = 0
steps. A larger number of steps applied, which
lengthens the pulse width, also supplies more power to
the load. Lowering the number of steps applied, which
shortens the pulse width, supplies less power. The FIGURE 24-4: SIMPLIFIED PWM BLOCK
PWM period is defined as the duration of one complete DIAGRAM
cycle or the total amount of on and off time combined.
CCP1CON<5:4>
Duty Cycle Registers
PWM resolution defines the maximum number of steps
that can be present in a single PWM period. A higher CCPR1L
resolution allows for more precise control of the pulse
width time and in turn the power that is applied to the
load.
The term duty cycle describes the proportion of the on CCPR1H(2) (Slave)
CCP1
time to the off time and is expressed in percentages,
where 0% is fully off and 100% is fully on. A lower duty Comparator R Q
cycle corresponds to less power applied and a higher
duty cycle corresponds to more power applied. (1) S
TMR2
Figure 24-3 shows a typical waveform of the PWM TRIS
signal.
Comparator
Clear Timer,
24.3.1 STANDARD PWM OPERATION toggle CCP1 pin and
latch duty cycle
The standard PWM mode generates a Pulse-Width PR2
Modulation (PWM) signal on the CCP1 pin with up to 10
Note 1: The 8-bit timer TMR2 register is concatenated
bits of resolution. The period, duty cycle, and resolution
with the 2-bit internal system clock (FOSC), or
are controlled by the following registers:
2 bits of the prescaler, to create the 10-bit time
PR2 registers base.
T2CON registers 2: In PWM mode, CCPR1H is a read-only register.
CCPR1L registers
CCP1CON registers
Figure 24-4 shows a simplified block diagram of PWM
operation.
PWM Period = PR2 + 1 4 T OSC The CCPR1H register and a 2-bit internal latch are
(TMR2 Prescale Value) used to double buffer the PWM duty cycle. This double
buffering is essential for glitchless PWM operation.
Note 1: TOSC = 1/FOSC The 8-bit timer TMR2 register is concatenated with
either the 2-bit internal system clock (FOSC), or 2 bits of
the prescaler, to create the 10-bit time base. The system
clock is used if the Timer2 prescaler is set to 1:1.
When the 10-bit time base matches the CCPR1H and
2-bit latch, then the CCP1 pin is cleared (see
Figure 24-4).
PR2 registers Table 24-8 shows the pin assignments for various
Enhanced PWM modes.
T2CON registers
CCPR1L registers Note 1: The corresponding TRIS bit must be
CCP1CON registers cleared to enable the PWM output on the
CCP1 pin.
The ECCP modules have the following additional PWM
registers which control Auto-shutdown, Auto-restart, 2: Clearing the CCP1CON register will
Dead-band Delay and PWM Steering modes: relinquish control of the CCP1 pin.
FIGURE 24-5: EXAMPLE SIMPLIFIED BLOCK DIAGRAM OF THE ENHANCED PWM MODE
DC1B<1:0> P1M<1:0> CCP1M<3:0>
Duty Cycle Registers
2 4
CCPR1L
Output
Controller
CCPR1H (Slave)
CCP1/P1A CCP1/P1A
Comparator R Q
TRISx
TMR2 (1)
S P1B P1B
TRISx
Comparator
Clear Timer,
toggle PWM pin and
latch duty cycle
PR2 PWM1CON
Note 1: The 8-bit timer TMR1 register is concatenated with the 2-bit internal Q clock, or 2 bits of the prescaler to create the 10-bit time
base.
Relationships:
Period = 4 * TOSC * (PR2 + 1) * (TMRx Prescale Value)
Pulse Width = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMRx Prescale Value)
Delay = 4 * TOSC * (PWM1CON<6:0>)
Pulse PR2+1
P1M<1:0> Signal 0
Width
Period
P1A Modulated
Delay Delay
10 (Half-Bridge) P1B Modulated
Relationships:
Period = 4 * TOSC * (PR2 + 1) * (TMRx Prescale Value)
Pulse Width = TOSC * (CCPR1L<7:0>:CCP1CON<5:4>) * (TMRx Prescale Value)
Delay = 4 * TOSC * (PWM1CON<6:0>)
FET
Driver +
P1A
-
Load
FET
Driver
+
P1B
-
V+
FET FET
Driver Driver
P1A
Load
FET FET
Driver Driver
P1B
PWM Period
PWM Activity
Start of
PWM Period
Shutdown Event
CCP1ASE bit
PWM
Shutdown Shutdown Resumes
Event Occurs Event Clears CCP1ASE
Cleared by
Firmware
PWM Period
PWM Activity
Start of
PWM Period
Shutdown Event
CCP1ASE bit
PWM
Shutdown Resumes
Event Occurs
Shutdown CCP1ASE
Event Clears Cleared by
Hardware
FET
Driver +
P1A V
-
Load
FET
Driver
+
P1B V
-
V-
PWM Period
PWM
STR1
P1n = PWM
PWM
STR1
P1n = PWM
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Reset
1 = Bit is set 0 = Bit is cleared
1011 = Compare mode: Special Event Trigger (CCP1 resets Timer, sets CCP1IF bit, and starts ADC conversion
if ADC module is enabled)
1010 = Compare mode: generate software interrupt only; ECCP1 pin reverts to I/O state
1001 = Compare mode: initialize ECCP1 pin high; clear output on compare match (set CCP1IF)
1000 = Compare mode: initialize ECCP1 pin low; set output on compare match (set CCP1IF)
0011 = Reserved
0010 = Compare mode: toggle output on match
0001 = Reserved
0000 = Capture/Compare/PWM off (resets ECCP1 module)
PWM mode:
1111 = PWM mode: P1A active-low; P1B active-low
1110 = PWM mode: P1A active-low; P1B active-high
1101 = PWM mode: P1A active-high; P1B active-low
1100 = PWM mode: P1A active-high; P1B active-high
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: Bit resets to 0 with Two-Speed Start-up and LP, XT or HS selected as the Oscillator mode or Fail-Safe
mode is enabled.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: The PWM Steering mode is available only when the CCP1CON register bits CCP1M<3:2> = 11 and
P1M<1:0> = 00.
Data Bus
Read Write
SSP1BUF Reg
SDI
SSP1SR Reg
SDO bit 0 Shift
Clock
Edge
Select
SSP1M<3:0>
4
( TMR22Output )
SCK
Edge Prescaler TOSC
Select 4, 16, 64
Baud rate
generator
TRIS bit (SSP1ADD)
Internal
data bus [SSP1M 3:0]
Read Write
Internal
Data Bus
Read Write
Shift
Clock
SSP1SR Reg
SDA MSb LSb
SSP1MSK Reg
SSP1ADD Reg
SCK SCK
SPI Master
SDO SDI SPI Slave
SDI SDO #1
General I/O SS
General I/O
General I/O SCK
SDI SPI Slave
SDO #2
SS
SCK
SDI SPI Slave
SDO #3
SS
Slave Select
General I/O SS
Processor 1 (optional) Processor 2
Write to
SSP1BUF
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)
SSP1IF
SSP1SR to
SSP1BUF
SCK SCK
SPI Master
SDO SDI SPI Slave
SDI SDO #1
General I/O SS
SCK
SDI SPI Slave
SDO #2
SS
SCK
SDI SPI Slave
SDO #3
SS
SS
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSP1BUF
Shift register SSP1SR
and bit count are reset
SSP1BUF to
SSP1SR
SDI bit 0
bit 7 bit 7
Input
Sample
SSP1IF
Interrupt
Flag
SSP1SR to
SSP1BUF
SS
Optional
SCK
(CKP = 0
CKE = 0)
SCK
(CKP = 1
CKE = 0)
Write to
SSP1BUF
Valid
SDO bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
SDI
bit 7 bit 0
Input
Sample
SSP1IF
Interrupt
Flag
SSP1SR to
SSP1BUF
Write Collision
detection active
SS
Not Optional
SCK
(CKP = 0
CKE = 1)
SCK
(CKP = 1
CKE = 1)
Write to
SSP1BUF
Valid
SDO bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
SDI
bit 7 bit 0
Input
Sample
SSP1IF
Interrupt
Flag
SSP1SR to
SSP1BUF
Write Collision
detection active
SDA
SCL
S P
Change of Change of
Data Allowed Data Allowed
Start Stop
Condition Condition
Sr
Change of Change of
Data Allowed Data Allowed
Restart
Condition
DS40001441F-page 210
Bus Master sends
Stop condition
From Slave to Master
SDA
A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 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
S P
SSP1IF
SSP1IF set on 9th
Cleared by software Cleared by software falling edge of
SCL
BF
First byte
SSP1BUF is read of data is
available
in SSP1BUF
SSP1OV
SSP1IF
BF
First byte
of data is
SSP1BUF is read available
in SSP1BUF
SSP1OV
DS40001441F-page 211
PIC12(L)F1840
Master Releases SDA Master sends
to slave for ACK sequence Stop condition
FIGURE 25-16:
DS40001441F-page 212
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
SSP1IF
PIC12(L)F1840
Slave software
clears ACKDT to Slave software
ACK the received sets ACKDT to
CKP byte not ACK
When AHEN = 1:
When DHEN = 1: CKP set by software,
CKP is cleared by hardware
CKP is cleared by SCL is released
and SCL is stretched hardware on 8th falling
edge of SCL
ACKTIM
P
I2C SLAVE, 7-BIT ADDRESS, RECEPTION (SEN = 0, AHEN = 1, DHEN = 1)
Stop condition
Master releases
R/W = 0 SDA to slave for ACK sequence
Receiving Address Receive Data Receive Data ACK
SDA ACK
A7 A6 A5 A4 A3 A2 A1 D7 D6 D5 D4 D3 D2 D1 D0 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 P
SSP1IF
Cleared by software No interrupt after
if not ACK
from Slave
BF
Received
address is loaded into Received data is SSP1BUF can be
SSP1BUF available on SSP1BUF read any time before
next byte is loaded
ACKDT
ACKTIM
P
I2C SLAVE, 7-BIT ADDRESS, RECEPTION (SEN = 1, AHEN = 1, DHEN = 1)
DS40001441F-page 213
PIC12(L)F1840
PIC12(L)F1840
25.5.3 SLAVE TRANSMISSION 25.5.3.2 7-bit Transmission
When the R/W bit of the incoming address byte is set A master device can transmit a read request to a
and an address match occurs, the R/W bit of the slave, and then clock data out of the slave. The list
SSP1STAT register is set. The received address is below outlines what software for a slave will need to
loaded into the SSP1BUF register, and an ACK pulse do to accomplish a standard transmission.
is sent by the slave on the ninth bit. Figure 25-18 can be used as a reference to this list.
Following the ACK, slave hardware clears the CKP bit 1. Master sends a Start condition on SDA and
and the SCL pin is held low (see Section 25.5.6 SCL.
Clock Stretching for more detail). By stretching the 2. S bit of SSP1STAT is set; SSP1IF is set if
clock, the master will be unable to assert another clock interrupt on Start detect is enabled.
pulse until the slave is done preparing the transmit 3. Matching address with R/W bit set is received by
data. the Slave setting SSP1IF bit.
The transmit data must be loaded into the SSP1BUF 4. Slave hardware generates an ACK and sets
register which also loads the SSP1SR register. Then SSP1IF.
the SCL pin should be released by setting the CKP bit 5. SSP1IF bit is cleared by user.
of the SSP1CON1 register. The eight data bits are
6. Software reads the received address from
shifted out on the falling edge of the SCL input. This
SSP1BUF, clearing BF.
ensures that the SDA signal is valid during the SCL
high time. 7. R/W is set so CKP was automatically cleared
after the ACK.
The ACK pulse from the master-receiver is latched on
8. The slave software loads the transmit data into
the rising edge of the ninth SCL input pulse. This ACK
SSP1BUF.
value is copied to the ACKSTAT bit of the SSP1CON2
register. If ACKSTAT is set (not ACK), then the data 9. CKP bit is set releasing SCL, allowing the mas-
transfer is complete. In this case, when the not ACK is ter to clock the data out of the slave.
latched by the slave, the slave goes idle and waits for 10. SSP1IF is set after the ACK response from the
another occurrence of the Start bit. If the SDA line was master is loaded into the ACKSTAT register.
low (ACK), the next transmit data must be loaded into 11. SSP1IF bit is cleared.
the SSP1BUF register. Again, the SCL pin must be 12. The slave software checks the ACKSTAT bit to
released by setting bit CKP. see if the master wants to clock out more data.
An MSSP1 interrupt is generated for each data transfer Note 1: If the master ACKs the clock will be
byte. The SSP1IF bit must be cleared by software and stretched.
the SSP1STAT register is used to determine the status
of the byte. The SSP1IF bit is set on the falling edge of 2: ACKSTAT is the only bit updated on the
the ninth clock pulse. rising edge of SCL (9th) rather than the
falling.
25.5.3.1 Slave Mode Bus Collision 13. Steps 9-13 are repeated for each transmitted
A slave receives a Read request and begins shifting byte.
data out on the SDA line. If a bus collision is detected 14. If the master sends a not ACK; the clock is not
and the SBCDE bit of the SSP1CON3 register is set, held, but SSP1IF is still set.
the BCL1IF bit of the PIRx register is set. Once a bus 15. The master sends a Restart condition or a Stop.
collision is detected, the slave goes idle and waits to be 16. The slave is no longer addressed.
addressed again. User software can use the BCL1IF bit
to handle a slave bus collision.
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
BF
BF is automatically
Received address Data to transmit is cleared after 8th falling
is read from SSPBUF loaded into SSPBUF edge of SCL
CKP
When R/W is set CKP is not
SCL is always held for not
held low after 9th SCL Set by software ACK
falling edge
ACKSTAT
Indicates an address
has been received
DS40001441F-page 215
PIC12(L)F1840
PIC12(L)F1840
25.5.3.3 7-bit Transmission with Address
Hold Enabled
Setting the AHEN bit of the SSP1CON3 register
enables additional clock stretching and interrupt
generation after the 8th falling edge of a received
matching address. Once a matching address has
been clocked in, CKP is cleared and the SSP1IF
interrupt is set.
Figure 25-19 displays a standard waveform of a 7-bit
Address Slave Transmission with AHEN enabled.
1. Bus starts Idle.
2. Master sends Start condition; the S bit of
SSP1STAT is set; SSP1IF is set if interrupt on
Start detect is enabled.
3. Master sends matching address with R/W bit
set. After the 8th falling edge of the SCL line the
CKP bit is cleared and SSP1IF interrupt is
generated.
4. Slave software clears SSP1IF.
5. Slave software reads ACKTIM bit of SSP1CON3
register, and R/W and D/A of the SSP1STAT
register to determine the source of the interrupt.
6. Slave reads the address value from the
SSP1BUF register clearing the BF bit.
7. Slave software decides from this information if it
wishes to ACK or not ACK and sets the ACKDT
bit of the SSP1CON2 register accordingly.
8. Slave sets the CKP bit releasing SCL.
9. Master clocks in the ACK value from the slave.
10. Slave hardware automatically clears the CKP bit
and sets SSP1IF after the ACK if the R/W bit is
set.
11. Slave software clears SSP1IF.
12. Slave loads value to transmit to the master into
SSP1BUF setting the BF bit.
Note: SSP1BUF cannot be loaded until after the
ACK.
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
BF BF is automatically
Received address Data to transmit is cleared after 8th falling
is read from SSP1BUF loaded into SSP1BUF edge of SCL
ACKDT
Slave clears
ACKDT to ACK
address
ACKSTAT
Masters ACK
response is copied
to SSP1STAT
CKP
When AHEN = 1; CKP not cleared
CKP is cleared by hardware When R/W = 1; Set by software, after not ACK
after receiving matching CKP is always releases SCL
address. cleared after ACK
ACKTIM
I2C SLAVE, 7-BIT ADDRESS, TRANSMISSION (AHEN = 1)
R/W
D/A
DS40001441F-page 217
PIC12(L)F1840
PIC12(L)F1840
25.5.4 SLAVE MODE 10-BIT ADDRESS 25.5.5 10-BIT ADDRESSING WITH ADDRESS OR
RECEPTION DATA HOLD
This section describes a standard sequence of events Reception using 10-bit addressing with AHEN or
for the MSSP1 module configured as an I2C slave in DHEN set is the same as with 7-bit modes. The only
10-bit Addressing mode. difference is the need to update the SSP1ADD register
Figure 25-20 is used as a visual reference for this using the UA bit. All functionality, specifically when the
description. CKP bit is cleared and SCL line is held low are the
same. Figure 25-21 can be used as a reference of a
This is a step by step process of what must be done by slave in 10-bit addressing with AHEN set.
slave software to accomplish I2C communication.
Figure 25-22 shows a standard waveform for a slave
1. Bus starts Idle. transmitter in 10-bit Addressing mode.
2. Master sends Start condition; S bit of
SSP1STAT is set; SSP1IF is set if interrupt on
Start detect is enabled.
3. Master sends matching high address with R/W
bit clear; UA bit of the SSP1STAT register is set.
4. Slave sends ACK and SSP1IF is set.
5. Software clears the SSP1IF bit.
6. Software reads received address from
SSP1BUF clearing the BF flag.
7. Slave loads low address into SSP1ADD,
releasing SCL.
8. Master sends matching low address byte to the
slave; UA bit is set.
Note: Updates to the SSP1ADD register are not
allowed until after the ACK sequence.
Master sends
Stop condition
Receive First Address Byte Receive Second Address Byte Receive Data Receive Data
SDA
1 1 1 1
0 A9 A8 ACK A7 A6 A5 A4 A3 A2 A1 A0 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK
SSP1IF
Set by hardware Cleared by software
on 9th falling edge
BF
If address matches Receive address is Data is read
SSP1ADD it is loaded into read from SSP1BUF from SSP1BUF
SSP1BUF
UA
When UA = 1; Software updates SSP1ADD
SCL is held low and releases SCL
CKP
DS40001441F-page 219
PIC12(L)F1840
Receive First Address Byte R/W = 0 Receive Second Address Byte Receive Data Receive Data
FIGURE 25-21:
DS40001441F-page 220
SCL S 1 2 3 4 5 6 7 8 9 UA 1 2 3 4 5 6 7 8 9 UA 1 2 3 4 5 6 7 8 9 1 2
PIC12(L)F1840
SSP1IF
Set by hardware Cleared by software Cleared by software
on 9th falling edge
BF
UA
Master sends
Master sends Stop condition
Restart event Master sends
not ACK
Receiving Address R/W = 0 Receiving Second Address Byte Receive First Address Byte Transmitting Data Byte ACK = 1
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
SSP1IF
BF
Indicates an address
has been received
I2C SLAVE, 10-BIT ADDRESS, TRANSMISSION (SEN = 0, AHEN = 0, DHEN = 0)
DS40001441F-page 221
PIC12(L)F1840
PIC12(L)F1840
25.5.6 CLOCK STRETCHING
Clock stretching occurs when a device on the bus
holds the SCL line low effectively pausing
communication. The slave may stretch the clock to
allow more time to handle data or prepare a response
for the master device. A master device is not
concerned with stretching as anytime it is active on the
bus and not transferring data it is stretching. Any
stretching done by a slave is invisible to the master
software and handled by the hardware that generates
SCL.
The CKP bit of the SSP1CON1 register is used to con-
trol stretching in software. Any time the CKP bit is
cleared, the module will wait for the SCL line to go low
and then hold it. Setting CKP will release SCL and
allow more communication.
25.5.6.1 Normal Clock Stretching
Following an ACK if the R/W bit of SSP1STAT is set, a
read request, the slave hardware will clear CKP. This
allows the slave time to update SSP1BUF with data to
transfer to the master. If the SEN bit of SSP1CON2 is
set, the slave hardware will always stretch the clock
after the ACK sequence. Once the slave is ready; CKP
is set by software and communication resumes.
Note 1: The BF bit has no effect on if the clock will
be stretched or not. This is different than
previous versions of the module that
would not stretch the clock, clear CKP, if
SSP1BUF was read before the 9th falling
edge of SCL.
2: Previous versions of the module did not
stretch the clock for a transmission if
SSP1BUF was loaded before the 9th fall-
ing edge of SCL. It is now always cleared
for read requests.
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
SDA DX DX 1
SCL
Master device
CKP asserts clock
Master device
releases clock
WR
SSP1CON1
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 by software
SSPBUF is read
GCEN (SSP1CON2<7>)
1
Master mode is enabled by setting and clearing the The master device generates all of the serial clock
appropriate SSPM bits in the SSP1CON1 register and pulses and the Start and Stop conditions. A transfer is
by setting the SSPEN bit. In Master mode, the SDA and ended with a Stop condition or with a Repeated Start
SCK pins must be configured as inputs. The MSSP condition. Since the Repeated Start condition is also
peripheral hardware will override the output driver TRIS the beginning of the next serial transfer, the I2C bus will
controls when necessary to drive the pins low. not be released.
Master mode of operation is supported by interrupt In Master Transmitter mode, serial data is output
generation on the detection of the Start and Stop through SDA, while SCL outputs the serial clock. The
conditions. The Stop (P) and Start (S) bits are cleared first byte transmitted contains the slave address of the
from a Reset or when the MSSP1 module is disabled. receiving device (7 bits) and the Read/Write (R/W) bit.
Control of the I 2C bus may be taken when the P bit is In this case, the R/W bit will be logic 0. Serial data is
set, or the bus is Idle. transmitted eight bits at a time. After each byte is
transmitted, an Acknowledge bit is received. Start and
In Firmware Controlled Master mode, user code Stop conditions are output to indicate the beginning
conducts all I 2C bus operations based on Start and and the end of a serial transfer.
Stop bit condition detection. Start and Stop condition
detection is the only active circuitry in this mode. All In Master Receive mode, the first byte transmitted con-
other communication is done by the user software tains the slave address of the transmitting device
directly manipulating the SDA and SCL lines. (7 bits) and the R/W bit. In this case, the R/W bit will be
logic 1. Thus, the first byte transmitted is a 7-bit slave
The following events will cause the SSP1 Interrupt Flag address followed by a 1 to indicate the receive bit.
bit, SSP1IF, to be set (SSP1 interrupt, if enabled): Serial data is received via SDA, while SCL outputs the
Start condition detected serial clock. Serial data is received 8 bits at a time. After
each byte is received, an Acknowledge bit is transmit-
Stop condition detected
ted. Start and Stop conditions indicate the beginning
Data transfer byte transmitted/received and end of transmission.
Acknowledge transmitted/received
A Baud Rate Generator is used to set the clock
Repeated Start generated frequency output on SCL. See Section 25.7 Baud
Note 1: The MSSP1 module, when configured in Rate Generator for more detail.
I2C Master mode, does not allow queuing
of events. For instance, the user is not
allowed to initiate a Start condition and
immediately write the SSP1BUF register
to initiate transmission before the Start
condition is complete. In this case, the
SSP1BUF will not be written to and the
WCOL bit will be set, indicating that a
write to the SSP1BUF did not occur
2: When in Master mode, Start/Stop detec-
tion is masked and an interrupt is gener-
ated when the SEN/PEN bit is cleared and
the generation is complete.
SDA DX DX 1
BRG decrements on
Q2 and Q4 cycles
BRG
03h 02h 01h 00h (hold off) 03h 02h
Value
TBRG
SCL
S
TBRG
DS40001441F-page 230
Write SSP1CON2<0> SEN = 1 ACKSTAT in
Start condition begins SSP1CON2 = 1
From slave, clear ACKSTAT bit SSP1CON2<6>
SEN = 0
Transmitting Data or Second Half
Transmit Address to Slave R/W = 0 ACK
of 10-bit Address
SDA A7 A6 A5 A4 A3 A2 A1 ACK = 0 D7 D6 D5 D4 D3 D2 D1 D0
PIC12(L)F1840
BF (SSP1STAT<0>)
PEN
R/W
I2C MASTER MODE WAVEFORM (TRANSMISSION, 7 OR 10-BIT ADDRESS)
begin Start condition ACK from Master Set ACKEN, start Acknowledge sequence
Master configured as a receiver SDA = ACKDT = 0 SDA = ACKDT = 1
by programming SSP1CON2<3> (RCEN = 1)
DS40001441F-page 232
SEN = 0
PEN bit = 1
Write to SSP1BUF occurs here, RCEN cleared RCEN = 1, start RCEN cleared
ACK from Slave next receive automatically written here
start XMIT automatically
Transmit Address to Slave Receiving Data from Slave Receiving Data from Slave
SDA A7 A6 A5 A4 A3 A2 A1 R/W ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK
Bus master
ACK is not sent
PIC12(L)F1840
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 SSP1IF at end
of receive Set SSP1IF interrupt
Set SSP1IF interrupt at end of Acknow-
Set SSP1IF interrupt ledge sequence
at end of receive at end of Acknowledge
SSP1IF sequence
Set P bit
Cleared by software Cleared by software Cleared by software Cleared by software (SSP1STAT<4>)
SDA = 0, SCL = 1 Cleared in
while CPU software and SSP1IF
responds to SSP1IF
BF
(SSP1STAT<0>) Last bit is shifted into SSP1SR and
contents are unloaded into SSP1BUF
SSP1OV
ACKEN
I2C MASTER MODE WAVEFORM (RECEPTION, 7-BIT ADDRESS)
RCEN
Master configured as a receiver RCEN cleared ACK from Master RCEN cleared
by programming SSP1CON2<3> (RCEN = 1) automatically SDA\ = ACKDT = 0 automatically
SCL 8 9
SSP1IF
Cleared in
SSP1IF set at software
the end of receive Cleared in
software SSP1IF set at the end
of Acknowledge sequence
Note: TBRG = one Baud Rate Generator period.
SDA ACK
P
TBRG TBRG TBRG
SCL brought high after TBRG
SDA asserted low before rising edge of clock
to setup Stop condition
SDA
BCL1IF
SDA
SCL
Set SEN, enable Start SEN cleared automatically because of bus collision.
condition if SDA = 1, SCL = 1 SSP1 module reset into Idle state.
SEN
SDA sampled low before
Start condition. Set BCL1IF.
S bit and SSP1IF set because
BCL1IF SDA = 0, SCL = 1.
SSP1IF and BCL1IF are
cleared by software
SSP1IF
TBRG TBRG
SDA
SSP1IF 0 0
FIGURE 25-35: BRG RESET DUE TO SDA ARBITRATION DURING START CONDITION
SDA = 0, SCL = 1
Set S Set SSP1IF
Less than TBRG
TBRG
SCL S
SCL pulled low after BRG
time-out
SEN
Set SEN, enable Start
sequence if SDA = 1, SCL = 1
BCL1IF 0
SSP1IF
SDA = 0, SCL = 1, Interrupts cleared
set SSP1IF by software
SDA
SCL
RSEN
BCL1IF
Cleared by software
S 0
SSP1IF 0
TBRG TBRG
SDA
SCL
S 0
SSP1IF
PEN
BCL1IF
P 0
SSP1IF 0
SDA
PEN
BCL1IF
P 0
SSP1IF 0
SSP1M<3:0> SSP1ADD<7:0>
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared HS = Bit is set by hardware C = User cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared HC = Cleared by hardware S = User set
bit 7 GCEN: General Call Enable bit (in I2C Slave mode only)
1 = Enable interrupt when a general call address (0x00 or 00h) is received in the SSP1SR
0 = General call address disabled
bit 6 ACKSTAT: Acknowledge Status bit (in I2C mode only)
1 = Acknowledge was not received
0 = Acknowledge was received
bit 5 ACKDT: Acknowledge Data bit (in I2C mode only)
In Receive mode:
Value transmitted when the user initiates an Acknowledge sequence at the end of a receive
1 = Not Acknowledge
0 = Acknowledge
bit 4 ACKEN: Acknowledge Sequence Enable bit (in I2C Master mode only)
In Master Receive mode:
1 = Initiate Acknowledge sequence on SDA and SCL pins, and transmit ACKDT data bit.
Automatically cleared by hardware.
0 = Acknowledge sequence idle
bit 3 RCEN: Receive Enable bit (in I2C Master mode only)
1 = Enables Receive mode for I2C
0 = Receive idle
bit 2 PEN: Stop Condition Enable bit (in I2C Master mode only)
SCKMSSP Release Control:
1 = Initiate Stop condition on SDA and SCL pins. Automatically cleared by hardware.
0 = Stop condition Idle
bit 1 RSEN: Repeated Start Condition Enable bit (in I2C Master mode only)
1 = Initiate Repeated Start condition on SDA and SCL pins. Automatically cleared by hardware.
0 = Repeated Start condition Idle
bit 0 SEN: Start Condition Enable/Stretch Enable bit
In Master mode:
1 = Initiate Start condition on SDA and SCL pins. Automatically cleared by hardware.
0 = Start condition Idle
In Slave mode:
1 = Clock stretching is enabled for both slave transmit and slave receive (stretch enabled)
0 = Clock stretching is disabled
Note 1: For bits ACKEN, RCEN, PEN, RSEN, SEN: If the I2C module is not in the Idle mode, this bit may not be
set (no spooling) and the SSP1BUF may not be written (or writes to the SSP1BUF are disabled).
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Note 1: For daisy-chained SPI operation; allows the user to ignore all but the last received byte. SSP1OV is still set
when a new byte is received and BF = 1, but hardware continues to write the most recent byte to
SSP1BUF.
2: This bit has no effect in Slave modes that Start and Stop condition detection is explicitly listed as enabled.
3: The ACKTIM Status bit is only active when the AHEN bit or DHEN bit is set.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
REGISTER 25-6: SSP1ADD: MSSP1 ADDRESS AND BAUD RATE REGISTER (I2C MODE)
R/W-0/0 R/W-0/0 R/W-0/0 R/W-0/0 R/W-0/0 R/W-0/0 R/W-0/0 R/W-0/0
ADD<7:0>
bit 7 bit 0
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Master mode:
bit 7-3 Not used: Unused for Most Significant Address byte. Bit state of this register is a dont care. Bit
pattern sent by master is fixed by I2C specification and must be equal to 11110. However, those bits
are compared by hardware and are not affected by the value in this register.
bit 2-1 ADD<2:1>: Two Most Significant bits of 10-bit address
bit 0 Not used: Unused in this mode. Bit state is a dont care.
10-Bit Slave mode Least Significant Address Byte:
TXEN
TRMT SPEN
Baud Rate Generator FOSC
n
TX9
BRG16 n
+1 Multiplier x4 x16 x64
TX9D
SYNC 1 X 0 0 0
SPBRGH SPBRGL BRGH X 1 1 0 0
BRG16 X 1 0 1 0
BRG16
+1 n
Multiplier x4 x16 x64
SYNC 1 X 0 0 0
SPBRGH SPBRGL BRGH FIFO
X 1 1 0 0 FERR RX9D RCREG Register
BRG16 X 1 0 1 0
8
Data Bus
RCIF Interrupt
RCIE
Write to TXREG
Word 1
BRG Output
(Shift Clock)
TX/CK
pin Start bit bit 0 bit 1 bit 7/8 Stop bit
Word 1
TXIF bit
(Transmit Buffer 1 TCY
Reg. Empty Flag)
Write to TXREG
Word 1 Word 2
BRG Output
(Shift Clock)
TX/CK
pin Start bit bit 0 bit 1 bit 7/8 Stop bit Start bit bit 0
TXIF bit 1 TCY Word 1 Word 2
(Transmit Buffer
Reg. Empty Flag) 1 TCY
CREN = 1 Immediately after all data bits and the Stop bit have
been received, the character in the RSR is transferred
SYNC = 0
to the EUSART receive FIFO and the RCIF interrupt
SPEN = 1 flag bit of the PIR1 register is set. The top character in
All other EUSART control bits are assumed to be in the FIFO is transferred out of the FIFO by reading the
their default state. RCREG register.
Setting the CREN bit of the RCSTA register enables the Note: If the receive FIFO is overrun, no additional
receiver circuitry of the EUSART. Clearing the SYNC bit characters will be received until the overrun
of the TXSTA register configures the EUSART for condition is cleared. See Section 26.1.2.5
asynchronous operation. Setting the SPEN bit of the Receive Overrun Error for more
RCSTA register enables the EUSART. The programmer information on overrun errors.
must set the corresponding TRIS bit to configure the
RX/DT I/O pin as an input. 26.1.2.3 Receive Interrupts
Note 1: If the RX/DT function is on an analog pin, The RCIF interrupt flag bit of the PIR1 register is set
the corresponding ANSEL bit must be whenever the EUSART receiver is enabled and there is
cleared for the receiver to function. an unread character in the receive FIFO. The RCIF
interrupt flag bit is read-only, it cannot be set or cleared
by software.
RCIF interrupts are enabled by setting all of the
following bits:
RCIE, Interrupt Enable bit of the PIE1 register
PEIE, Peripheral Interrupt Enable bit of the
INTCON register
GIE, Global Interrupt Enable bit of the INTCON
register
The RCIF interrupt flag bit will be set when there is an
unread character in the FIFO, regardless of the state of
interrupt enable bits.
Read Rcv
Buffer Reg.
RCREG
RCIF
(Interrupt Flag)
OERR bit
CREN
Note: This timing diagram shows three words appearing on the RX input. The RCREG (receive buffer) is read after the third word,
causing the OERR (overrun) bit to be set.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
TABLE 26-4: SUMMARY OF REGISTERS ASSOCIATED WITH THE BAUD RATE GENERATOR
Register
Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
on Page
BAUDCON ABDOVF RCIDL SCKP BRG16 WUE ABDEN 259
RCSTA SPEN RX9 SREN CREN ADDEN FERR OERR RX9D 258
SPBRGL BRG<7:0> 260*
SPBRGH BRG<15:8> 260*
TXSTA CSRC TX9 TXEN SYNC SENDB BRGH TRMT TX9D 257
Legend: = unimplemented, read as 0. Shaded cells are not used for the Baud Rate Generator.
* Page provides register information.
BAUD FOSC = 32.000 MHz FOSC = 20.000 MHz FOSC = 18.432 MHz FOSC = 11.0592 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300
1200
2400
9600 9615 0.16 207 9615 0.16 129 9600 0.00 119 9600 0.00 71
10417 10417 0.00 191 10417 0.00 119 10378 -0.37 110 10473 0.53 65
19.2k 19.23k 0.16 103 19.23k 0.16 64 19.20k 0.00 59 19.20k 0.00 35
57.6k 57.14k -0.79 34 56.82k -1.36 21 57.60k 0.00 19 57.60k 0.00 11
115.2k 117.64k 2.12 16 113.64k -1.36 10 115.2k 0.00 9 115.2k 0.00 5
BAUD FOSC = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300 0.16 207
1200 1202 0.16 207 1200 0.00 191 1202 0.16 51
2400 2404 0.16 207 2404 0.16 103 2400 0.00 95 2404 0.16 25
9600 9615 0.16 51 9615 0.16 25 9600 0.00 23
10417 10417 0.00 47 10417 0.00 23 10473 0.53 21 10417 0.00 5
19.2k 19231 0.16 25 19.23k 0.16 12 19.2k 0.00 11
57.6k 55556 -3.55 8 57.60k 0.00 3
115.2k 115.2k 0.00 1
BAUD FOSC = 32.000 MHz FOSC = 20.000 MHz FOSC = 18.432 MHz FOSC = 11.0592 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300.0 0.00 6666 300.0 -0.01 4166 300.0 0.00 3839 300.0 0.00 2303
1200 1200 -0.02 3332 1200 -0.03 1041 1200 0.00 959 1200 0.00 575
2400 2401 -0.04 832 2399 -0.03 520 2400 0.00 479 2400 0.00 287
9600 9615 0.16 207 9615 0.16 129 9600 0.00 119 9600 0.00 71
10417 10417 0.00 191 10417 0.00 119 10378 -0.37 110 10473 0.53 65
19.2k 19.23k 0.16 103 19.23k 0.16 64 19.20k 0.00 59 19.20k 0.00 35
57.6k 57.14k -0.79 34 56.818 -1.36 21 57.60k 0.00 19 57.60k 0.00 11
115.2k 117.6k 2.12 16 113.636 -1.36 10 115.2k 0.00 9 115.2k 0.00 5
BAUD FOSC = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 299.9 -0.02 1666 300.1 0.04 832 300.0 0.00 767 300.5 0.16 207
1200 1199 -0.08 416 1202 0.16 207 1200 0.00 191 1202 0.16 51
2400 2404 0.16 207 2404 0.16 103 2400 0.00 95 2404 0.16 25
9600 9615 0.16 51 9615 0.16 25 9600 0.00 23
10417 10417 0.00 47 10417 0.00 23 10473 0.53 21 10417 0.00 5
19.2k 19.23k 0.16 25 19.23k 0.16 12 19.20k 0.00 11
57.6k 55556 -3.55 8 57.60k 0.00 3
115.2k 115.2k 0.00 1
BAUD FOSC = 32.000 MHz FOSC = 20.000 MHz FOSC = 18.432 MHz FOSC = 11.0592 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300.0 0.00 26666 300.0 0.00 16665 300.0 0.00 15359 300.0 0.00 9215
1200 1200 0.00 6666 1200 -0.01 4166 1200 0.00 3839 1200 0.00 2303
2400 2400 0.01 3332 2400 0.02 2082 2400 0.00 1919 2400 0.00 1151
9600 9604 0.04 832 9597 -0.03 520 9600 0.00 479 9600 0.00 287
10417 10417 0.00 767 10417 0.00 479 10425 0.08 441 10433 0.16 264
19.2k 19.18k -0.08 416 19.23k 0.16 259 19.20k 0.00 239 19.20k 0.00 143
57.6k 57.55k -0.08 138 57.47k -0.22 86 57.60k 0.00 79 57.60k 0.00 47
115.2k 115.9k 0.64 68 116.3k 0.94 42 115.2k 0.00 39 115.2k 0.00 23
BAUD FOSC = 8.000 MHz FOSC = 4.000 MHz FOSC = 3.6864 MHz FOSC = 1.000 MHz
RATE SPBRG SPBRG SPBRG SPBRG
Actual % Actual % Actual % Actual %
value value value value
Rate Error Rate Error Rate Error Rate Error
(decimal) (decimal) (decimal) (decimal)
300 300.0 0.00 6666 300.0 0.01 3332 300.0 0.00 3071 300.1 0.04 832
1200 1200 -0.02 1666 1200 0.04 832 1200 0.00 767 1202 0.16 207
2400 2401 0.04 832 2398 0.08 416 2400 0.00 383 2404 0.16 103
9600 9615 0.16 207 9615 0.16 103 9600 0.00 95 9615 0.16 25
10417 10417 0 191 10417 0.00 95 10473 0.53 87 10417 0.00 23
19.2k 19.23k 0.16 103 19.23k 0.16 51 19.20k 0.00 47 19.23k 0.16 12
57.6k 57.14k -0.79 34 58.82k 2.12 16 57.60k 0.00 15
115.2k 117.6k 2.12 16 111.1k -3.55 8 115.2k 0.00 7
BRG Clock
RCIDL
RCIF bit
(Interrupt)
Read
RCREG
Note 1: The ABD sequence requires the EUSART module to be configured in Asynchronous mode.
RCIF
Cleared due to User Read of RCREG
Note 1: The EUSART remains in Idle while the WUE bit is set.
Note 1: If the wake-up event requires long oscillator warm-up time, the automatic clearing of the WUE bit can occur while the stposc signal is
still active. This sequence should not depend on the presence of Q clocks.
2: The EUSART remains in Idle while the WUE bit is set.
Write to TXREG
Dummy Write
BRG Output
(Shift Clock)
TX (pin) Start bit bit 0 bit 1 bit 11 Stop bit
Break
TXIF bit
(Transmit
Interrupt Flag)
TRMT bit
(Transmit Shift
Empty Flag)
SENDB Sampled Here Auto Cleared
SENDB
(send Break
control bit)
RX/DT
pin bit 0 bit 1 bit 2 bit 7 bit 0 bit 1 bit 7
Word 1 Word 2
TX/CK pin
(SCKP = 0)
TX/CK pin
(SCKP = 1)
Write to
TXREG Reg Write Word 1 Write Word 2
TXIF bit
(Interrupt Flag)
TRMT bit
1 1
TXEN bit
Note: Sync Master mode, SPBRGL = 0, continuous transmission of two 8-bit words.
TX/CK pin
Write to
TXREG reg
TXIF bit
TRMT bit
TXEN bit
RX/DT
pin bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7
TX/CK pin
(SCKP = 0)
TX/CK pin
(SCKP = 1)
Write to
bit SREN
SREN bit
CREN bit 0 0
RCIF bit
(Interrupt)
Read
RCREG
Note: Timing diagram demonstrates Sync Master mode with bit SREN = 1 and bit BRGH = 0.
Upon waking from Sleep, the instruction following the 26.6.3 ALTERNATE PIN LOCATIONS
SLEEP instruction will be executed. If the Global Inter-
This module incorporates I/O pins that can be moved to
rupt Enable (GIE) bit of the INTCON register is also set,
other locations with the use of the alternate pin function
then the Interrupt Service Routine at address 004h will
register, APFCON. To determine which pins can be
be called.
moved and what their default locations are upon a
Reset, see Section 12.1 Alternate Pin Function for
more information.
Timer0 Module
Set
TMR0CS TMR0IF
T0XCS
FOSC/4 0
Overflow
T0CKI 0 TMR0
1
CPSCH<3:0> 1
CPSON(1) CPSRNG<1:0>
CPSON
Capacitive
Sensing Timer1 Module
Oscillator
T1CS<1:0>
CPSOSC
CPS0 FOSC
CPS1 FOSC/4
CPSCLK
0 Int.
CPS2 TMR1H:TMR1L
Ref- DAC_output Ref. T1OSC/ EN
CPS3 1 CPSOUT T1CKI
0 T1GSEL<1:0>
Ref+
1 FVR T1G
Buffer2 Timer1 Gate
Control Logic
sync_C1OUT
CPSRM
Oscillator Module
VDD
(1)
(2)
+
-
S Q CPSCLK
CPSx
Internal
References
0 0
Ref- Ref+
CPSRM
Note 1: Module Enable and Current mode selections are not shown.
2: Comparators remain active in Noise Detection mode.
27.2 Capacitive Sensing Oscillator When the variable voltage references are used, the
DAC voltage determines the lower threshold level
The capacitive sensing oscillator consists of a constant (Ref-) and the FVR voltage determines the upper
current source and a constant current sink, to produce threshold level (Ref+). An advantage of using these
a triangle waveform. The CPSOUT bit of the reference sources is that oscillation frequency remains
CPSCON0 register shows the status of the capacitive constant with changes in VDD.
sensing oscillator, whether it is a sinking or sourcing Different oscillation frequencies can be obtained
current. The oscillator is designed to drive a capacitive through the use of these variable voltage references.
load (single PCB pad) and at the same time, be a clock The more the upper voltage reference level is lowered
source to either Timer0 or Timer1. The oscillator has and the more the lower voltage reference level is
several different current settings as defined by CPS- raised, the higher the capacitive sensing oscillator
RNG<1:0> of the CPSCON0 register. The different cur- frequency becomes.
rent settings for the oscillator serve two purposes:
Selection between the voltage references is controlled
Maximize the number of counts in a timer for a by the CPSRM bit of the CPSCON0 register. Setting
fixed time base. this bit selects the variable voltage references and
Maximize the count differential in the timer during clearing this bit selects the Fixed Voltage References.
a change in frequency.
Please see Section 14.0 Fixed Voltage Reference
(FVR) and Section 17.0 Digital-to-Analog Converter
(DAC) Module for more information on configuring the
variable voltage levels.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as 0
u = Bit is unchanged x = Bit is unknown -n/n = Value at POR and BOR/Value at all other Resets
1 = Bit is set 0 = Bit is cleared
RJ11-6PIN
R1
To MPLAB ICD 2 To Target Board
270 Ohm
LM431BCMX
2 A 1
K
3 A U1
6 A NC 4
7 A NC 5
VREF
8
R2 R3
10k 1% 24k 1%
ICSPDAT
2 4 6 NC
VDD
ICSPCLK
1 3 5
Target
VPP/MCLR VSS PC Board
Bottom Side
Pin Description*
1 = VPP/MCLR
2 = VDD Target
3 = VSS (ground)
4 = ICSPDAT
5 = ICSPCLK
6 = No Connect
Pin 1 Indicator
Pin Description*
1 1 = VPP/MCLR
2
2 = VDD Target
3
4 3 = VSS (ground)
5
6 4 = ICSPDAT
5 = ICSPCLK
6 = No Connect
External
Programming VDD Device to be
Signals Programmed
VDD VDD
VPP MCLR/VPP
VSS VSS
Data ICSPDAT
Clock ICSPCLK
* * *
To Normal Connections
OPCODE only
13 0
OPCODE
CONTROL OPERATIONS
BRA k Relative Branch 2 11 001k kkkk kkkk
BRW Relative Branch with W 2 00 0000 0000 1011
CALL k Call Subroutine 2 10 0kkk kkkk kkkk
CALLW Call Subroutine with W 2 00 0000 0000 1010
GOTO k Go to address 2 10 1kkk kkkk kkkk
RETFIE k Return from interrupt 2 00 0000 0000 1001
RETLW k Return with literal in W 2 11 0100 kkkk kkkk
RETURN Return from Subroutine 2 00 0000 0000 1000
INHERENT OPERATIONS
CLRWDT Clear Watchdog Timer 1 00 0000 0110 0100 TO, PD
NOP No Operation 1 00 0000 0000 0000
OPTION Load OPTION_REG register with W 1 00 0000 0110 0010
RESET Software device Reset 1 00 0000 0000 0001
SLEEP Go into Standby mode 1 00 0000 0110 0011 TO, PD
TRIS f Load TRIS register with W 1 00 0000 0110 0fff
C-COMPILER OPTIMIZED
ADDFSR n, k Add Literal k to FSRn 1 11 0001 0nkk kkkk
MOVIW n mm Move Indirect FSRn to W with pre/post inc/dec 1 00 0000 0001 0nmm Z 2, 3
modifier, mm
k[n] Move INDFn to W, Indexed Indirect. 1 11 1111 0nkk kkkk Z 2
MOVWI n mm Move W to Indirect FSRn with pre/post inc/dec 1 00 0000 0001 1nmm 2, 3
modifier, mm
k[n] Move W to INDFn, Indexed Indirect. 1 11 1111 1nkk kkkk 2
Note 1: If the Program Counter (PC) is modified, or a conditional test is true, the instruction requires two cycles. The second cycle
is executed as a NOP.
2: If this instruction addresses an INDF register and the MSb of the corresponding FSR is set, this instruction will require
one additional instruction cycle.
3: See Table in the MOVIW and MOVWI instruction descriptions.
C register f 0 Words: 1
Cycles: 1
Example: MOVF FSR, 0
After Instruction
LSRF Logical Right Shift
W = value in FSR register
Syntax: [ label ] LSRF f {,d} Z = 1
Operands: 0 f 127
d [0,1]
Operation: 0 dest<7>
(f<7:1>) dest<6:0>,
(f<0>) C,
Status Affected: C, Z
Description: The contents of register f are shifted
one bit to the right through the Carry
flag. A 0 is shifted into the MSb. If d is
0, the result is placed in W. If d is 1,
the result is stored back in register f.
0 register f C
Before Instruction
W = 0x07
After Instruction
W = value of k8
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.
5.5
VDD (V)
2.5
2.3
1.8
0 4 10 16 32
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
2: Refer to Table 30-1 for each Oscillator modes supported frequencies.
3.6
2.5
1.8
0 4 10 16 32
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
2: Refer to Table 30-1 for each Oscillator modes supported frequencies.
125
5%
85
3%
Temperature (C)
60
25 2%
5%
-40
1.8 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
VDD
VPOR
VPORR
VSS
NPOR(1)
POR REARM
VSS
TVLOW(2) TPOR(3)
20 29 45 A 5.0
D024 8.0 17 20 A 3.0 BOR Current (Note 1)
D024 8.0 17 30 A 3.0 BOR Current
9.0 20 40 A 5.0 VREGPM = 1 (Note 1)
D025 0.3 5 9 A 1.8 T1OSC Current (Note 1)
0.5 9 12 A 3.0
D025 1.1 6 10 A 2.3 T1OSC Current
1.3 9 20 A 3.0 VREGPM = 1 (Note 1)
1.4 10 25 A 5.0
D026 0.1 1.0 9 A 1.8 ADC Current (Note 1, 3)
0.1 2.0 10 A 3.0 No conversion in progress
D026 0.2 3.0 10 A 2.3 ADC Current
0.4 4.0 11 A 3.0 No conversion in progress
VREGPM = 1 (Note 1, 3)
0.5 6.0 16 A 5.0
* These parameters are characterized but not tested.
Data in Typ column is at 3.0V, 25C unless otherwise stated. These parameters are for design guidance only and are
not tested.
Note 1: The peripheral current is the sum of the base IDD or IPD and the additional current consumed when this peripheral is
enabled. The peripheral current can be determined by subtracting the base IDD or IPD current from this limit. Max.
values should be used when calculating total current consumption.
2: The power-down current in Sleep mode does not depend on the oscillator type. Power-down current is measured with
the part in Sleep mode, with all I/O pins in high-impedance state and tied to VSS.
3: ADC clock source is FRC.
TH01 JA Thermal Resistance Junction to Ambient 89.3 C/W 8-pin PDIP package
149.5 C/W 8-pin SOIC package
56.7 C/W 8-pin DFN package
39.4 C/W 8-pin UDFN 3X3mm package
TH02 JC Thermal Resistance Junction to Case 43.1 C/W 8-pin PDIP package
39.9 C/W 8-pin SOIC package
9.0 C/W 8-pin DFN package
40.3 C/W 8-pin UDFN 3X3mm package
TH03 TJMAX Maximum Junction Temperature 150 C
TH04 PD Power Dissipation W PD = PINTERNAL + PI/O
TH05 PINTERNAL Internal Power Dissipation W PINTERNAL = IDD x VDD(1)
TH06 PI/O I/O Power Dissipation W PI/O = (IOL * VOL) + (IOH * (VDD - VOH))
TH07 PDER Derated Power W PDER = PDMAX (TJ - TA)/JA(2)
Note 1: IDD is current to run the chip alone without driving any load on the output pins.
2: TA = Ambient Temperature, TJ = Junction Temperature.
1. TppS2ppS
2. TppS
T
F Frequency T Time
Lowercase letters (pp) and their meanings:
pp
cc CCP1 osc OSC1
ck CLKOUT rd RD
cs CS rw RD or WR
di SDIx sc SCKx
do SDO ss SS
dt Data in t0 T0CKI
io I/O PORT t1 T1CKI
mc MCLR wr WR
Uppercase letters and their meanings:
S
F Fall P Period
H High R Rise
I Invalid (High-impedance) V Valid
L Low Z High-impedance
Pin CL
VSS
Q4 Q1 Q2 Q3 Q4 Q1
OSC1/CLKIN
OS02
OS04 OS04
OS03
OSC2/CLKOUT
(LP,XT,HS Modes)
OSC2/CLKOUT
(CLKOUT Mode)
OS01 FOSC External CLKIN Frequency(1) DC 0.5 MHz External Clock (ECL)
DC 4 MHz External Clock (ECM)
DC 32 MHz External Clock (ECH)
Oscillator Frequency(1) 32.768 kHz LP Oscillator
0.1 4 MHz XT Oscillator
1 4 MHz HS Oscillator
1 20 MHz HS Oscillator, VDD > 2.7V
DC 4 MHz RC Oscillator, VDD > 2.0V
OS02 TOSC External CLKIN Period(1) 27 s LP Oscillator
250 ns XT Oscillator
50 ns HS Oscillator
50 ns External Clock (EC)
Oscillator Period(1) 30.5 s LP Oscillator
250 10,000 ns XT Oscillator
50 1,000 ns HS Oscillator
250 ns RC Oscillator
OS03 TCY Instruction Cycle Time(1) 200 TCY DC ns TCY = 4/FOSC
OS04* TosH, External CLKIN High, 2 s LP oscillator
TosL External CLKIN Low 100 ns XT oscillator
20 ns HS oscillator
OS05* TosR, External CLKIN Rise, 0 ns LP oscillator
TosF External CLKIN Fall 0 ns XT oscillator
0 ns HS oscillator
* These parameters are characterized but not tested.
Data in Typ column is at 3.0V, 25C unless otherwise stated. These parameters are for design guidance only and are not
tested.
Note 1: Instruction cycle period (TCY) equals four times the input oscillator time base period. All specified values are based on
characterization data for that particular oscillator type under standard operating conditions with the device executing code.
Exceeding these specified limits may result in an unstable oscillator operation and/or higher than expected current con-
sumption. All devices are tested to operate at min values with an external clock applied to OSC1 pin. When an external
clock input is used, the max cycle time limit is DC (no clock) for all devices.
MFINTOSC
Wake-up from Sleep Start-up Time 20 30 s
*These parameters are characterized but not tested.
Data in Typ column is at 3.0V, 25C unless otherwise stated. These parameters are for design guidance only and are not
tested.
Note 1: To ensure these oscillator frequency tolerances, VDD and VSS must be capacitively decoupled as close to the device as
possible. 0.1 F and 0.01 F values in parallel are recommended.
2: See Figure 31-64 and Figure 31-65, LFINTOSC Frequency Characteristics over VDD and Temperature.
FOSC
OS11 OS12
OS20
CLKOUT OS21
OS19 OS16 OS18
OS13 OS17
I/O pin
(Input)
OS15 OS14
I/O pin Old Value New Value
(Output)
OS18, OS19
VDD
MCLR
30
Internal
POR
33
PWRT
Time-out 32
OSC
Start-Up Time
Internal Reset(1)
Watchdog Timer
Reset(1)
31
34
34
I/O pins
VDD
VBOR and VHYST
VBOR
37
Reset
33(1)
(due to BOR)
T0CKI
40 41
42
T1CKI
45 46
47 49
TMR0 or
TMR1
CC01 CC02
CC03
BSF ADCON0, GO
1 TCY
AD134 (TOSC/2(1))
AD131
Q4
AD130
ADC CLK
ADC Data 7 6 5 4 3 2 1 0
ADIF 1 TCY
GO DONE
Note 1: If the ADC clock source is selected as RC, a time of TCY is added before the ADC clock starts. This allows the
SLEEP instruction to be executed.
BSF ADCON0, GO
AD134 (TOSC/2 + TCY(1)) 1 TCY
AD131
Q4
AD130
ADC CLK
ADC Data 7 6 5 4 3 2 1 0
ADIF 1 TCY
GO DONE
Note 1: If the ADC clock source is selected as RC, a time of TCY is added before the ADC clock starts. This allows the
SLEEP instruction to be executed.
CK
US121 US121
DT
US120 US122
CK
US125
DT
US126
SSx
SP70
SCKx
(CKP = 0)
SP71 SP72
SP78 SP79
SCKx
(CKP = 1)
SP79 SP78
SP80
SP75, SP76
SP74
SP73
SSx
SP81
SCKx
(CKP = 0)
SP71 SP72
SP79
SP73
SCKx
(CKP = 1)
SP80
SP78
SP75, SP76
SP74
SSx
SP70
SCKx SP83
(CKP = 0)
SP71 SP72
SP78 SP79
SCKx
(CKP = 1)
SP79 SP78
SP80
SP74
SP73
SP82
SSx
SP70
SCKx SP83
(CKP = 0)
SP71 SP72
SCKx
(CKP = 1)
SP80
SP77
SP75, SP76
SDIx
MSb In bit 6 - - - -1 LSb In
SP74
SCLx
SP91 SP93
SP90 SP92
SDAx
Start Stop
Condition Condition
SCLx
SP90
SP106
SP107
SP91 SP92
SDAx
In
SP110
SP109
SP109
SDAx
Out
I
TABLE 30-16: I2C BUS DATA REQUIREMENTS
Param.
Symbol Characteristic Min. Max. Units Conditions
No.
SP100* THIGH Clock high time 100 kHz mode 4.0 s Device must operate at a
minimum of 1.5 MHz
400 kHz mode 0.6 s Device must operate at a
minimum of 10 MHz
SSP module 1.5TCY
SP101* TLOW Clock low time 100 kHz mode 4.7 s Device must operate at a
minimum of 1.5 MHz
400 kHz mode 1.3 s Device must operate at a
minimum of 10 MHz
SSP module 1.5TCY
SP102* TR SDA and SCL rise 100 kHz mode 1000 ns
time 400 kHz mode 20 + 0.1CB 300 ns CB is specified to be from
10-400 pF
SP103* TF SDA and SCL fall 100 kHz mode 250 ns
time 400 kHz mode 20 + 0.1CB 250 ns CB is specified to be from
10-400 pF
SP106* THD:DAT Data input hold time 100 kHz mode 0 ns
400 kHz mode 0 0.9 s
SP107* TSU:DAT Data input setup 100 kHz mode 250 ns (Note 2)
time 400 kHz mode 100 ns
SP109* TAA Output valid from 100 kHz mode 3500 ns (Note 1)
clock 400 kHz mode ns
SP110* TBUF Bus free time 100 kHz mode 4.7 s Time the bus must be free
400 kHz mode 1.3 s before a new transmission
can start
SP111 CB Bus capacitive loading 400 pF
* These parameters are characterized but not tested.
Note 1: As a transmitter, the device must provide this internal minimum delay time to bridge the undefined region (min.
300 ns) of the falling edge of SCL to avoid unintended generation of Start or Stop conditions.
2: A Fast mode (400 kHz) I2C bus device can be used in a Standard mode (100 kHz) I2C bus system, but the
requirement TSU:DAT 250 ns must then be met. This will automatically be the case if the device does not
stretch the low period of the SCL signal. If such a device does stretch the low period of the SCL signal, it must
output the next data bit to the SDA line TR max. + TSU:DAT = 1000 + 250 = 1250 ns (according to the Standard
mode I2C bus specification), before the SCL line is released.
VCTH
VCTL
ISRC ISNK
Enabled Enabled
5.5
VDD (V)
2.5
1.8
0 4 10 16 32
Frequency (MHz)
Note 1: The shaded region indicates the permissible combinations of voltage and frequency.
2: Refer to Table 30-1 for each Oscillator modes supported frequencies.
FIGURE 30-24: HFINTOSC FREQUENCY ACCURACY OVER DEVICE VDD AND TEMPERATURE
150
10%
125
Temperature (C)
No Operation
85
25 5%
-40
1.8 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5
VDD (V)
TABLE 30-22: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, POWER-UP TIMER
AND BROWN-OUT RESET PARAMETERS FOR PIC12F1840-H (High Temp.)
Standard Operating Conditions: (unless otherwise stated)
PIC12F1840
Operating Temperature: -40C TA +150C for High Temperature
Param
Sym. Characteristic Min. Typ. Max. Units Conditions
No.
31 TWDTLP Low-Power Watchdog Timer 8 16 30 ms VDD = 3.3V-5V
Time-out Period (No Prescaler) 1:16 Prescaler used
35 VBOR Brown-out Reset Voltage(1) 2.50 2.70 2.90 V BORV = 0
BORV = 1
Data in Typ column is at 3.0V, 25C unless otherwise stated. These parameters are for design guidance
only and are not tested.
Note 1: To ensure these voltage tolerances, VDD and VSS must be capacitively decoupled as close to the device as
possible. 0.1 F and 0.01 F values in parallel are recommended.
TABLE 30-25: CAP SENSE OSCILLATOR SPECIFICATIONS FOR PIC12F1840-H (High Temp.)
Standard Operating Conditions: (unless otherwise stated)
PIC12F1840
Operating Temperature: -40C TA +150C for High Temperature
Param
Sym. Characteristic Min. Typ. Max. Units Conditions
No.
All All All This module is not intended for use in
high temperature devices.
25
15
IDD (A)
10 Typical
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
40
Max: 85C + 3
35 Max.
Typical: 25C
30
25
Typical
IDD (A)
20
15
10
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
500
350 4 MHz XT
300
IDD (A)
250
200
1 MHz XT
150
100
50
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
600
400 4 MHz XT
IDD (A)
300
1 MHz XT
200
100
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
4 MHz EXTRC
500 Typical: 25C
4 MHz XT
400
300
IDD (A)
1 MHz XT
200
100
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
600
Max: 85C + 3
4 MHz EXTRC
500
4 MHz XT
400
1 MHz XT
IDD (A)
300
200
100
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
16
Max: 85C + 3
14 Typical: 25C
Max.
12
10
IDD (A)
6 Typical
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
FIGURE 31-8: IDD, EXTERNAL CLOCK (ECL), LOW-POWER MODE, FOSC = 32 kHz,
PIC12F1840 ONLY
40
Max: 85C + 3
35 Typical: 25C Max.
30
25 Typical
IDD (A)
20
15
10
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
70
60 Max: 85C + 3
Typical: 25C
50 Max.
40 Typical
IDD (A)
30
20
10
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
FIGURE 31-10: IDD, EXTERNAL CLOCK (ECL), LOW-POWER MODE, FOSC = 500 kHz,
PIC12F1840 ONLY
70
60 Max.
50
IDD (A)
40
Typical
30
20
Max: 85C + 3
10 Typical: 25C
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
350
200
IDD (A)
150
100 1 MHz
50
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
400
250
IDD (A)
200
150
1 MHz
100
50
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
400
4 MHz
350 Typical: 25C
300
250
IDD (A)
200
150 1 MHz
100
50
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
FIGURE 31-14: IDD MAXIMUM, EXTERNAL CLOCK (ECM), MEDIUM-POWER MODE, PIC12F1840
ONLY
450
4 MHz
400 Max: 85C + 3
350
300
IDD (A)
250
200 1 MHz
150
100
50
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
2.5
Typical: 25C
32 MHz
2.0
1.5
IDD (mA)
16 MHz
1.0
8 MHz
0.5
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
3.0
2.0
IDD (mA)
1.5
16 MHz
1.0
8 MHz
0.5
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
2.5
2.0
1.5
IDD (mA)
16 MHz
1.0
8 MHz
0.5
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
2.5
Max: 85C + 3
32 MHz
2.0
16 MHz
1.5
IDD (mA)
1.0 8 MHz
0.5
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
30
20
IDD (A)
15
Typical
10
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
35
Max.
30
25 Typical
IDD (A)
20
15
10
5 Max: 85C + 3
Typical: 25C
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
200
120
IDD (A)
100
80
60
40
20
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
300
Max.
Max: 85C + 3
250 Typical: 25C
Typical
200
IDD (A)
150
100
50
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
3.0
Typical: 25C
2.5
1.5
16 MHz
1.0 8 MHz
4 MHz
0.5
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
5.0
4.0
3.5
32 MHz (4x PLL)
3.0
IDD (mA)
2.5
2.0 16 MHz
1.5 8 MHz
1.0 4 MHz
0.5
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
3.0
2.0
IDD (mA)
1.5 16 MHz
8 MHz
1.0
4 MHz
0.5
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
4.5
32 MHz (4x PLL)
4.0 Max: 85C + 3
3.5
3.0
IDD (mA)
2.5
16 MHz
2.0
1.5 8 MHz
1.0
4 MHz
0.5
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
1.8
1.4
1.2
1.0
IDD (mA)
0.8 8 MHz
0.6
4 MHz
0.4
0.2
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
2.5
Max: 85C + 3
2.0 32 MHz
1.5
IDD (mA)
1.0 8 MHz
4 MHz
0.5
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
2.0
32 MHz
1.8 Typical: 25C
1.6
1.4
1.2
IDD (mA)
1.0 8 MHz
0.8
4 MHz
0.6
0.4
0.2
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
2.5
32 MHz
Max: 85C + 3
2.0
1.5
IDD (mA)
8 MHz
1.0
4 MHz
0.5
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
450
Max: 85C + 3
M 3 Max.
400
Typical: 25C
350
300
D (nA)
250
IPD
200
150
100
Typical
50
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
FIGURE 31-32: IPD BASE, LOW-POWER SLEEP MODE, VREGPM = 1, PIC12F1840 ONLY
600
Max.
Max: 85C + 3
500 Typical: 25C
400
IPD (nA)
300
Typical
200
100
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
1.4
Max: 85C + 3
1.2 Typical: 25C
Max.
1.0
0 8
0.8
(A)
IPD (A
Typical
0.6
0.4
0.2
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
1.2
Max: 85C + 3
1.0
Typical: 25C
Max.
0.8
A)
IPD (A
0.6 Typical
0.4
0.2
0.0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
25
Max.
20 Typical
15
A)
IPD (A
10
Max: 85C + 3
5
Typical: 25C
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
30
25 Max.
20
Typical
IPD (A)
15
10
5 Max: 85C + 3
Typical: 25C
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
12
8
Typical
D (A)
6
IPD
0
16
1.6 1 8
1.8 2 0
2.0 2 2
2.2 2 4
2.4 2 6
2.6 2 8
2.8 3 0
3.0 3 2
3.2 3 4
3.4 3 6
3.6 3 8
3.8
VDD (V)
14
Max: 85C + 3
Ma Max
Max.
12 Typical: 25C
10
Typical
8
IPD (A)
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
6.0
Max: 85C + 3
5.0
Typical: 25C
Max.
4.0
A)
IPD (A
3.0
Typical
2.0
1.0
0.0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
12
Max: 85C + 3
10
Typical: 25C
Max.
8
IPD (A)
6 Typical
0
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
4
VOH (V)
3
125C
Typical
2
-40C
Graph represents
1
3 Limits
0
-45 -40 -35 -30 -25 -20 -15 -10 -5 0
IOH (mA)
FIGURE 31-42: VOL vs. IOL OVER TEMPERATURE, VDD = 5.5V, PIC12F1840 ONLY
125C
Graph represents
4 3 Limits
3
VOL (V)
Typical
2
-40C
0
0 10 20 30 40 50 60 70 80 90 100
IOL (mA)
3.5
Graph represents
3.0 3 Limits
2.5
VOH (V)
2.0
125C
1.5
Typical
1.0
-40C
0.5
0.0
-15 -13 -11 -9 -7 -5 -3 -1
IOH (mA)
3.0
125C
Graph represents
2.5
3 Limits
Typical
2.0
-40C
VOL (V)
1.5
1.0
0.5
0.0
0 5 10 15 20 25 30 35 40
IOL (mA)
2.0
1.4
125C
1.2
VOH (V)
1.0
Typical
0.8
0.6
-40C
0.4
0.2
0.0
-4.5 -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0
IOH (mA)
FIGURE 31-46: VOL vs. IOL OVER TEMPERATURE, VDD = 1.8V, PIC12LF1840 ONLY
1.8
Graph represents
1.6
3 Limits
1.4
125C
1.2
Typical
VOL (V)
1.0
-40C
0.8
0.6
0.4
0.2
0.0
0 1 2 3 4 5 6 7 8 9 10
IOL (mA)
1.70
1.68
Max.
1.66
1.64 Typical
1.62
Voltage (V)
Min.
1.60
1.58
1.56
1.50
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature (C)
1.54
1.46
Voltage (V)
1.44
Typical
1.42
1.40
Min.
1.38
1.36
1.34
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature (C)
2.00
Max.
1.95
Voltage (V)
Typical
1.90
1.85 Min.
Max: Typical + 3
Min: Typical - 3
1.80
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature (C)
60
50 Max.
Max: Typical + 3
40 Typical: 25C
Min: Typical - 3
Voltage (mV)
Typical
30
20
Min.
10
0
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature (C)
2.60
2.55 Max.
2.50
Typical
Voltage (V)
2.45
Min.
2.40
Max: Typical + 3
2.35 Min: Typical - 3
2.30
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature (C)
70
Max.
60
Max: Typical + 3
50 Typical: 25C
Min: Typical - 3
Voltage (mV)
40
Typical
30
20
Min.
10
0
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature (C)
2.80
2.75
Max.
2.70
Voltage (V)
Typical
2.65
Min.
Max: Typical + 3
2.60 Min: Typical - 3
2.55
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature (C)
2.50
Max.
Max: Typical + 3
2.40
Min: Typical - 3
2.30
Typical
Voltage (V)
2.20
2.10
2.00
Min.
1.90
1.80
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature (C)
45
25
Min.
20
15
10
0
-60 -40 -20 0 20 40 60 80 100 120 140
Temperature (C)
24
22 Max.
20
Time (ms)
18 Typical
16
Min.
14
100
80
Time (ms)
70 Typical
60
Min.
50
40
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
40
Max: Typical + 3
35 Max. Typical: statistical mean @ 25C
30
Typical
25
Time (us)
20
15
Note:
10 The FVR Stabilization Period applies when:
1) coming out of RESET or exiting Sleep mode for PIC12/16LFxxxx devices.
2) when exiting sleep mode with VREGPM = 1 for PIC12/16Fxxxx devices
5 In all other cases, the FVR is stable when released from RESET.
0
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
80
70
Max.
60
Typical
Hysteresis (mV)
50
40
Min.
30
20 Max: Typical + 3
Typical: 25C
10 Min: Typical - 3
0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
16
14 Max.
12
Typical
Hysteresis (mV)
10
6
Min.
4
Max: Typical + 3
2 Typical: 25C
Min: Typical - 3
0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
350
300
250
Max.
Time (ns)
200
Typical
150
100
Max: Typical + 3
50 Typical: 25C
0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
400
250
Time (ns)
125C
200
150
Typical
100
-40C
50
0
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
50
40
30
Max.
20
Offset Voltage (mV)
10
Typical
0
Min.
-10
-20
-50
0.0 1.0 2.0 3.0 4.0 5.0
Common Mode Voltage (V)
36
34
Max.
32
30
Typical
Frequency (kHz)
28
26 Min.
24
Max: Typical + 3 (-40C to +125C)
22 Typical: statistical mean @ 25C
Min: Typical - 3 (-40C to +125C)
20
1.6 1.8 2.0 2.2 2.4 2.6 2.8 3.0 3.2 3.4 3.6 3.8
VDD (V)
FIGURE 31-65: LFINTOSC FREQUENCY OVER VDD AND TEMPERATURE, PIC12F1840 ONLY
36
34
Max.
32
30
Frequency (kHz)
Typical
28
26 Min.
24
Max: Typical + 3 (-40C to +125C)
22 Typical: statistical mean @ 25C
Min: Typical - 3 (-40C to +125C)
20
2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
20
15
Sink Typical
Sink Max.
10
5 Sink Min.
IPIN (uA)
-5 Source Min.
5
Max: Typical + 3
4 Typical:
Min: Typical - 3
3 Sink Max.
Sink Typical
2
1 Sink Min.
IPIN (uA)
-1 Source Min.
-2
Source Typical
-3 Source Max.
-4
-5
1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
VDD (V)
0.0
IPIN (uA)
The MPASM Assembler generates relocatable object Support for the entire device instruction set
files for the MPLINK Object Linker, Intel standard HEX Support for fixed-point and floating-point data
files, MAP files to detail memory usage and symbol Command-line interface
reference, absolute LST files that contain source lines Rich directive set
and generated machine code, and COFF files for Flexible macro language
debugging.
MPLAB X IDE compatibility
The MPASM Assembler features include:
Integration into MPLAB X IDE projects
User-defined macros to streamline
assembly code
Conditional assembly for multipurpose
source files
Directives that allow complete control over the
assembly process
XXXXXXXX 12F1840
XXXXXNNN /P017
YYWW 1212
12F1840
/SN1212
NNN 017
Note: In the event the full Microchip part number cannot be marked on one line, it will
be carried over to the next line, thus limiting the number of available
characters for customer-specific information.
XXXX MFQ0
YYWW 1212
NNN 017
PIN 1 PIN 1
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
D A
N B
E1
NOTE 1
1 2
TOP VIEW
C A A2
PLANE
L c
A1
e eB
8X b1
8X b
.010 C
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
DATUM A DATUM A
b b
e e
2 2
e e
Units INCHES
Dimension Limits MIN NOM MAX
Number of Pins N 8
Pitch e .100 BSC
Top to Seating Plane A - - .210
Molded Package Thickness A2 .115 .130 .195
Base to Seating Plane A1 .015 - -
Shoulder to Shoulder Width E .290 .310 .325
Molded Package Width E1 .240 .250 .280
Overall Length D .348 .365 .400
Tip to Seating Plane L .115 .130 .150
Lead Thickness c .008 .010 .015
Upper Lead Width b1 .040 .060 .070
Lower Lead Width b .014 .018 .022
Overall Row Spacing eB - - .430
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. Significant Characteristic
3. Dimensions D and E1 do not include mold flash or protrusions. Mold flash or
protrusions shall not exceed .010" per side.
4. Dimensioning and tolerancing per ASME Y14.5M
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
!"#$%
&
!
"# $% &"'""
($)
%
*++&&&!
!+$
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
8-Lead Ultra Thin Plastic Dual Flat, No Lead Package (RF) - 3x3x0.50 mm Body [UDFN]
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
D A B
N
(DATUM A)
(DATUM B)
E
NOTE 1
2X
0.10 C
1 2
2X
0.10 C TOP VIEW
0.05 C A1
C
A
SEATING
PLANE 8X
(A3) 0.05 C
SIDE VIEW
0.10 C A B
D2
1 2
L
0.10 C A B
E2
NOTE 1
K
N
e 8X b
e 0.10 C A B
2
BOTTOM VIEW
Microchip Technology Drawing C04-254A Sheet 1 of 2
8-Lead Ultra Thin Plastic Dual Flat, No Lead Package (RF) - 3x3x0.50 mm Body [UDFN]
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
Units MILLIMETERS
Dimension Limits MIN NOM MAX
Number of Terminals N 8
Pitch e 0.65 BSC
Overall Height A 0.45 0.50 0.55
Standoff A1 0.00 0.02 0.05
Terminal Thickness A3 0.065 REF
Overall Width E 3.00 BSC
Exposed Pad Width E2 1.40 1.50 1.60
Overall Length D 3.00 BSC
Exposed Pad Length D2 2.20 2.30 2.40
Terminal Width b 0.25 0.30 0.35
Terminal Length L 0.35 0.45 0.55
Terminal-to-Exposed-Pad K 0.20 - -
Notes:
1. Pin 1 visual index feature may vary, but must be located within the hatched area.
2. Package is saw singulated
3. Dimensioning and tolerancing per ASME Y14.5M
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
REF: Reference Dimension, usually without tolerance, for information purposes only.
8-Lead Ultra Thin Plastic Dual Flat, No Lead Package (RF) - 3x3x0.50 mm Body [UDFN]
Note: For the most current package drawings, please see the Microchip Packaging Specification located at
http://www.microchip.com/packaging
C
X2
Y2
X1
G1
G2
SILK SCREEN
Y1
Units MILLIMETERS
Dimension Limits MIN NOM MAX
Contact Pitch E 0.65 BSC
Optional Center Pad Width X2 1.60
Optional Center Pad Length Y2 2.40
Contact Pad Spacing C 2.90
Contact Pad Width (X8) X1 0.35
Contact Pad Length (X8) Y1 0.85
Contact Pad to Contact Pad (X6) G1 0.20
Contact Pad to Center Pad (X8) G2 0.30
Notes:
1. Dimensioning and tolerancing per ASME Y14.5M
BSC: Basic Dimension. Theoretically exact value shown without tolerances.
Microchip Technology Drawing C04-2254A
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchips Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
QUALITY MANAGEMENT SYSTEM Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
CERTIFIED BY DNV Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Companys quality system processes and procedures
== ISO/TS 16949 ==
are for its PIC MCUs and dsPIC DSCs, KEELOQ code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchips quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.