3.0 Flash Program Memory Self Read/Self Write Control ............................................................................................................... 25
7.0 Timer1 Module with Gate Control .............................................................................................................................................. 57
18.0 Instruction Set Summary ......................................................................................................................................................... 140
19.0 Special Features of the CPU ................................................................................................................................................... 149
21.0 Development Support .............................................................................................................................................................. 169
23.0 DC and AC Characteristics Graphs and Charts ...................................................................................................................... 197
24.0 Packaging Information ............................................................................................................................................................. 216
The Microchip Web Site .................................................................................................................................................................... 228
Customer Change Notification Service ............................................................................................................................................. 228
Customer Support ............................................................................................................................................................................. 228
Product Identification System ............................................................................................................................................................ 229
DS40001709B-page 4Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
TO OUR VALUED CUSTOMERS
It is our intention to provide our valued customers with the best documentation possible to ensure successful use of your Microchip
products. To this end, we will continue to improve our publications to better suit your needs. Our publications will be refined and
enhanced as new volumes and updates are introduced.
If you have any questions or comments regarding this publication, please contact the Marketing Communications Department via
E-mail at docerrors@microchip.com. We welcome your feedback.
Most Current Data Sheet
To obtain the most up-to-date version of this data sheet, please register at our Worldwide Web site at:
http://www.microchip.com
You can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page.
The last character of the literature number is the version number, (e.g., DS30000000A is version A of document DS30000000).
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:
• Microchip’s 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.
Customer Notification System
Register on our web site at www.microchip.com to receive the most current information on all of our products.
Block Diagrams and pinout descriptions of the devices
are shown in Figure 1-1 and Ta bl e 1- 1.
The PIC16F753/HV753 devices are covered by this
data sheet. They are available in 14-pin PDIP, SOIC,
TSSOP and 16-pin QFN packages.
FIGURE 1-1:PIC16F753/HV753 BLOCK DIAGRAM
DS40001709B-page 6Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
TABLE 1-1:PIC16F753/HV753 PINOUT DESCRIPTION
NameFunction
RA0/AN0/C1IN0+/DACOUT/
FVROUT/ICSPDAT
RA1/AN1/C1IN0-/C2IN0-/
REF+/FVRIN/ICSPCLK
V
RA2/AN2/INT/C1OUT/
T0CKI/COG1FLT
(1)
(3)
/T1G
RA3
RA4/AN3/T1G
RA5/T1CKI/COG1OUT0
C2IN1-/CLKIN
RC0/AN4/OPA1IN+/C2IN0+RC0TTLCMOS General purpose I/O with IOC and WPU.
RC1/AN5/OPA1IN-/C1IN1-/
C2IN1-
Legend: AN = Analog input or outputCMOS = CMOS compatible input or output
Note 1:Input only.
/VPP/MCLR
(2)
/CLKOUTRA4TTLCMOS General purpose I/O with IOC and WPU.
TTL = TTL compatible inputST= Schmitt Trigger input with CMOS levels
HP = High PowerHV= High Voltage
* Alternate pin function.
2:Default pin function via the APFCON register.
3:Alternate pin function via the APFCON register.
4:RA3 pull-up is enabled when pin is configured as MCLR
(4)
(3)
RA0TTLHPGeneral purpose I/O with IOC and WPU.
AN0AN—A/D Channel 0 input.
C1IN0+AN—Comparator C1 positive input.
DACOUT—ANDAC unbuffered Voltage Reference output.
FVROUT—ANDAC/FVR buffered Voltage Reference output.
RC3/AN7/C1IN3-/C2IN3-RC3TTLCMOS General purpose I/O with IOC and WPU.
RC4/COG1OUT1/C2OUTRC4TTLCMOS General purpose I/O with IOC and WPU.
RC5/COG1OUT0/CCP1RC5TTLCMOS General purpose I/O with IOC and WPU.
DDVDDPower—Positive supply.
V
V
SSVSSPower—Ground reference.
Legend: AN = Analog input or outputCMOS = CMOS compatible input or output
Note 1:Input only.
TTL = TTL compatible inputST= Schmitt Trigger input with CMOS levels
HP = High PowerHV= High Voltage
* Alternate pin function.
2:Default pin function via the APFCON register.
3:Alternate pin function via the APFCON register.
4:RA3 pull-up is enabled when pin is configured as MCLR
RC2TTLCMOS General purpose I/O with IOC and WPU.
AN6AN—A/D Channel 6 input.
OPA1OUTANHPOp amp output.
C1IN2-AN—Comparator C1 negative input.
C2IN2-AN—Comparator C2 negative input.
AN7AN—A/D Channel 7 input.
C1IN3-AN—Comparator C1 negative input.
C2IN3-AN—Comparator C2 negative input.
COG1OUT1—CMOS COG output Channel 1.
C2OUT—HPComparator C2 output.
COG1OUT0—CMOS COG output Channel 0.
CCP1—HPCapture/Compare/PWM 1.
Input
Type
Output
Typ e
Description
in Configuration Word.
DS40001709B-page 8Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
PC<12:0>
13
0000h
0004h
0005h
07FFh
0400h
1FFFh
Stack Level 1
Stack Level 8
Reset Vector
Interrupt Vector
On-chip Program
Memory
CALL, RETURN
RETFIE, RETLW
Stack Level 2
Shadows 0-07FFh
2.0MEMORY ORGANIZATION
2.1Program Memory Organization
The PIC16F753/HV753 has a 13-bit program counter
capable of addressing an 8K x 14 program memory
space. Only the first 2K x 14 (0000h-07FFh) is
physically implemented. Accessing a location above
these boundaries will cause a wrap-around within the
first 2K x 14 space for PIC16F753/HV753. The Reset
vector is at 0000h and the interrupt vector is at 0004h
(see Figure 2-1).
FIGURE 2-1:PROGRAM MEMORY MAP
AND STACK FOR THE
PIC16F753/HV753
2.2Data Memory Organization
The data memory (see Figure 2-2) is partitioned into four
banks, which contain the General Purpose Registers
(GPR) and the Special Function Registers (SFR). The
Special Function Registers are located in the first 32
locations of each bank. Register locations 40h-6Fh in
Bank 0 are General Purpose Registers, implemented as
static RAM. Register locations 70h-7Fh in Bank 0 are
Common RAM and shared as the last 16 addresses in
all Banks. All other RAM is unimplemented and returns
‘0’ when read. The RP<1:0> bits of the STATUS register
are the bank select bits.
RP0
RP1
00 Bank 0 is selected
01 Bank 1 is selected
10 Bank 2 is selected
11 Bank 3 is selected
2.2.1GENERAL PURPOSE REGISTER
FILE
The register file is organized as 64 x 8 in the
PIC16F753/HV753. Each register is accessed, either
directly or indirectly, through the File Select Register
(FSR) (see Section 2.5 “Indirect Addressing, INDF
and FSR Registers”).
2.2.2SPECIAL FUNCTION REGISTERS
The Special Function Registers are registers used by
the CPU and peripheral functions for controlling the
desired operation of the device (see Tab le 2 -1 ). These
registers are static RAM.
The special registers can be classified into two sets:
core and peripheral. The Special Function Registers
associated with the “core” are described in this section.
Those related to the operation of the peripheral features
are described in the section of that peripheral feature.
DS40001709B-page 14Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
2.3Global SFRs
writable. Therefore, the result of an instruction with the
STATUS register as destination may be different than
2.3.1STATUS REGISTER
The STATUS register, shown in Register 2-1, contains:
• the arithmetic status of the ALU
• the Reset status
• the bank select bits for data memory (RAM)
The STATUS register can be the destination for any
instruction, like any other register. If the STATUS
register is the destination for an instruction that affects
the Z, DC or C bits, then the write to these three bits is
intended.
For example, CLRF STATUS, will clear the upper three
bits and set the Z bit. This leaves the STATUS register
as ‘000u u1uu’ (where u = unchanged).
It is recommended, therefore, that only BCF, BSF,SWAPF and MOVWF instructions are used to alter the
STATUS register, because these instructions do not
affect any Status bits. For other instructions not
affecting any Status bits, see Section 18.0
“Instruction Set Summary”.
disabled. These bits are set or cleared according to the
device logic. Furthermore, the TO
and PD bits are not
REGISTER 2-1:STATUS: STATUS REGISTER
R/W-0R/W-0R/W-0R-1R-1R/W-xR/W-xR/W-x
IRPRP1RP0TO
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
PDZDC
(1)
(1)
C
bit 7IRP: Register Bank Select bit (used for indirect addressing)
1 = Bank 2, 3 (100h-1FFh)
0 = Bank 0, 1 (00h-FFh)
bit 6RP1: Register Bank Select bit (used for direct addressing)
00 = Bank 0 (00h-7Fh)
01 = Bank 1 (80h-FFh)
10 = Bank 2 (100h-17Fh)
11 = Bank 3 (180h-1FFh)
bit 5RP0: Register Bank Select bit (used for direct addressing)
1 = Bank 1 (80h-FFh)
0 = Bank 0 (00h-7Fh)
bit 4TO
bit 3PD
bit 2Z: Zero bit
bit 1DC: Digit Carry/Borrow
bit 0C: Carry/Borrow
: Time-Out bit
1 = After power-up, CLRWDT instruction or SLEEP instruction
0 = A WDT time-out occurred
: Power-Down bit
1 = After power-up or by the CLRWDT instruction
0 = By execution of the SLEEP instruction
1 = The result of an arithmetic or logic operation is zero
0 = The result of an arithmetic or logic operation is not zero
1 = A carry-out from the 4th low-order bit of the result occurred
0 = No carry-out from the 4th low-order bit of the result
bit
1 = A carry-out from the Most Significant bit of the result occurred
0 = No carry-out from the Most Significant bit of the result occurred
(2)
bit
(ADDWF, ADDLW,SUBLW,SUBWF instructions), For Borrow, the polarity is reversed.
(2)
(ADDWF, ADDLW, SUBLW, SUBWF instructions)
Note 1:The C and DC bits operate as a Borrow
instructions for examples.
2:For Borrow
For rotate (RRF, RLF) instructions, this bit is loaded with either the high-order or low-order bit of the source register.
1 = Increment on high-to-low transition on T0CKI pin
0 = Increment on low-to-high transition on T0CKI pin
bit 3PSA: Prescaler Assignment bit
1 = Prescaler is assigned to the WDT
0 = Prescaler is assigned to the Timer0 module
bit 2-0PS<2:0>: Prescaler Rate Select bits
OSC/4)
DS40001709B-page 16Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
2.3.3INTCON REGISTER
The INTCON register is a readable and writable
register, which contains the various enable and flag bits
for TMR0 register overflow, IOCIE change and external
RA2/INT pin interrupts.
Note:Interrupt flag bits are set when an interrupt
condition occurs, regardless of the state of
its corresponding enable bit or the Global
Enable bit, GIE of the INTCON register.
User software should ensure the
appropriate interrupt flag bits are clear
prior to enabling an interrupt.
REGISTER 2-3:INTCON: INTERRUPT CONTROL REGISTER
R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0
GIEPEIET0IEINTEIOCIET0IFINTFIOCIF
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7GIE: Global Interrupt Enable bit
1 = Enables all unmasked interrupts
0 = Disables all interrupts
bit 6PEIE: Peripheral Interrupt Enable bit
1 = Enables all unmasked peripheral interrupts
0 = Disables all peripheral interrupts
bit 5T0IE: Timer0 Overflow Interrupt Enable bit
1 = Enables the Timer0 interrupt
0 = Disables the Timer0 interrupt
bit 4INTE: RA2/INT External Interrupt Enable bit
1 = Enables the RA2/INT external interrupt
0 = Disables the RA2/INT external interrupt
bit 3IOCIE: Interrupt-on-Change Interrupt Enable bit
1 = Enables the IOC change interrupt
0 = Disables the IOC change interrupt
bit 2T0IF: Timer0 Overflow Interrupt Flag bit
1 = Timer0 register has overflowed (must be cleared in software)
0 = Timer0 register did not overflow
bit 1INTF: RA2/INT External Interrupt Flag bit
1 = The RA2/INT external interrupt occurred (must be cleared in software)
0 = The RA2/INT external interrupt did not occur
bit 0IOCIF: Interrupt-on-Change Interrupt Flag bit
1 = An IOC pin has changed state and generated an interrupt
0 = No pin interrupts have been generated
(2)
(1)
Note 1: IOC register must also be enabled.
2: T0IF bit is set when TMR0 rolls over. TMR0 is unchanged on Reset and should be initialized before
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7TMR1GIF: TMR1 Gate Interrupt Flag bit
1 = Timer1 gate interrupt is pending
0 = Timer1 gate interrupt is not pending
bit 6ADIF: ADC Interrupt Flag bit
1 = ADC conversion complete
0 = ADC conversion has not completed or has not been started
bit 5-4Unimplemented: Read as ‘0’
bit 3HLTMR2IF: HLT2 to HLTPR2 Match Interrupt Flag bit
1 = HLT2 to HLTPR2 match occurred (must be cleared in software)
0 = HLT2 to HLTPR2 match did not occur
bit 2HLTMR1IF: HLT1 to HLTPR1 Match Interrupt Flag bit
1 = HLT1 to HLTPR1 match occurred (must be cleared in software)
0 = HLT1 to HLTPR1 match did not occur
bit 1TMR2IF: Timer2 to PR2 Match Interrupt Flag bit
1 = Timer2 to PR2 match occurred (must be cleared in software)
0 = Timer2 to PR2 match did not occur
bit 0TMR1IF: Timer1 Interrupt Flag bit
1 = Timer1 rolled over (must be cleared in software)
0 = Timer1 has not rolled over
——HLTMR2IFHLTMR1IFTMR2IFTMR1IF
Note:Interrupt flag bits are set when an interrupt
condition occurs, regardless of the state of
its corresponding enable bit or the Global
Enable bit, GIE of the INTCON register.
User software should ensure the
appropriate interrupt flag bits are clear prior
to enabling an interrupt.
DS40001709B-page 20Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
2.3.7PIR2 REGISTER
The PIR2 register contains the Peripheral Interrupt flag
bits, as shown in Register 2-7.
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7-6Unimplemented: Read as ‘0’
bit 5C2IF: Comparator 1 Interrupt Flag bit
1 = Comparator output (C2OUT bit) has changed (must be cleared in software)
0 = Comparator output (C2OUT bit) has not changed
bit 4C1IF: Comparator 1 Interrupt Flag bit
1 = Comparator output (C1OUT bit) has changed (must be cleared in software)
0 = Comparator output (C1OUT bit) has not changed
bit 3Unimplemented: Read as ‘0’
bit 2COG1IF: COG 1 Interrupt Flag bit
1 = COG1 has generated an auto-shutdown interrupt
0 = COG1 has NOT generated an auto-shutdown interrupt
bit 1Unimplemented: Read as ‘0’
bit 0CCP1IF: ECCP Interrupt Flag bit
Capture Mode
1 = A TMR1 register capture occurred (must be cleared in software)
0 = No TMR1 register capture occurred
Compare Mode
1 = A TMR1 register compare match occurred (must be cleared in software)
0 = No TMR1 register compare match occurred
PWM mode
Unused in this mode
Note:Interrupt flag bits are set when an interrupt
condition occurs, regardless of the state of
its corresponding enable bit or the Global
Enable bit, GIE of the INTCON register.
User software should ensure the
appropriate interrupt flag bits are clear prior
to enabling an interrupt.
The Power Control (PCON) register (see Tab le 19 -2 )
contains flag bits to differentiate between a:
• Power-on Reset (POR
• Brown-out Reset (BOR)
• Watchdog Timer Reset (WDT)
• External MCLR
The PCON register also controls the software enable of
the BOR
The PCON register bits are shown in Register 2-8.
.
REGISTER 2-8:PCON: POWER CONTROL REGISTER
U-0U-0U-0U-0U-0U-0R/W-q/uR/W-q/u
——————PORBOR
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is clearedq = unchanged
)
Reset
bit 7-2Unimplemented: Read as ‘0’
bit 1POR
bit 0BOR
: Power-on Reset Status bit
1 = No Power-on Reset occurred
0 = A Power-on Reset occurred (must be set in software after a Power-on Reset occurs)
: Brown-out Reset Status bit
1 = No Brown-out Reset occurred
0 = A Brown-out Reset occurred (must be set in software after a Brown-out Reset occurs)
DS40001709B-page 22Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
PC
128 70
5
PCLATH<4:0>
PCLATH
Instruction with
ALU Result
GOTO, CALL
OPCODE <10:0>
8
PC
12 11 100
11
PCLATH<4:3>
PCHPCL
87
2
PCLATH
PCHPCL
PCL as
Destination
MOVLW0x40;initialize pointer
MOVWFFSR;to RAM
NEXTCLRFINDF;clear INDF register
INCFFSR;inc pointer
BTFSSFSR,7;all done?
GOTONEXT;no clear next
CONTINUE;yes continue
2.4PCL and PCLATH
The Program Counter (PC) is 13 bits wide. The low byte
comes from the PCL register, which is a readable and
writable register. The high byte (PC<12:8>) is not directly
readable or writable and comes from PCLATH. On any
Reset, the PC is cleared. Figure 2-3 shows the two
situations for the loading of the PC. The upper example
in Figure 2-3 shows how the PC is loaded on a write to
PCL (PCLATH<4:0> PCH). The lower example in
Figure 2-3 shows how the PC is loaded during a CALL or
GOTO instruction (PCLATH<4:3> PCH).
FIGURE 2-3:LOADING OF PC IN
DIFFERENT SITUATIONS
2.4.2STACK
The PIC16F753/HV753 Family has an 8-level x 13-bit
wide hardware stack (see Figure 2-1). The stack space
is not part of either program or data space and the
Stack Pointer is not readable or writable. The PC is
PUSHed onto the stack when a CALL instruction is executed or an interrupt causes a branch. The stack is
POPed in the event of a RETURN, RETLW or a RETFIE
instruction execution. PCLATH is not affected by a
PUSH or POP operation.
The stack operates as a circular buffer. This means that
after the stack has been PUSHed eight times, the ninth
push overwrites the value that was stored from the first
push. The tenth push overwrites the second push (and
so on).
Note 1: There are no Status bits to indicate Stack
Overflow or Stack Underflow conditions.
2: There are no instructions/mnemonics
called PUSH or POP. These are actions
that occur from the execution of the
CALL, RETURN, RETLW and RETFIE
instructions or the vectoring to an
interrupt address.
2.5Indirect Addressing, INDF and
FSR Registers
2.4.1MODIFYING PCL
Executing any instruction with the PCL register as the
destination simultaneously causes the Program
Counter PC<12:8> bits (PCH) to be replaced by the
contents of the PCLATH register. This allows the entire
contents of the program counter to be changed by
writing the desired upper five bits to the PCLATH
register. When the lower eight bits are written to the
PCL register, all 13 bits of the program counter will
change to the values contained in the PCLATH register
and those being written to the PCL register.
A computed GOTO is accomplished by adding an offset
to the program counter (ADDWF PCL). Care should be
exercised when jumping into a look-up table or
program branch table (computed GOTO) by modifying
the PCL register. Assuming that PCLATH is set to the
table start address, if the table length is greater than
255 instructions or if the lower eight bits of the memory
address rolls over from 0xFF to 0x00 in the middle of
the table, then PCLATH must be incremented for each
address rollover that occurs between the table
beginning and the target location within the table.
For more information refer to Application Note AN556,
“Implementing a Table Read” (DS00556).
The INDF register is not a physical register. Addressing
the INDF register will cause indirect addressing.
Indirect addressing is possible by using the INDF
register. Any instruction using the INDF register
actually accesses data pointed to by the File Select
Register (FSR). Reading INDF itself indirectly will
produce 00h. Writing to the INDF register indirectly
results in a no operation (although Status bits may be
affected). An effective 9-bit address is obtained by
concatenating the 8-bit FSR and the IRP bit of the
STATUS register, as shown in Figure 2-4.
A simple program to clear RAM location 40h-7Fh using
indirect addressing is shown in Example 2-1.
DS40001709B-page 24Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
3.0FLASH PROGRAM MEMORY
SELF READ/SELF WRITE
CONTROL
The Flash program memory is readable and writable
during normal operation (full V
is not directly mapped in the register file space.
Instead, it is indirectly addressed through the Special
Function Registers (see Registers 3-1 to 3-5). There
are six SFRs used to read and write this memory:
•PMCON1
•PMCON2
•PMDATL
•PMDATH
• PMADRL
• PMADRH
When interfacing the program memory block, the
PMDATL and PMDATH registers form a two-byte word
which holds the 14-bit data for read/write, and the
PMADRL and PMADRH registers form a two-byte
word which holds the 10-bit address of the Flash location being accessed. These devices have 1K words of
program Flash with an address range from 0000h to
03FFh.
The program memory allows a single-word read and a
four-word write. A four-word write automatically erases
the row of the location and writes the new data (erase
before write).
The write time is controlled by an on-chip timer. The
write/erase voltages are generated by an on-chip
charge pump rated to operate over the voltage range
of the device for byte or word operations.
When the device is code-protected, the CPU may
continue to read and write the Flash program memory.
Depending on the settings of the Flash Program
Memory Enable (WRT<1:0>) bits, the device may or
may not be able to write certain blocks of the program
memory; however, reads of the program memory are
allowed.
When the Flash program memory Code Protection
) bit in the Configuration Word register is enabled,
(CP
the program memory is code-protected, and the
device programmer (ICSP™) cannot access data or
program memory.
DD range). This memory
3.1PMADRH and PMADRL Registers
The PMADRH and PMADRL registers can address up
to a maximum of 1K words of program memory.
When selecting a program address value, the Most
Significant Byte (MSB) of the address is written to the
PMADRH register and the Least Significant Byte
(LSB) is written to the PMADRL register.
3.2PMCON1 and PMCON2 Registers
PMCON1 is the control register for the data program
memory accesses.
Control bits RD and WR initiate read and write,
respectively. These bits cannot be cleared, only set in
software. They are cleared in hardware at completion
of the read or write operation. The inability to clear the
WR bit in software prevents the accidental premature
termination of a write operation.
The WREN bit, when set, will allow a write operation.
On power-up, the WREN bit is clear.
PMCON2 is not a physical register. Reading PMCON2
will read all ‘0’s. The PMCON2 register is used
exclusively in the Flash memory write sequence.
BANKSEL PM_ADR; Change STATUS bits RP1:0 to select bank with PMADRL
MOVLWMS_PROG_PM_ADDR ;
MOVWFPMADRH; MS Byte of Program Address to read
MOVLWLS_PROG_PM_ADDR ;
MOVWFPMADRL; LS Byte of Program Address to read
BANKSEL PMCON1; Bank to containing PMCON1
BSFPMCON1, RD; PM Read
NOP; First instruction after BSF PMCON1,RD executes normally
NOP; Any instructions here are ignored as program
; memory is read in second cycle after BSF PMCON1,RD
;
BANKSEL PMDATL; Bank to containing PMADRL
MOVFPMDATL, W; W = LS Byte of Program PMDATL
MOVFPMDATH, W; W = MS Byte of Program PMDATL
3.4Reading the Flash Program
Memory
To read a program memory location, the user must
write two bytes of the address to the PMADRL and
PMADRH registers, and then set control bit RD
(PMCON1<0>). Once the read control bit is set, the
program memory Flash controller will use the second
instruction cycle after to read the data. This causes the
second instruction immediately following the “
PMCON1,RD
” instruction to be ignored. The data is
available in the very next cycle in the PMDATL and
PMDATH registers; it can be read as two bytes in the
following instructions. PMDATL and PMDATH registers will hold this value until another read or until it is
written to by the user (during a write operation).
EXAMPLE 3-1:FLASH PROGRAM READ
BSF
DS40001709B-page 28Preliminary 2013 Microchip Technology Inc.
A word of the Flash program memory may only be
written to if the word is in an unprotected segment of
memory.
Flash program memory must be written in four-word
blocks. See Figure 3-2 and Figure 3-3 for more details.
A block consists of four words with sequential
addresses, with a lower boundary defined by an
address, where PMADRL<1:0> = 00. All block writes to
program memory are done as 16-word erase by fourword write operations. The write operation is edgealigned and cannot occur across boundaries.
To write program data, it must first be loaded into the
buffer registers (see Figure 3-2). This is accomplished
by first writing the destination address to PMADRL and
PMADRH and then writing the data to PMDATL and
PMDATH. After the address and data have been set
up, then the following sequence of events must be
executed:
1. Write 55h, then AAh, to PMCON2 (Flash
programming sequence).
2. Set the WR control bit of the PMCON1 register.
All four buffer register locations should be written to
with correct data. If less than four words are being
written to in the block of four words, then a read from
the program memory location(s) not being written to
must be performed. This takes the data from the
program location(s) not being written and loads it into
the PMDATL and PMDATH registers. Then the
sequence of events to transfer data to the buffer
registers must be executed.
To transfer data from the buffer registers to the program
memory, the PMADRL and PMADRH must point to the
last location in the four-word block (PMADRL<1:0> =
11). Then the following sequence of events must be
executed:
1. Write 55h, then AAh, to PMCON2 (Flash
programming sequence).
2.Set control bit WR of the PMCON1 register to
begin the write operation.
The user must follow the same specific sequence to
initiate the write for each word in the program block,
writing each program word in sequence (000, 001,010, 011). When the write is performed on the last
word (PMADRL<1:0> = 11), a block of sixteen words is
automatically erased and the content of the four-word
buffer registers are written into the program memory.
After the “BSF PMCON1,WR” instruction, the processor
requires two cycles to set up the erase/write operation.
The user must place two NOP instructions after the WR
bit is set. Since data is being written to buffer registers,
the writing of the first three words of the block appears
to occur immediately. The processor will halt internal
operations for the typical 4 ms, only during the cycle in
which the erase takes place (i.e., the last word of the
sixteen-word block erase). This is not Sleep mode as
the clocks and peripherals will continue to run. After
the four-word write cycle, the processor will resume
operation with the third instruction after the PMCON1
write instruction. The above sequence must be
repeated for the higher 12 words.
3.6Protection Against Spurious Write
There are conditions when the device should not write
to the program memory. To protect against spurious
writes, various mechanisms have been built in. On
power-up, WREN is cleared. Also, the Power-up Timer
(64 ms duration) prevents program memory writes.
The write initiate sequence and the WREN bit help
prevent an accidental write during brown-out, power
glitch or software malfunction.
3.7Operation During Code-Protect
When the device is code-protected, the CPU is able to
read and write unscrambled data to the program
memory.
3.8Operation During Write Protect
When the program memory is write-protected, the CPU
can read and execute from the program memory. The
portions of program memory that are write-protected
can be modified by the CPU using the PMCON
registers, but the protected program memory cannot be
modified using ICSP mode.
DS40001709B-page 30Preliminary 2013 Microchip Technology Inc.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This write routine assumes the following:
; A valid starting address (the least significant bits = '00')
;is loaded in ADDRH:ADDRL
; ADDRH, ADDRL and DATADDR are all located in data memory
MOVWF PMDATL ;
INCF FSR,F ;Next byte
MOVF INDF,W ;Load second data byte into upper
MOVWF PMDATH ;
INCF FSR,F ;
BANKSEL PMCON1
BSF PMCON1,WREN ;Enable writes
BCF INTCON,GIE ;Disable interrupts (if using)
BTFSC INTCON,GIE ;See AN576
GOTO $-2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Required Sequence
MOVLW 55h ;Start of required write sequence:
MOVWF PMCON2 ;Write 55h
MOVLW 0AAh ;
MOVWF PMCON2 ;Write 0AAh
BSF PMCON1,WR ;Set WR bit to begin write
NOP ;Required to transfer data to the buffer
NOP ;registers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BCF PMCON1,WREN ;Disable writes
BSF INTCON,GIE ;Enable interrupts (comment out if not using interrupts)
BANKSEL PMADRL
MOVFPMADRL, W
INCF PMADRL,F ;Increment address
ANDLW 0x03 ;Indicates when sixteen words have been programmed
SUBLW0x03;Change value for different size write blocks
;0x0F = 16 words
;0x0B = 12 words
;0x07 = 8 words
;0x03 = 4 words
BTFSS STATUS,Z ;Exit on a match,
GOTO LOOP ;Continue if more data needs to be written
An example of the complete four-word write sequence
is shown in Example 3-2. The initial address is loaded
into the PMADRH and PMADRL register pair; the four
words of data are loaded using indirect addressing.
EXAMPLE 3-2:WRITING TO FLASH PROGRAM MEMORY
DS40001709B-page 32Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
TABLE 3-1:SUMMARY OF REGISTERS ASSOCIATED WITH FLASH PROGRAM MEMORY
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
PMCON1
PMCON2Program Memory Control Register 2
PMADRLPMADRL<7:0>
PMADRH
PMDATLPMDATL<7:0>
PMDATH
INTCONGIEPEIE
Legend:— = unimplemented location, read as ‘0’. Shaded cells are not used by Flash program memory module.
* Page provides register information.
—————
——————PMADRH<1:0>26
——PMDATH<5:0>26
T0IEINTEIOCIET0IFINTFIOCIF
WRENWRRD
Register on
TABLE 3-2:SUMMARY OF CONFIGURATION WORD WITH FLASH PROGRAM MEMORY
Legend:— = unimplemented location, read as ‘1’. Shaded cells are not used by Flash program memory.
Note 1:See Configuration Word register (Register 19-1) for operation of all register bits.
The internal oscillator module provides the following
selectable system clock modes:
4.1Overview
The oscillator module has a variety of clock sources
and selection features that allow it to be used in a wide
range of applications while maximizing performance
• 8 MHz (HFINTOSC)
• 4 MHz (HFINTOSC Postscaler)
• 1 MHz (HFINTOSC Postscaler)
• 31 kHz (LFINTOSC)
and minimizing power consumption. Figure 4-1
illustrates a block diagram of the oscillator module.
The oscillator module can be configured in one of two
clock modes.
1. EC (external clock)
2. INTOSC (internal oscillator)
Clock Source modes are configured by the FOSC bit in
the Configuration Word register (CONFIG).
FIGURE 4-1:PIC® MCU CLOCK SOURCE BLOCK DIAGRAM
FIGURE 4-2:OSCILLATOR ENABLE
DS40001709B-page 34Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
CLKIN
CLKOUT
(1)
I/O
Clock from
Ext. System
PIC
®
MCU
Note 1:Alternate pin functions are listed in
Section 1.0 “Device Overview”.
CLKOUT
(1)
I/O
PIC
®
MCU
Note 1:Alternate pin functions are listed in
Section 1.0 “Device Overview”.
I/O
CLKIN
(1)
4.2Clock Source Modes
Clock Source modes can be classified as external or
internal:
• The External Clock mode relies on an external
clock for the clock source. For example, a clock
module or clock output from another circuit.
• Internal clock sources are contained internally
within the oscillator module. The oscillator module
has four selectable clock frequencies:
-8MHz
-4MHz
-1MHz
-31kHz
The system clock can be selected between external or
internal clock sources via the FOSC0 bit of the
Configuration Word register (CONFIG).
4.2.1EC MODE
The External Clock (EC) mode allows an externally
generated logic as the system clock source. The EC
clock mode is selected when the FOSC0 bit of the
Configuration Word is set.
When operating in this mode, an external clock source
must be connected to the CLKIN input. The CLKOUT is
available for either general purpose I/O or system clock
output. Figure 4-3 shows the pin connections for EC
mode.
®
Because the PIC
the external clock input will have the effect of halting the
device while leaving all data intact. Upon restarting the
external clock, the device will resume operation as if no
time had elapsed.
FIGURE 4-3:EXTERNAL CLOCK (EC)
MCU design is fully static, stopping
MODE OPERATION
4.2.2INTERNAL CLOCK MODE
Internal Clock mode configures the internal oscillators
as the system clock source. The Internal Clock mode is
selected when the FOSC0 bit of the Configuration
Word is cleared. The source and frequency are
selected with the IRCF<1:0> bits of the OSCCON
register.
When one of the HFINTOSC frequencies is selected,
the frequency of the internal oscillator can be trimmed
by adjusting the TUN<4:0> bits of the OSCTUNE
register.
Operation after a Power-on Reset (POR) or wake-up
from Sleep is delayed by the oscillator start-up time.
Delays are typically longer for the LFINTOSC than
HFINTOSC because of the very low-power operation
and relatively narrow bandwidth of the LF internal
oscillator. However, when another peripheral keeps the
oscillator running during Sleep, the start-up time is
delayed to allow the memory bias to stabilize.
FIGURE 4-4:INTERNAL CLOCK MODE
OPERATION
4.2.2.1Oscillator Ready Bits
The HTS and LTS bits of the OSCCON register indicate
the status of the HFINTOSC and LFINTOSC,
respectively. When either bit is set, it indicates that the
corresponding oscillator is running and stable.
The CLKOUT pin is available for general purpose I/O or
system clock output. The CLKOUTEN
Configuration Word controls the function of the
CLKOUT pin.
When the CLKOUTEN
is driven by the selected internal oscillator frequency
divided by 4. The corresponding I/O pin always reads
‘0’ in this configuration.
The CLKOUT signal may be used to provide a clock for
external circuitry, synchronization, calibration, test or
other application requirements.
When the CLKOUTEN
function is disabled and the CLKOUT pin is available for
general purpose I/O.
bit is cleared, the CLKOUT pin
bit is set, the system clock out
bit of the
4.4Oscillator Delay upon Wake-Up,
Power-Up, and Base Frequency
Change
In applications where the OSCTUNE register is used to
shift the HFINTOSC frequency, the application should
not expect the frequency to stabilize immediately. In
this case, the frequency may shift gradually toward the
new value. The time for this frequency shift is less than
eight cycles of the base frequency.
A short delay is invoked upon power-up and when
waking from sleep to allow the memory bias circuitry to
stabilize. Table 4-1 shows examples where the oscillator
delay is invoked.
TABLE 4-1:OSCILLATOR DELAY EXAMPLES
Switch FromSwitch ToFrequencyOscillator Delay
Sleep/PORINTOSC31 kHz to 8 MHz
Sleep/PORECDC – 20 MHz
10 s internal delay to allow memory
bias to stabilize.
DS40001709B-page 36Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
4.5Register Definitions: Oscillator Control
REGISTER 4-1:OSCCON: OSCILLATOR CONTROL REGISTER
U-0U-0R/W-0/uR/W-1/uU-0 R-0/u R-0/u U-0
——IRCF<1:0>—HTSLTS—
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7-6Unimplemented: Read as ‘0’
bit 5-4IRCF<1:0>: Internal Oscillator Frequency Select bits
The oscillator is factory calibrated, but can be adjusted
in software by writing to the OSCTUNE register
(Register 4-2).
The default value of the OSCTUNE register is ‘0’. The
value is a 5-bit two’s complement number.
When the OSCTUNE register is modified, the frequency
will begin shifting to the new frequency. Code execution
continues during this shift. There is no indication that the
shift has occurred.
REGISTER 4-2:OSCTUNE: OSCILLATOR TUNING REGISTER
U-0U-0U-0R/W-0/u R/W-0/u R/W-0/u R/W-0/u R/W-0/u
———TUN<4:0>
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7-5Unimplemented: Read as ‘0’
bit 4-0TUN<4:0>: Frequency Tuning bits
01111 = Maximum frequency
01110 =
•
•
•
00001 =
00000 = Oscillator module is running at the calibrated frequency.
11111 =
•
•
•
10000 = Minimum frequency
TABLE 4-2:SUMMARY OF REGISTERS ASSOCIATED WITH CLOCK SOURCES
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
OSCCON
OSCTUNE
Legend: x = unknown, u = unchanged, – = unimplemented locations read as ‘0’. Shaded cells are not used by
——IRCF<1:0>—HTSLTS—37
———TUN<4:0>38
oscillators.
Register
on Page
TABLE 4-3:SUMMARY OF CONFIGURATION WORD CLOCK SOURCES
Legend:— = unimplemented location, read as ‘1’. Shaded cells are not used by oscillator module.
Note 1:See Configuration Word register (Register 19-1) for operation of all register bits.
DS40001709B-page 38Preliminary 2013 Microchip Technology Inc.
(1)
7:0
—CPMCLREPWRTEWDTE——FOSC0
Register
on Page
150
PIC16F753/HV753
QD
CK
Write LATA
Data Register
I/O pin
Read PORTA
Write PORTA
TRISA
Read LATA
Data Bus
To peripherals
ANSELA
VDD
VSS
; This code example illustrates
; initializing the PORTA register. The
; other ports are initialized in the same
; manner.
BANKSEL PORTA;
CLRFPORTA;Init PORTA
BANKSEL LATA;Data Latch
CLRFLATA;
BANKSEL ANSELA;
CLRF ANSELA;digital I/O
BANKSEL TRISA;
MOVLWB'00111000' ;Set RA<5:3> as inputs
MOVWFTRISA;and set RA<2:0> as
;outputs
5.0I/O PORTS
Depending on the device selected and peripherals
enabled, there are up to two ports available. In general,
when a peripheral is enabled, that pin may not be used
as a general purpose I/O pin.
Each port has three standard registers for its operation.
These registers are:
• TRISx registers (data direction)
• PORTx registers (reads the levels on the pins of
the device)
• LATx registers (output latch)
Some ports may have one or more of the following
additional registers. These registers are:
• ANSELx (analog select)
• WPUx (weak pull-up)
• SLRCONx registers (slew rate)
The Data Latch (LATx registers) is useful for readmodify-write operations on the values that the I/O pins
are driving.
A write operation to the LATx register has the same
affect as a write to the corresponding PORTx register.
A read of the LATx register reads the values held in the
I/O PORT latches, while a read of the PORTx register
reads the actual I/O pin value.
Ports with analog functions also have an ANSELx
register which can disable the digital input and save
power. A simplified model of a generic I/O port, without
the interfaces to other peripherals, is shown in
The Alternate Pin Function Control (APFCON) register
is used to steer specific peripheral input and output
functions between different pins. The APFCON register
is shown in Register 5-1. For this device family, the
following functions can be moved between different
pins.
•Timer1 Gate
• COG1
These bits have no effect on the values of any TRIS
register. PORT and TRIS overrides will be routed to the
correct pin. The unselected pin will be unaffected.
5.2Register Definitions: Alternate Pin Function Control
REGISTER 5-1:APFCON: ALTERNATE PIN FUNCTION CONTROL REGISTER
U-0U-0U-0R/W-0/0U-0U-0U-0U-0
———
bit 7bit 0
T1GSEL
————
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = bit is unchangedx = 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-5Unimplemented: Read as ‘0’.
bit 4T1GSEL: Timer 1 Gate Input Pin Selection bit
1 = T1G function is on RA3
0 = T1G function is on RA4
bit 3-0Unimplemented: Read as ‘0’.
DS40001709B-page 40Preliminary 2013 Microchip Technology Inc.
5.3PORTA and TRISA Registers
PORTA is a 6-bit wide port with five bidirectional and one
input-only pin. The corresponding data direction register
is TRISA (Register 5-2). Setting a TRISA bit (= 1) will
make the corresponding PORTA pin an input (i.e.,
disable the output driver). Clearing a TRISA bit (= 0) will
make the corresponding PORTA pin an output (i.e.,
enables output driver and puts the contents of the output
latch on the selected pin). The exception is RA3, which
is input-only and its TRIS bit will always read as ‘1’.
Example 5-1 shows how to initialize PORTA.
Reading the PORTA register (Register 5-2) reads the
status of the pins, whereas writing to it will write to the
PORT latch. All write operations are read-modify-write
operations. Therefore, a write to a port implies that the
port pins are read, this value is modified and then
written to the PORT data latch. RA3 reads ‘0’ when
MCLRE = 1.
The TRISA register controls the direction of the
PORTA pins, even when they are being used as analog
inputs. The user must ensure the bits in the TRISA
register are maintained set when using them as analog
inputs. I/O pins configured as analog input always read
‘0’.
Note:The ANSEL register must be initialized to
configure an analog channel as a digital
input. Pins configured as analog inputs will
read ‘0’ and cannot generate an interrupt.
PIC16F753/HV753
TABLE 5-1:PORTA OUTPUT PRIORITY
Pin NameFunction Priority
RA0ICSPDAT
FVROUT
DACOUT
C1IN0+
RA0
RA1FVRIN
RA2COG1FLT
RA3MCLR
RA4CLKOUT
RA5CLKIN
ICSPCLK
V
REF+
C1IN0C2IN0RA1
T0CKI
C1OUT
INT
RA2
VPP
T1G
RA3
T1G
RA4
T1CKI
RA5
5.3.1PORTA FUNCTIONS AND OUTPUT
PRIORITIES
Each PORTA pin is multiplexed with other functions. The
pins, their combined functions and their output priorities
are shown in Tab l e 5 -1 .
When multiple outputs are enabled, the actual pin
control goes to the peripheral with the highest priority.
Analog input functions, such as comparator inputs, are
not shown in the priority lists. These inputs are active
when the peripheral is enabled and the input multiplexer
for the pin is selected. The Analog mode, set with the
ANSELA register, disables the digital input buffer
thereby preventing excessive input current when the
analog input voltage is between logic states. Digital
output functions may control the pin when it is in Analog
mode with the priority shown in Table 5-1.
Every PORTA pin on the PIC16F753 has an interrupton-change option and a weak pull-up option. The next
three sections describe these functions.
5.4.1ANSELA REGISTER
The ANSELA register (Register 5-5) is used to
configure the Input mode of an I/O pin to analog.
Setting the appropriate ANSELA bit high will cause all
digital reads on the pin to be read as ‘0’ and allow
analog functions on the pin to operate correctly.
The state of the ANSELA bits has no effect on digital
output functions. A pin with TRIS clear and ANSEL set
will still operate as a digital output, but the Input mode
will be analog. This can cause unexpected behavior
when executing read-modify-write instructions on the
affected port.
Note:The ANSELA bits default to the Analog
mode after Reset. To use any pins as
digital general purpose or peripheral
inputs, the corresponding ANSEL bits
must be initialized to ‘0’ by user software.
5.4.2WEAK PULL-UPS
Each of the PORTA pins, except RA3, has an
individually configurable internal weak pull-up. Control
bits WPUx enable or disable each pull-up. Refer to
Register 5-6. Each weak pull-up is automatically turned
off when the port pin is configured as an output. The
pull-ups are disabled on a Power-on Reset by the
bit of the OPTION_REG register. A weak pull-up
RAPU
is automatically enabled for RA3 when configured as
MCLR and disabled when RA3 is an I/O. There is no
software control of the MCLR
pull-up.
5.4.3INTERRUPT-ON-CHANGE
Each PORTA pin is individually configurable as an
interrupt-on-change pin. Control bits IOCA enable or
disable the interrupt function for each pin. Refer to
Register 5-7. The interrupt-on-change is disabled on a
Power-on Reset.
For enabled interrupt-on-change pins, the values are
compared with the old value latched on the last read of
PORTA. The ‘mismatch’ outputs of the last read are
OR’d together to set the PORTA Change Interrupt Flag
bit (IOCIF) in the INTCON register (Register 2-3).
This interrupt can wake the device from Sleep. The
user, in the Interrupt Service Routine, clears the
interrupt by:
a) Any read of PORTA AND Clear flag bit IOCIF.
This will end the mismatch condition;
OR
b) Any write of PORTA AND Clear flag bit IOCIF
will end the mismatch condition;
A mismatch condition will continue to set flag bit IOCIF.
Reading PORTA will end the mismatch condition and
allow flag bit IOCIF to be cleared. The latch holding the
last read value is not affected by a MCLR
Reset. After these Resets, the IOCIF flag will continue
to be set if a mismatch is present.
Note:If a change on the I/O pin should occur
when any PORTA operation is being
executed, then the IOCIF interrupt flag
may not get set.
nor BOR
DS40001709B-page 42Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
5.5Register Definitions: PORTA Control
REGISTER 5-2:PORTA: PORTA REGISTER
U-0U-0R/W-x/uR/W-x/uR-x/xR/W-x/uR/W-x/uR/W-x/u
——RA5RA4RA3RA2RA1RA0
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = 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-6Unimplemented: Read as ‘0’
bit 5-0RA<5:0>: PORTA I/O Value bits
1 = Port pin is > VIH
0 = Port pin is < VIL
Note 1:Writes to PORTA are actually written to corresponding LATA register. Reads from PORTA register is return of actual I/O pin
values.
(1)
REGISTER 5-3:TRISA: PORTA TRI-STATE REGISTER
U-0U-0R/W-1/1R/W-1/1R-1/1R/W-1/1R/W-1/1R/W-1/1
——TRISA5TRISA4TRISA3
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = 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-6Unimplemented: Read as ‘0’
bit 5-0TRISA<5:0>: PORTA Tri-State Control bits
1 = PORTA pin configured as an input (tri-stated)
0 = PORTA pin configured as an output
Note 1:TRISA3 always reads ‘1’.
(1)
(1)
TRISA2TRISA1TRISA0
REGISTER 5-4:LATA: PORTA DATA LATCH REGISTER
U-0U-0R/W-x/uR/W-x/uU-0R/W-x/uR/W-x/uR/W-x/u
——LATA5LATA4—LATA2LATA1LATA 0
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = 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-6Unimplemented: Read as ‘0’
bit 5-4LATA<5:4>: PORTA Output Latch Value bits
bit 3Unimplemented: Read as ‘0’
bit 2-0LATA<2:0>: PORTA Output Latch Value bits
Note 1:Writes to PORTA are actually written to corresponding LATA register. Reads from PORTA register is return of actual I/O
TABLE 5-2:SUMMARY OF REGISTERS ASSOCIATED WITH PORTA
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
ADCON0ADFM
ADCON1
ANSELA
APFCON
CM1CON0
CM2CON0
CM1CON1
CM2CON1
DAC1CON0DACEN
IOCAF
IOCAN
IOCAP
LATA
OPTION_REG
PORTA
TRISA
Legend:x = unknown, u = unchanged, – = unimplemented locations read as ‘0’. Shaded cells are not used by PORTA.
Note 1:TRISA3 always reads ‘1’.
—ADCS<2:0>———
———ANSA4—ANSA2ANSA1ANSA044
———T1GSEL————40
C1ONC1OUTC1OEC1POLC1ZLFC1SPC1HYSC1SYNC129
C2ONC2OUTC2OEC2POLC2ZLFC2SPC2HYSC2SYNC129
C1INTPC1INTNC1PCH<2:0>C1NCH<2:0>130
C2INTPC2INTNC2PCH<2:0>
——IOCAF5IOCAF4IOCAF3IOCAF2IOCAF1IOCAF045
——IOCAN5IOCAN4IOCAN3IOCAN2IOCAN1IOCAN045
——IOCAP5IOCAP4IOCAP3IOCAP2IOCAP1IOCAP045
——LATA5LATA4—LATA2L ATA1LATA 043
RAPUINTEDGT0CST0SEPSAPS<2:0>16
——RA5RA4RA3RA2RA1RA043
——TRISA5TRISA4TRISA3
—
DACFMDACOE—DACPSS1 DACPSS0——120
CHS<3:0>GO/DONE
C2NCH<2:0>
(1)
TRISA2TRISA1TRISA043
ADON109
ADPREF1
Register
on Page
110
130
DS40001709B-page 46Preliminary 2013 Microchip Technology Inc.
5.6PORTC Registers
PORTC is a 6-bit wide port with five bidirectional and one
input-only pin. The corresponding data direction register
is TRISC (Register 5-2). Setting a TRISC bit (= 1) will
make the corresponding PORTC pin an input (i.e.,
disable the output driver). Clearing a TRISC bit (= 0) will
make the corresponding PORTC pin an output (i.e.,
enables output driver and puts the contents of the output
latch on the selected pin). The exception is RA3, which
is input-only and its TRIS bit will always read as ‘1’.
Example 5-1 shows how to initialize PORTC.
Reading the PORTC register (Register 5-2) reads the
status of the pins, whereas writing to it will write to the
PORT latch. All write operations are read-modify-write
operations. Therefore, a write to a port implies that the
port pins are read, this value is modified and then
written to the PORT data latch. RC3 reads ‘0’ when
MCLRE = 1.
The TRISC register controls the direction of the
PORTC pins, even when they are being used as
analog inputs. The user must ensure the bits in the
TRISC register are maintained set when using them as
analog inputs. I/O pins configured as analog input
always read ‘0’.
Note:The ANSEL register must be initialized to
configure an analog channel as a digital
input. Pins configured as analog inputs will
read ‘0’ and cannot generate an interrupt.
PIC16F753/HV753
TABLE 5-3:PORTC OUTPUT PRIORITY
Pin NameFunction Priority
RC0OPA1IN+
C2IN0+
RC0
RC1OPA1IN-
C1IN1C2IN1RC1
RC2SLPCIN
OPA1OUT
C1IN2C2IN2RC2
RC3C1IN3-
C2IN3RC3
RC4COG1OUT1
C2OUT
RC4
RC5COG1OUT0
CCP1
RC5
5.6.1PORTC FUNCTIONS AND OUTPUT
PRIORITIES
Each PORTC pin is multiplexed with other functions. The
pins, their combined functions and their output priorities
are shown in Tab l e 5 -1 .
When multiple outputs are enabled, the actual pin
control goes to the peripheral with the highest priority.
Analog input functions, such as comparator inputs, are
not shown in the priority lists. These inputs are active
when the peripheral is enabled and the input multiplexer
for the pin is selected. The Analog mode, set with the
ANSELC register, disables the digital input buffer
thereby preventing excessive input current when the
analog input voltage is between logic states. Digital
output functions may control the pin when it is in Analog
mode with the priority shown in Table 5-1.
Every PORTC pin on the PIC16F753 has an interrupton-change option and a weak pull-up option. The next
three sections describe these functions.
5.7.1ANSELC REGISTER
The ANSELC register (Register 5-5) is used to
configure the Input mode of an I/O pin to analog.
Setting the appropriate ANSELC bit high will cause all
digital reads on the pin to be read as ‘0’ and allow
analog functions on the pin to operate correctly.
The state of the ANSELC bits has no effect on digital
output functions. A pin with TRIS clear and ANSEL set
will still operate as a digital output, but the Input mode
will be analog. This can cause unexpected behavior
when executing read-modify-write instructions on the
affected port.
Note:The ANSELC bits default to the Analog
mode after Reset. To use any pins as
digital general purpose or peripheral
inputs, the corresponding ANSEL bits
must be initialized to ‘0’ by user software.
5.7.2WEAK PULL-UPS
Each of the PORTC pins, except RC3, has an
individually configurable internal weak pull-up. Control
bits WPUx enable or disable each pull-up. Refer to
Register 5-6. Each weak pull-up is automatically turned
off when the port pin is configured as an output. The
pull-ups are disabled on a Power-on Reset by the
bit of the OPTION_REG register. A weak pull-up
RAPU
is automatically enabled for RC3 when configured as
MCLR and disabled when RC3 is an I/O. There is no
software control of the MCLR
pull-up.
5.7.3INTERRUPT-ON-CHANGE
Each PORTC pin is individually configurable as an
interrupt-on-change pin. Control bit IOCC enables or
disables the interrupt function for each pin. Refer to
Register 5-7. The interrupt-on-change is disabled on a
Power-on Reset.
For enabled interrupt-on-change pins, the values are
compared with the old value latched on the last read of
PORTC. The ‘mismatch’ outputs of the last read are
OR’d together to set the PORTC Change Interrupt Flag
bit (IOCIF) in the INTCON register (Register 2-3).
This interrupt can wake the device from Sleep. The
user, in the Interrupt Service Routine, clears the
interrupt by:
a) Any read of PORTC AND Clear flag bit IOCIF.
This will end the mismatch condition;
OR
b) Any write of PORTC AND Clear flag bit IOCIF
will end the mismatch condition;
A mismatch condition will continue to set flag bit IOCIF.
Reading PORTC will end the mismatch condition and
allow flag bit IOCIF to be cleared. The latch holding the
last read value is not affected by a MCLR
Reset. After these Resets, the IOCIF flag will continue
to be set if a mismatch is present.
Note:If a change on the I/O pin should occur
when any PORTC operation is being
executed, then the IOCIF interrupt flag
may not get set.
nor BOR
5.7.4SLEW RATE CONTROL
Two of the PORTC pins, RC4 and RC5, are equipped
with high current driver circuitry. The SLRCONC register
provides reduced slew rate control to mitigate possible
EMI radiation from these pins.
DS40001709B-page 48Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
5.8Register Definitions: PORTC Control
REGISTER 5-10:PORTC: PORTC REGISTER
U-0U-0R/W-x/uR/W-x/uR-x/xR/W-x/uR/W-x/uR/W-x/u
——RC5RC4RC3RC2RC1RC0
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = 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-6Unimplemented: Read as ‘0’
bit 5-0RC<5:0>: PORTC I/O Value bits
1 = Port pin is > VIH
0 = Port pin is < VIL
Note 1: Writes to PORTC are actually written to corresponding LATC register. Reads from PORTC register is
return of actual I/O pin values.
(1)
REGISTER 5-11:TRISC: PORTC TRI-STATE REGISTER
U-0U-0R/W-1/1R/W-1/1R-1/1R/W-1/1R/W-1/1R/W-1/1
——TRISC5TRISC4TRISC3TRISC2TRISC1TRISC0
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = 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-6Unimplemented: Read as ‘0’
bit 5-0TRISC<5:0>: PORTC Tri-State Control bits
1 = PORTC pin configured as an input (tri-stated)
0 = PORTC pin configured as an output
REGISTER 5-12:LATC: PORTC DATA LATCH REGISTER
U-0U-0R/W-x/uR/W-x/uR/W-x/uR/W-x/uR/W-x/uR/W-x/u
——LATC5LATC4LATC3LATC2LATC1LATC0
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = 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-6Unimplemented: Read as ‘0’
bit 5-0LATC<5:0>: PORTC Output Latch Value bits
Note 1: Writes to PORTC are actually written to corresponding LATC register. Reads from PORTC register is
Note 1: T0SE, T0CS, PSA, PS<2:0> are bits in Register 6-1.
2: WDTE bit is in Register 19-1.
0
1
0
1
0
1
8
8
8-bit
Prescaler
0
1
FOSC/4
PSA
PSA
PSA
Sync
2 T
CY
Shared Prescale
WDTE
LFINTOSC
(Figure 4-1)
2
PSA
6.0TIMER0 MODULE
The Timer0 module is an 8-bit timer/counter with the
following features:
• 8-bit timer/counter register (TMR0)
• 8-bit prescaler (shared with Watchdog Timer)
• Programmable internal or external clock source
• Programmable external clock edge selection
• Interrupt on overflow
Figure 6-1 is a block diagram of the Timer0 module.
6.1Timer0 Operation
When used as a timer, the Timer0 module can be used
as either an 8-bit timer or an 8-bit counter.
6.1.18-BIT TIMER MODE
When used as a timer, the Timer0 module will
increment every instruction cycle (without prescaler).
Timer mode is selected by clearing the T0CS bit of the
OPTION register to ‘0’.
When TMR0 is written, the increment is inhibited for
two instruction cycles immediately following the write.
Note:The value written to the TMR0 register
can be adjusted, in order to account for
the two instruction cycle delay when
TMR0 is written.
6.1.28-BIT COUNTER MODE
When used as a counter, the Timer0 module will
increment on every rising or falling edge of the T0CKI
pin. The incrementing edge is determined by the T0SE
bit of the OPTION_REG register. Counter mode is
selected by setting the T0CS bit of the OPTION register
to ‘1’.
FIGURE 6-1:TIMER0 WITH SHARED PRESCALE BLOCK DIAGRAM
DS40001709B-page 54Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
BANKSEL TMR0;
CLRWDT;Clear WDT
CLRFTMR0;Clear TMR0 and
;prescaler
BANKSEL OPTION_REG;
MOVLWb’11110000’ ;Mask TMR0 select and
ANDWFOPTION_REG,W ;prescaler bits
IORLWb’00000011’ ;Set prescale to 1:16
MOVWFOPTION_REG;
6.1.3SOFTWARE PROGRAMMABLE
PRESCALER
A single software programmable prescaler is available
for use with either Timer0 or the Watchdog Timer
(WDT), but not both simultaneously. The prescaler
assignment is controlled by the PSA bit of the OPTION
register. To assign the prescaler to Timer0, the PSA bit
must be cleared to a ‘0’.
There are eight prescaler options for the Timer0 module ranging from 1:2 to 1:256. The prescale values are
selectable via the PS<2:0> bits of the OPTION register.
In order to have a 1:1 prescaler value for the Timer0
module, the prescaler must be assigned to the WDT
module.
The prescaler is not readable or writable. When
assigned to the Timer0 module, all instructions writing to
the TMR0 register will clear the prescaler.
When the prescaler is assigned to WDT (PSA = 1), a
CLRWDT instruction will clear the prescaler along with
the WDT.
6.1.3.1Switching Prescaler Between
Timer0 and WDT Modules
As a result of having the prescaler assigned to either
Timer0 or the WDT, it is possible to generate an
unintended device Reset when switching prescaler
values. When changing the prescaler assignment from
Timer0 to the WDT module, the instruction sequence
shown in Example 6-1 must be executed.
EXAMPLE 6-1:CHANGING PRESCALER
(TIMER0 WDT)
When changing the prescaler assignment from the
WDT to the Timer0 module, the following instruction
sequence must be executed (see Example 6-2).
EXAMPLE 6-2:CHANGING PRESCALER
(WDT TIMER0)
6.1.4TIMER0 INTERRUPT
Timer0 will generate an interrupt when the TMR0
register overflows from FFh to 00h. The T0IF interrupt
flag bit of the INTCON register is set every time the
TMR0 register overflows, regardless of whether or not
the Timer0 interrupt is enabled. The T0IF bit must be
cleared in software. The Timer0 interrupt enable is the
T0IE bit of the INTCON register.
Note:The Timer0 interrupt cannot wake the
processor from Sleep since the timer is
frozen during Sleep.
6.1.5USING TIMER0 WITH AN
EXTERNAL CLOCK
When Timer0 is in Counter mode, the synchronization
of the T0CKI input and the Timer0 register is
accomplished by sampling the prescaler output on the
Q2 and Q4 cycles of the internal phase clocks.
Therefore, the high and low periods of the external
clock source must meet the timing requirements as
shown in Section 22.0 “Electrical Specifications”.
The Timer1 module is a 16-bit incrementing counter
which is accessed through the TMR1H:TMR1L register
pair. Writes to TMR1H or TMR1L directly update the
counter.
When used with an internal clock source, the module is
a timer and increments on every instruction cycle.
When used with an external clock source, the module
can be used as either a timer or counter and
increments on every selected edge of the external
source.
Timer1 is enabled by configuring the TMR1ON and
TMR1GE bits in the T1CON and T1GCON registers,
respectively. Tab l e 7- 1 displays the Timer1 enable
selections.
TABLE 7-1:TIMER1 ENABLE
SELECTIONS
TMR1ONTMR1GE
00Off
01Off
10Always On
11Count Enabled
Timer1
Operation
7.2Clock Source Selection
The TMR1CS<1:0> bits of the T1CON register are used
to select the clock source for Timer1. Tab l e 7 - 2 displays
the clock source selections.
TABLE 7-2:CLOCK SOURCE
SELECTIONS
TMR1CS<1:0>Clock Source
11Temperature Sense Oscillator
10External Clocking on T1CKI Pin
01System Clock (FOSC)
00Instruction Clock (FOSC/4)
7.2.1INTERNAL CLOCK SOURCE
When the internal clock source is selected, the
TMR1H:TMR1L register pair will increment on multiples
OSC or FOSC/4 as determined by the Timer1
of F
prescaler.
7.2.2EXTERNAL CLOCK SOURCE
When the external clock source is selected, the Timer1
module may work as a timer or a counter. When enabled
to count, Timer1 is incremented on the rising edge of the
external clock input T1CKI.
Note:In Counter mode, a falling edge must be
registered by the counter prior to the first
incrementing rising edge (see Figure 7-2)
after any one or more of the following
conditions:
• Timer1 enabled after POR Reset
• 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.
7.2.3WDT OSCILLATOR
When the Watchdog is selected, Timer 1 will use the
LFINTOSC that is used to operate the Watchdog
Timer. This is the same oscillator as the LFINTOSC
used as the system clock. Selecting this option will
enable the oscillator even when the LFINTOSC or the
Watchdog are not in use. This oscillator will continue
to operate when in Sleep mode.
DS40001709B-page 58Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
7.3Timer1 Prescaler
Timer1 has four prescaler options allowing one, two, four
or eight divisions of the clock input. The T1CKPS bits of
the T1CON register control the prescale counter. The
prescale counter is not directly readable or writable;
however, the prescaler counter is cleared upon a write to
TMR1H or TMR1L.
7.4Timer1 Operation in
Asynchronous Counter Mode
If control bit T1SYNC of the T1CON register is set, the
external clock input is not synchronized. The timer
increments asynchronously to the internal phase
clocks. If external clock source is selected then the
timer will continue to run during Sleep and can
generate an interrupt on overflow, which will wake-up
the processor. However, special precautions in
software are needed to read/write the timer (see
Section 7.4.1 “Reading and Writing Timer1 in
Asynchronous Counter Mode”).
Note:When switching from synchronous to
asynchronous operation, it is possible to
skip an increment. When switching from
asynchronous to synchronous operation,
it is possible to produce an additional
increment.
7.4.1READING AND WRITING TIMER1 IN
ASYNCHRONOUS COUNTER
MODE
Reading TMR1H or TMR1L while the timer is running
from an external asynchronous clock will ensure a valid
read (taken care of in hardware). However, the user
should keep in mind that reading the 16-bit timer in two
8-bit values itself, poses certain problems, since the
timer may overflow between the reads.
For writes, it is recommended that the user simply stop
the timer and write the desired values. A write
contention may occur by writing to the timer registers,
while the register is incrementing. This may produce an
unpredictable value in the TMR1H:TMR1L register pair.
7.5Timer1 Gate
Timer1 can be configured to count freely or the count
can be enabled and disabled using Timer1 gate
circuitry. This is also referred to as Timer1 gate count
enable.
Timer1 gate can also be driven by multiple selectable
sources.
7.5.1TIMER1 GATE COUNT ENABLE
The Timer1 gate is enabled by setting the TMR1GE bit
of the T1GCON register. The polarity of the Timer1 gate
is configured using the T1GPOL bit of the T1GCON
register.
When Timer1 Gate (T1G) input is active, Timer1 will
increment on the rising edge of the Timer1 clock
source. When Timer1 gate input is inactive, no
incrementing will occur and Timer1 will hold the current
count. See Figure 7-3 for timing details.
TABLE 7-3:TIMER1 GATE ENABLE
SELECTIONS
T1CLKT1GPOLT1GTimer1 Operation
00Counts
01Holds Count
10Holds Count
11Counts
7.5.2TIMER1 GATE SOURCE
SELECTION
The Timer1 gate source can be selected from one of
four different sources. Source selection is controlled by
the T1GSS bits of the T1GCON register. The polarity
for each available source is also selectable. Polarity
selection is controlled by the T1GPOL bit of the
T1GCON register.
The T1G pin is one source for Timer1 gate control. It
can be used to supply an external source to the Timer1
gate circuitry.
7.5.2.2Timer0 Overflow Gate Operation
When Timer0 increments from FFh to 00h, a low-tohigh pulse will automatically be generated and
internally supplied to the Timer1 gate circuitry.
7.5.2.3C1OUT/C2OUT Gate Operation
The outputs from the Comparator C1 and C2 modules
can be used as gate sources for the Timer1 module.
7.5.3TIMER1 GATE TOGGLE MODE
When Timer1 Gate Toggle mode is enabled, it is
possible to measure the full-cycle length of a Timer1
gate signal, as opposed to the duration of a single-level
pulse.
The Timer1 gate source is routed through a flip-flop that
changes state on every incrementing edge of the
signal. See Figure 7-4 for timing details.
Timer1 Gate Toggle mode is enabled by setting the
T1GTM bit of the T1GCON register. When the T1GTM
bit is cleared, the flip-flop is cleared and held clear. This
is necessary in order to control which edge is
measured.
Note:Enabling Toggle mode at the same time
as changing the gate polarity may result in
indeterminate operation.
7.5.5TIMER1 GATE VALUE STATUS
When Timer1 gate value status is utilized, it is possible
to read the most current level of the gate control value.
The value is stored in the T1GVAL bit in the T1GCON
register. The T1GVAL bit is valid even when the Timer1
gate is not enabled (TMR1GE bit is cleared).
7.5.6TIMER1 GATE EVENT INTERRUPT
When Timer1 gate event interrupt is enabled, it is
possible to generate an interrupt upon the completion
of a gate event. When the falling edge of T1GVAL
occurs, the TMR1GIF flag bit in the PIR1 register will be
set. If the TMR1GIE bit in the PIE1 register is set, then
an interrupt will be recognized.
The TMR1GIF flag bit operates even when the Timer1
gate is not enabled (TMR1GE bit is cleared).
7.5.4TIMER1 GATE SINGLE-PULSE
MODE
When Timer1 Gate Single-Pulse mode is enabled, it is
possible to capture a single-pulse gate event. Timer1
Gate Single-Pulse mode is first enabled by setting the
T1GSPM bit in the T1GCON register. Next, the
T1GGO/DONE
The Timer1 will be fully enabled on the next
incrementing edge. On the next trailing edge of the
pulse, the T1GGO/DONE
cleared. No other gate events will be allowed to
increment Timer1 until the T1GGO/DONE bit is once
again set in software.
Clearing the T1GSPM bit of the T1GCON register will
also clear the T1GGO/DONE
timing details.
Enabling the Toggle mode and the Single-Pulse mode
simultaneously will permit both sections to work
together. This allows the cycle times on the Timer1 gate
source to be measured. See Figure 7-6 for timing
details.
bit in the T1GCON register must be set.
bit will automatically be
bit. See Figure 7-5 for
DS40001709B-page 60Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
T1CKI
T1CKI
TMR1 enabled
Note 1: Arrows indicate counter increments.
2: In Counter mode, a falling edge must be registered by the counter prior to the first incrementing rising edge of the clock.
7.6Timer1 Interrupt
The Timer1 register pair (TMR1H:TMR1L) increments
to FFFFh and rolls over to 0000h. When Timer1 rolls
over, the Timer1 interrupt flag bit of the PIR1 register is
set. To enable the interrupt on rollover, you must set
these bits:
• TMR1ON bit of the T1CON register
• TMR1IE bit of the PIE1 register
• PEIE bit of the INTCON register
• GIE bit of the INTCON register
The interrupt is cleared by clearing the TMR1IF bit in
the Interrupt Service Routine.
Note:The TMR1H:TMR1L register pair and the
TMR1IF bit should be cleared before
enabling interrupts.
7.7Timer1 Operation During Sleep
Timer1 can only operate during Sleep when set up in
Asynchronous Counter mode or with the internal
watchdog clock source. In this mode, the clock source
can be used to increment the counter. To set up the
timer to wake the device:
• TMR1ON bit of the T1CON register must be set
• TMR1IE bit of the PIE1 register must be set
• PEIE bit of the INTCON register must be set
• T1SYNC
• TMR1CS bits of the T1CON register must be
configured
• TMR1GE bit of the T1GCON register must be
configured
The device will wake-up on an overflow and execute
the next instructions. If the GIE bit of the INTCON
register is set, the device will call the Interrupt Service
Routine (0004h).
bit of the T1CON register must be set
7.8CCP Capture/Compare Time Base
The CCP module uses the TMR1H:TMR1L register
pair as the time base when operating in Capture or
Compare mode.
In Capture mode, the value in the TMR1H:TMR1L
register pair is copied into the CCPR1H:CCPR1L
register pair on a configured event.
In Compare mode, an event is triggered when the value
CCPR1H:CCPR1L register pair matches the value in
the TMR1H:TMR1L register pair. This event can be a
Special Event Trigger.
For more information, see Section 10.0 “Capture/
Compare/PWM Modules”.
7.9CCP Special Event Trigger
When the CCP is configured to trigger a special event,
the trigger will clear the TMR1H:TMR1L register pair.
This special event does not cause a Timer1 interrupt.
The CCP module may still be configured to generate a
CCP interrupt.
In this mode of operation, the CCPR1H:CCPR1L
register pair becomes the period register for Timer1.
Timer1 should be synchronized to the F
the Special Event Trigger. Asynchronous operation of
Timer1 can cause a Special Event Trigger to be
missed.
In the event that a write to TMR1H or TMR1L coincides
with a Special Event Trigger from the CCP, the write will
take precedence.
The clock input to the Timer2 module is the system
instruction clock (F
Timer2 prescaler, which has prescale options of 1:1,
1:4 or 1:16. The output of the prescaler is then used to
increment the TMR2 register.
The values of TMR2 and PR2 are constantly compared
to determine when they match. TMR2 will increment
from 00h until it matches the value in PR2. When a
match occurs, two things happen:
• TMR2 is reset to 00h on the next increment cycle.
• The Timer2 postscaler is incremented
The match output of the Timer2/PR2 comparator is
then fed into the Timer2 postscaler. The postscaler has
postscale options of 1:1 to 1:16 inclusive. The output of
the Timer2 postscaler is used to set the TMR2IF
interrupt flag bit in the PIR1 register.
OSC/4). The clock is fed into the
The TMR2 and PR2 registers are both fully readable
and writable. On any Reset, the TMR2 register is set to
00h and the PR2 register is set to FFh.
Timer2 is turned on by setting the TMR2ON bit in the
T2CON register to a ‘1’. Timer2 is turned off by clearing
the TMR2ON bit to a ‘0’.
The Timer2 prescaler is controlled by the T2CKPS bits
in the T2CON register. The Timer2 postscaler is
controlled by the T2OUTPS bits in the T2CON register.
The prescaler and postscaler counters are cleared
when:
• A write to TMR2 occurs.
• A write to T2CON occurs.
• Any device Reset occurs (Power-on Reset, MCLR
Reset, Watchdog Timer Reset, or Brown-out
Reset).
Note:TMR2 is not cleared when T2CON is
written.
FIGURE 8-1:TIMER2 BLOCK DIAGRAM
DS40001709B-page 68Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
8.2Register Definitions: Timer2 Control
REGISTER 8-1:T2CON: TIMER2 CONTROL REGISTER
U-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0R/W-0
—T2OUTPS<3:0>TMR2ONT2CKPS<1:0>
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
-n = Value at POR‘1’ = Bit is set‘0’ = Bit is clearedx = Bit is unknown
bit 7Unimplemented: Read as ‘0’
bit 6-3T2OUTPS<3:0>: Timer2 Output Postscaler Select bits
The Hardware Limit Timer (HLT) module is a version of
the Timer2-type modules. In addition to all the Timer2type features, the HLT can be reset on rising and falling
events from selected peripheral outputs.
The HLT primary purpose is to act as a timed hardware
limit to be used in conjunction with asynchronous
analog feedback applications. The external Reset
source synchronizes the HLTMRx to an analog
application.
In normal operation, the external Reset source from the
analog application should occur before the HLTMRx
matches the HLTPRx. This resets HLTMRx for the next
period and prevents the HLTimerx Output from going
active.
When the external Reset source fails to generate a
signal within the expected time, (allowing the HLTMRx
to match the HLTPRx), then the HLTimerx Output
becomes active.
FIGURE 9-1:HLTMRx BLOCK DIAGRAM
The HLT module incorporates the following features:
Refer to Figure 9-1 for a block diagram of the HLT.
DS40001709B-page 70Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
9.1HLT Operation
The clock input to the HLT module is the system
instruction clock (F
each rising clock edge.
A 4-bit counter/prescaler on the clock input provides the
following prescale options:
• Direct input
•Divide-by-4
•Divide-by-16
•Divide-by-64
The prescale options are selected by the prescaler
control bits, HxCKPS<1:0> of the HLTxCON0 register.
The value of HLTMRx is compared to that of the Period
register, HLTPRx, on each clock cycle. When the two
values match,then the comparator generates a match
signal as the HLTimerx output. This signal also resets
the value of HLTMRx to 00h on the next clock rising
edge and drives the output counter/postscaler (see
Section 9.2 “HLT Interrupt”).
The HLTMRx and HLTPRx registers are both directly
readable and writable. The HLTMRx register is cleared
on any device Reset, whereas the HLTPRx register
initializes to FFh. Both the prescaler and postscaler
counters are cleared on any of the following events:
• A write to the HLTMRx register
• A write to the HLTxCON0 register
• Power-on Reset (POR)
• Brown-out Reset (BOR)
•MCLR
• Watchdog Timer (WDT) Reset
• Stack Overflow Reset
• Stack Underflow Reset
• RESET Instruction
Reset
Note:HLTMRx is not cleared when HLTxCON0 is
written.
OSC/4). HLTMRx increments on
9.3Peripheral Resets
Resets driven from the selected peripheral output prevents the HLTMRx from matching the HLTPRx register
and generating an output. In this manner, the HLT can
be used as a hardware time limit to other peripherals.
In this device, the primary purpose of the HLT is to limit
the COG PWM duty cycle. Normally, the COG operation uses analog feedback to determine the PWM duty
cycle. The same feedback signal is used as an HLT
Reset input. The HLTPRx register is set to occur at the
maximum allowed duty cycle. If the analog feedback to
the COG exceeds the maximum time, then an
HLTMRx-to-HLTPRx match will occur and generate the
output needed to limit the COG drive output.
The HLTMRx can be reset by one of several selectable
peripheral sources. Reset inputs include:
• CCP1 output
• Comparator 1 output
• Comparator 2 output
• COGxFLT pin
• COG1OUT0
• COG1OUT1
The external Reset input is selected with the
HxERS<2:0> bits of the HLTxCON1 register. High and
low Reset enables are selected with the HxREREN and
HxFEREN bits, respectively. Setting the HxRES and
HxFES bits makes the respective rising and falling
Reset events edge sensitive. Reset inputs that are not
edge sensitive are level sensitive.
HLTMRx Resets are synchronous with the HLT clock.
In other words, HLTMRx is cleared on the rising edge
of the HLT clock after the enabled Reset event occurs.
If an enabled external Reset occurs at the same time a
write occurs to the TMR4A register, the write to the
timer takes precedence and pending Resets are
cleared.
9.2HLT Interrupt
The HLT can also generate an optional device interrupt.
The HLTMRx output signal (HLTMRx-to-HLTPRx match)
provides the input for the 4-bit counter/postscaler. The
overflow output of the postscaler sets the HLTMRxIF bit
of the PIR1 register. The interrupt is enabled by setting
the HLTMRx Match Interrupt Enable bit, HLTMRxIE of
the PIE1 register.
A range of 16 postscale options (from 1:1 through 1:16
inclusive) can be selected with the postscaler control
bits, HxOUTPS<3:0>, of the HLTxCON0 register.
The unscaled output of HLTMRx is available only to the
COG module, where it is used as a selectable limit to
the maximum COG period.
9.5HLT Operation During Sleep
The HLT cannot be operated while the processor is in
Sleep mode. The contents of the HLTMRx register will
remain unchanged while the processor is in Sleep
mode.
;to CCP1CON
CLRFCCP1CON;Turn CCP1 module off
MOVLWNEW_CAPT_PS ;Load the W reg with
;the new prescaler
;move value and CCP1 ON
MOVWFCCP1CON;Load CCP1CON with this
;value
10.0CAPTURE/COMPARE/PWM
MODULES
The Capture/Compare/PWM module is a peripheral
which allows the user to time and control different
events, and to generate Pulse-Width Modulation
(PWM) signals. In Capture mode, the peripheral allows
the timing of the duration of an event. The Compare
mode allows the user to trigger an external event when
a predetermined amount of time has expired. The
PWM mode can generate Pulse-Width Modulated
signals of varying frequency and duty cycle.
10.1Capture Mode
Capture mode makes use of the 16-bit Timer1
resource. When an event occurs on the CCP1 pin, the
16-bit CCPR1H:CCPR1L register pair captures and
stores the 16-bit value of the TMR1H:TMR1L register
pair, respectively. An event is defined as one of the
following and is configured by the CCP1M<3:0> bits of
the CCP1CON register:
• Every falling edge
• Every rising edge
• Every 4th rising edge
• Every 16th rising edge
When a capture is made, the Interrupt Request Flag bit
CCP1IF of the PIR2 register is set. The interrupt flag
must be cleared in software. If another capture occurs
before the value in the CCPR1H, CCPR1L register pair
is read, the old captured value is overwritten by the new
captured value.
Figure 10-1 shows a simplified diagram of the Capture
operation.
10.1.1CCP1 PIN CONFIGURATION
In Capture mode, the CCP1 pin should be configured
as an input by setting the associated TRIS control bit.
Note:If the CCP1 pin is configured as an output,
a write to the port can cause a capture
condition.
10.1.2TIMER1 MODE RESOURCE
Timer1 must be running in Timer mode or Synchronized
Counter mode for the CCP1 module to use the capture
feature. In Asynchronous Counter mode, the capture
operation may not work.
See Section 7.0 “Timer1 Module with Gate Control”
for more information on configuring Timer1.
10.1.3SOFTWARE INTERRUPT MODE
When the Capture mode is changed, a false capture
interrupt may be generated. The user should keep the
CCP1IE interrupt enable bit of the PIE2 register clear to
avoid false interrupts. Additionally, the user should
clear the CCP1IF interrupt flag bit of the PIR2 register
following any change in Operating mode.
Note:Clocking Timer1 from the system clock
OSC) should not be used in Capture
(F
mode. In order for Capture mode to
recognize the trigger event on the CCP1
pin, Timer1 must be clocked from the
instruction clock (FOSC/4) or from an
external clock source.
10.1.4CCP1 PRESCALER
There are four prescaler settings specified by the
CCP1M<3:0> bits of the CCP1CON register.
Whenever the CCP1 module is turned off, or the CCP1
module is not in Capture mode, the prescaler counter
is cleared. Any Reset will clear the prescaler counter.
Switching from one capture prescaler to another does not
clear the prescaler and may generate a false interrupt. To
avoid this unexpected operation, turn the module off by
clearing the CCP1CON register before changing the
prescaler. Example 10-1 demonstrates the code to
perform this function.
EXAMPLE 10-1:CHANGING BETWEEN
CAPTURE PRESCALERS
FIGURE 10-1:CAPTURE MODE
OPERATION BLOCK
DIAGRAM
DS40001709B-page 74Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
10.1.5CAPTURE DURING SLEEP
Capture mode depends upon the Timer1 module for
proper operation. If the Timer1 clock input source is a
clock that is not disabled during Sleep, Timer1 will continue to operate and Capture mode will operate during
Sleep to wake the device. The T1CKI is an example of
a clock source that will operate during Sleep.
When the input source to Timer1 is disabled during
Sleep, such as the HFINTOSC, Timer1 will not
increment during Sleep. When the device wakes from
Sleep, Timer1 will continue from its previous state.
TABLE 10-1:SUMMARY OF REGISTERS ASSOCIATED WITH CAPTURE
NameBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
CCP1CON——DC1B<1:0>CCP1M<3:0>
CCPR1LCCPR1L<7:0>
CCPR1HCCPR1H<7:0>
INTCONGIE PEIE
PIE1
PIE2
PIR1
PIR2
T1CONTMR1CS<1:0>T1CKPS<1:0>T1OSCENT1SYNC
T1GCON
TMR1HTMR1H<7:0>
TMR1LTMR1L<7:0>
TRISA
Legend: — = Unimplemented location, read as ‘0’. Shaded cells are not used by Capture mode.
Compare mode makes use of the 16-bit Timer1
resource. The 16-bit value of the CCPR1H:CCPR1L
register pair is constantly compared against the 16-bit
value of the TMR1H:TMR1L register pair. When a
match occurs, one of the following events can occur:
• Toggle the CCP1 output
• Set the CCP1 output
• Clear the CCP1 output
• Generate a Special Event Trigger
• Generate a Software Interrupt
The action on the pin is based on the value of the
CCP1M<3:0> control bits of the CCP1CON register. At
the same time, the interrupt flag CCP1IF bit is set.
All Compare modes can generate an interrupt.
Figure 10-2 shows a simplified diagram of the
Compare operation.
FIGURE 10-2:COMPARE MODE
OPERATION BLOCK
DIAGRAM
10.2.1CCP1 PIN CONFIGURATION
The user must configure the CCP1 pin as an output by
clearing the associated TRIS bit.
Note:Clearing the CCP1CON register will force
the CCP1 compare output latch to the
default low level. This is not the PORT I/O
data latch.
10.2.2TIMER1 MODE RESOURCE
In Compare mode, Timer1 must be running in either
Timer mode or Synchronized Counter mode. The
compare operation may not work in Asynchronous
Counter mode.
See Section 7.0 “Timer1 Module with Gate Control”
for more information on configuring Timer1.
Note:Clocking Timer1 from the system clock
(F
OSC) should not be used in Compare
mode. In order for Compare mode to
recognize the trigger event on the CCP1
pin, TImer1 must be clocked from the
instruction clock (F
OSC/4) or from an
external clock source.
10.2.3SOFTWARE INTERRUPT MODE
When Generate Software Interrupt mode is chosen
(CCP1M<3:0> = 1010), the CCP1 module does not
assert control of the CCP1 pin (see the CCP1CON
register).
10.2.4SPECIAL EVENT TRIGGER
When Special Event Trigger mode is chosen
(CCP1M<3:0> = 1011), the CCP1 module does the
following:
• Resets Timer1
• Starts an ADC conversion if ADC is enabled
The CCP1 module does not assert control of the CCP1
pin in this mode.
The Special Event Trigger output of the CCP1 occurs
immediately upon a match between the TMR1H,
TMR1L register pair and the CCPR1H, CCPR1L register pair. The TMR1H, TMR1L register pair is not reset
until the next rising edge of the Timer1 clock. The
Special Event Trigger output starts an A/D conversion
(if the A/D module is enabled). This allows the
CCPR1H, CCPR1L register pair to effectively provide a
16-bit programmable period register for Timer1.
TABLE 10-2:SPECIAL EVENT TRIGGER
DeviceCCP1
PIC16F753
PIC16HV753
Refer to Section 12.0 “Analog-to-Digital Converter(ADC) Module” for more information.
CCP1
Note 1: The Special Event Trigger from the CCP
module does not set interrupt flag bit
TMR1IF of the PIR1 register.
2: Removing the match condition by
changing the contents of the CCPR1H
DS40001709B-page 76Preliminary 2013 Microchip Technology Inc.
and CCPR1L register pair, between the
clock edge that generates the Special
Event Trigger and the clock edge that
generates the Timer1 Reset, will
preclude the Reset from occurring.
PIC16F753/HV753
10.2.5COMPARE DURING SLEEP
The Compare mode is dependent upon the system
clock (F
down during Sleep mode, the Compare mode will not
function properly during Sleep.
TABLE 10-3:SUMMARY OF REGISTERS ASSOCIATED WITH COMPARE
CCP1CON——DC1B<1:0>CCP1M<3:0>
CCPR1LCCPR1L<7:0>
CCPR1HCCPR1H<7:0>
INTCONGIE PEIE
PIE1TMR1GIE
PIE2——C2IEC1IE—COG1IE—CCP1IE19
PIR1TMR1GIF
PIR2——C2IFC1IF—COG1IF—CCP1IF21
T1CONTMR1CS<1:0>T1CKPS<1:0>T1OSCENT1SYNC—TMR1ON
T1GCONTMR1GE T1GPOLT1GTMT1GSPMT1GGO/
TMR1HTMR1H<7:0>
TMR1LTMR1L<7:0>
TRISA
Legend: — = Unimplemented location, read as ‘0’. Shaded cells are not used by Compare mode.
Note 1:The 8-bit timer TMR2 register is concatenated
with the 2-bit internal system clock (F
OSC), or
2 bits of the prescaler, to create the 10-bit time
base.
2:In PWM mode, CCPR1H is a read-only register.
TRIS
CCP1
Comparator
10.3PWM Overview
Pulse-Width Modulation (PWM) is a scheme that
provides power to a load by switching quickly between
fully on and fully off states. The PWM signal resembles
a square wave where the high portion of the signal is
considered the on state and the low portion of the signal
is considered the off state. The high portion, also known
as the pulse width, can vary in time and is defined in
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
PWM period is defined as the duration of one complete
cycle or the total amount of on and off time combined.
PWM resolution defines the maximum number of steps
that can be present in a single PWM period. A higher
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
time to the off time and is expressed in percentages,
where 0% is fully off and 100% is fully on. A lower duty
cycle corresponds to less power applied and a higher
duty cycle corresponds to more power applied.
Figure 10-3 shows a typical waveform of the PWM
signal.
FIGURE 10-3:CCP1 PWM OUTPUT
SIGNAL
FIGURE 10-4:SIMPLIFIED PWM BLOCK
DIAGRAM
10.3.1STANDARD PWM OPERATION
The standard PWM mode generates a Pulse-Width
Modulation (PWM) signal on the CCP1 pin with up to 10
bits of resolution. The period, duty cycle, and resolution
are controlled by the following registers:
• PR2 registers
• T2CON registers
• CCPR1L registers
• CCP1CON registers
Figure 10-4 shows a simplified block diagram of PWM
operation.
Note 1: The corresponding TRIS bit must be
cleared to enable the PWM output on the
CCP1 pin.
2: Clearing the CCP1CON register will
relinquish control of the CCP1 pin.
DS40001709B-page 78Preliminary 2013 Microchip Technology Inc.
The following steps should be taken when configuring
the CCP1 module for standard PWM operation:
1.Disable the CCP1 pin output driver by setting
the associated TRIS bit.
2. Load the PR2 register with the PWM period
value.
3. Configure the CCP1 module for the PWM mode
by loading the CCP1CON register with the
appropriate values.
4. Load the CCPR1L register and the DC1B<1:0>
bits of the CCP1CON register, with the PWM
duty cycle value.
5. Configure and start Timer2:
• Clear the TMR2IF interrupt flag bit of the
PIR1 register. See Note below.
• Configure the T2CKPS bits of the T2CON
register with the Timer prescale value.
• Enable the Timer by setting the TMR2ON
bit of the T2CON register.
6. Enable PWM output pin:
• Wait until the Timer overflows and the
TMR2IF bit of the PIR1 register is set. See
Note below.
• Enable the CCP1 pin output driver by clear-
ing the associated TRIS bit.
Note:In order to send a complete duty cycle and
period on the first PWM output, the above
steps must be included in the setup
sequence. If it is not critical to start with a
complete PWM signal on the first output,
then step 6 may be ignored.
When TMR2 is equal to PR2, the following three events
occur on the next increment cycle:
•TMR2 is cleared
• The CCP1 pin is set. (Exception: If the PWM duty
cycle = 0%, the pin will not be set.)
• The PWM duty cycle is latched from CCPR1L into
CCPR1H.
Note:The Timer postscaler (see Section 8.1
“Timer2 Operation”) is not used in the
determination of the PWM frequency.
10.3.4PWM DUTY CYCLE
The PWM duty cycle is specified by writing a 10-bit
value to multiple registers: CCPR1L register and
DC1B<1:0> bits of the CCP1CON register. The
CCPR1L contains the eight MSbs and the DC1B<1:0>
bits of the CCP1CON register contain the two LSbs.
CCPR1L and DC1B<1:0> bits of the CCP1CON
register can be written to at any time. The duty cycle
value is not latched into CCPR1H until after the period
completes (i.e., a match between PR2 and TMR2
registers occurs). While using the PWM, the CCPR1H
register is read-only.
Equation 10-2 is used to calculate the PWM pulse
width.
Equation 10-3 is used to calculate the PWM duty cycle
ratio.
EQUATION 10-2:PULSE WIDTH
10.3.3PWM PERIOD
The PWM period is specified by the PR2 register of
Timer2. The PWM period can be calculated using the
formula of Equation 10-1.
The CCPR1H register and a 2-bit internal latch are
used to double buffer the PWM duty cycle. This double
buffering is essential for glitchless PWM operation.
The 8-bit timer TMR2 register is concatenated with
either the 2-bit internal system clock (F
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
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Reset
‘1’ = Bit is set‘0’ = Bit is cleared
DC1B<1:0>CCP1M<3:0>
bit 7-6
bit 5-4
bit 3-0
Unimplemented: Read as ‘0’
DC1B<1:0>: PWM Duty Cycle Least Significant bits
Capture mode:
Unused
Compare mode:
Unused
PWM mode:
These bits are the two LSbs of the PWM duty cycle. The eight MSbs are found in CCPR1L.
CCP1M<3:0>: CCP1 Mode Select bits
0000 = Capture/Compare/PWM off (resets CCP1 module)
0001 = Reserved
0010 = Compare mode: toggle output on match
0011 = Reserved
0100 = Capture mode: every falling edge
0101 = Capture mode: every rising edge
0110 = Capture mode: every 4th rising edge
0111 = Capture mode: every 16th rising edge
1000 = Compare mode: initialize CCP1 pin low; set output on compare match (set CCP1IF)
1001 = Compare mode: initialize CCP1 pin high; clear output on compare match (set CCP1IF)
1010 = Compare mode: generate software interrupt only; CCP1 pin reverts to I/O state
1011 = Compare mode: Special Event Trigger (CCP1 resets Timer, sets CCP1IF bit, and starts A/D conversion
if A/D module is enabled)
11xx = PWM mode
DS40001709B-page 80Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
11.0COMPLEMENTARY OUTPUT
GENERATOR (COG) MODULE
The primary purpose of the Complementary Output
Generator (COG) is to convert a single output PWM
signal into a two output complementary PWM signal.
The COG can also convert two separate input events
into a single or complementary PWM output.
The COG PWM frequency and duty cycle are
determined by a rising event input and a falling event
input. The rising event and falling event may be the
same source. Sources may be synchronous or
asynchronous to the COG_clock.
The rate at which the rising event occurs determines
the PWM frequency. The time from the rising event
input to the falling event input determines the duty
cycle.
A selectable clock input is used to generate the phase
delay, blanking and dead-band times.
A simplified block diagram of the COG is shown in
Figure 11-1.
The COG module has the following features:
• Two modes of operation:
- Synchronous PWM
- Push-pull
• Selectable clock source
• Independently selectable rising event sources
• Independently selectable falling event sources
• Independently selectable edge or level event
sensitivity
• Independent output enables
• Independent output polarity selection
• Phase delay with independent rising and falling
delay times
• Dead-band control with:
- Independent rising and falling event
dead-band times
- Synchronous and asynchronous timing
• Blanking control with independent rising and
falling event blanking times
• Auto-shutdown control with:
- Independently selectable shutdown sources
- Auto-restart enable
- Auto-shutdown pin override control (high,
low, off, and High-Z)
11.1Fundamental Operation
11.1.1SYNCHRONOUS PWM MODE
In synchronous PWM mode, the COG generates a two
output complementary PWM waveform from rising and
falling event sources. In the simplest configuration, the
rising and falling event sources have the same signal,
which is a PWM signal with the desired period and duty
cycle. The COG converts this single PWM input into a
dual complementary PWM output. The frequency and
duty cycle of the dual PWM output match those of the
single input PWM signal. The off-to-on transition of
each output can be delayed from the on-to-off transition
of the other output, thereby creating a time immediately
after the PWM transition where neither output is driven.
This is referred to as dead time and is covered in
Section 11.5 “Dead-Band Control”.
A typical operating waveform, with dead band, generated
from a single CCP1 input is shown in Figure 11-4.
11.1.2PUSH-PULL MODE
In Push-Pull mode, the COG generates a single PWM
output that alternates every PWM period, between the
two COG output pins. The output drive activates with
the rising input event and terminates with the falling
event input. Each rising event starts a new period and
causes the output to switch to the COG pin not used in
the previous period.
A typical push-pull waveform generated from a single
CCP1 input is shown in Figure 11-6.
Push-Pull mode is selected by setting the GxMD bit of
the COGxCON0 register.
11.1.3ALL MODES
In addition to generating a complementary output from
a single PWM input, the COG can also generate PWM
waveforms from a periodic rising event and a separate
falling event. In this case, the falling event is usually
derived from analog feedback within the external PWM
driver circuit. In this configuration, high-power
switching transients may trigger a false falling event
that needs to be blanked out. The COG can be
configured to blank falling (and rising) event inputs for
a period of time immediately following the rising (and
falling) event drive output. This is referred to as input
blanking and is described in Section 11.6 “Blanking
Control”.
It may be necessary to guard against the possibility of
circuit faults. In this case, the active drive must be
terminated before the Fault condition causes damage.
This is referred to as auto-shutdown and is described in
Section 11.8 “Auto-shutdown Control”.
A feedback falling event arriving too late or not at all can
be terminated with auto-shutdown or by enabling one of
the Hardware Limit Timer (HLT) event inputs. See
Section 9.0 “Hardware Limit Timer (HLT) Module”
for more information about the HLT.
The COG can be configured to operate in phase
delayed conjunction with another PWM. The active
drive cycle is delayed from the rising event by a phase
delay timer. Phase delay is covered in more detail in
Section 11.7 “Phase Delay”. A typical operating
waveform, with phase delay and dead band, generated
from a single CCP1 input, is shown in Figure 11-5.
FIGURE 11-5:COG OPERATION WITH CCP1 AND PHASE DELAY
FIGURE 11-6:COG OPERATION IN PUSH-PULL MODE WITH CCP1
DS40001709B-page 84Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
Rising (CCP1)
Falling (C1OUT)
C1IN-
COGOUT
hyst
Edge Sensitive
Rising (CCP1)
Falling (C1OUT)
C1IN-
COGOUT
hyst
Level Sensitive
11.2Clock Sources
The COG_clock is used as the reference clock to the
various timers in the peripheral. Timers that use the
COG_clock include:
• Rising and falling dead-band time
• Rising and falling blanking time
• Rising and falling event phase delay
Clock sources available for selection include:
• 8 MHz HFINTOSC (active during Sleep)
• Instruction clock (Fosc/4)
• System clock (Fosc)
The clock source is selected with the GxCS<1:0> bits
of the COGxCON1 register (Register 11-2).
11.3Selectable Event Sources
The COG uses any combination of independently
selectable event sources to generate the
complementary waveform. Sources fall into two
categories:
• Rising event sources
• Falling event sources
The rising event sources are selected by setting bits in
the COGxRIS register (Register 11-3). The falling event
sources are selected by setting bits in the COGxFIS
register (Register 11-5). All selected sources are ‘OR’d
together to generate the corresponding event signal.
Refer to Figure 11-2.
11.3.1EDGE VS. LEVEL SENSING
Event input detection may be selected as level or
edge-sensitive. The Detection mode is individually selectable for every source. Rising source detection modes are
selected with the COGxRSIM register (Register 11-4).
Falling source detection modes are selected with the
COGxFSIM register (Register 11-6). A set bit enables
edge detection for the corresponding event source. A
cleared bit enables level detection.
In general, events that are driven from a periodic source
should be edge-detected and events that are derived from
voltage thresholds at the target circuit should be
level-sensitive. Consider the following two examples:
1. The first example is an application in which the
period is determined by a 50% duty cycle clock
and the COG output duty cycle is determined by
a voltage level fed back through a comparator. If
the clock input is level sensitive, duty cycles less
than 50% will exhibit erratic operation.
2. The second example is similar to the first,
except that the duty cycle is close to 100%. The
feedback comparator high-to-low transition trips
the COG drive off, but almost immediately the
period source turns the drive back on. If the off
cycle is short enough, the comparator input may
not reach the low side of the hysteresis band
precluding an output change. The comparator
output stays low and without a high-to-low transition to trigger the edge sense, the drive of the
COG output will be stuck in a constant drive-on
condition. See Figure 11-7.
FIGURE 11-7:EDGE VS. LEVEL SENSE
11.3.2RISING EVENT
The rising event starts the PWM output active duty
cycle period. The rising event is the low-to-high
transition of the rising_event output. When the rising
event phase delay and dead-band time values are zero,
the COGxOUT0 output starts immediately. Otherwise,
the COGxOUT0 output is delayed. The rising event
source causes all the following actions:
• Set COGxOUT0 output after dead-band delay
expires.
11.3.3FALLING EVENT
The falling event terminates the PWM output active
duty cycle period. The falling event is the high-to-low
transition of the falling_event output. When the falling
event phase delay and dead-band time values are
zero, the COGxOUT1 output starts immediately.
Otherwise, the COGxOUT1 output is delayed. The
falling event source causes all the following actions:
Upon disabling, or immediately after enabling the COG
module, the complementary drive is configured with
COGxOUT0 drive inactive and COGxOUT1 drive
active.
11.4.1OUTPUT ENABLES
Each COG output pin has an individual output enable
control. Output enables are selected with the GxOE0 and
GxOE1 bits of the COGxCON0 register (Register 11-1).
When an output enable control is cleared, the module
asserts no control over the pin. When an output enable is
set, the override value or PWM waveform is applied to
the pin per the port priority selection.
The device pin outputenable control bits are
independent of the GxEN bit of the COGxCON0
register, which enables the COG. When GxEN is
cleared, and shutdown is not active, the Reset state
PWM levels are present on the COG output pins. The
PWM levels are affected by the polarity controls. If
shutdown is active when GxEN is cleared, the
shutdown override levels will be present on the COG
output pins. Note that setting the GxASE bit while the
GxEN bit is cleared will activate shutdown which can
only be cleared by either a rising event while the GxEN
bit is set, or a device Reset.
11.4.2POLARITY CONTROL
The polarity of each COG output can be selected
independently. When the output polarity bit is set, the
corresponding output is active-low. Clearing the output
polarity bit configures the corresponding output as
active-high. However, polarity does not affect the
shutdown override levels.
Output polarity is selected with the GxPOL0 and
GxPOL1 bits of the COGxCON0 register (Register 11-1).
11.5Dead-Band Control
11.5.1ASYNCHRONOUS DELAY CHAIN
DEAD-BAND DELAY
Asynchronous dead-band delay is determined by the
time it takes the input to propagate through a series of
delay elements. Each delay element is a nominal five
nanoseconds.
Set the COGxDBR register (Register 11-9) value to the
desired number of delay elements in the COGxOUT0
dead band. Set the COGxDBF register (Register 11-10)
value to the desired number of delay elements in the
COGxOUT1 dead band. When the value is zero,
dead-band delay is disabled.
11.5.2SYNCHRONOUS COUNTER
DEAD-BAND DELAY
Synchronous counter dead band is timed by counting
COG_clock periods from zero up to the value in the
dead-band count register. Use Equation 11-1 to
calculate dead-band times.
Set the COGxDBR count register value to obtain the
desired dead-band time of the COGxOUT0 output. Set
the COGxDBF count register value to obtain the
desired dead-band time of the COGxOUT1 output.
When the value is zero, dead-band delay is disabled.
11.5.3SYNCHRONOUS COUNTER
DEAD-BAND TIME UNCERTAINTY
When the rising and falling events that trigger the
dead-band counters come from asynchronous inputs,
it creates uncertainty in the synchronous counter
dead-band time. The maximum uncertainty is equal to
one COG_clock period. Refer to Equation 11-1 for
more detail.
When event input sources are asynchronous with no
phase delay, use the asynchronous delay chain
dead-band mode to avoid the dead-band time
uncertainty.
The dead-band control provides for non-overlapping
PWM output signals to prevent shoot-through current
in the external power switches.
The COG contains two dead-band timers. One
dead-band timer is used for rising event dead-band
control. The other is used for falling event dead-band
control. Timer modes are selectable as either:
• Asynchronous delay chain
• Synchronous counter
The dead-band Timer mode is selected for the
COGxOUT0 and COGxOUT1 dead-band times with
the respective GxRDBTS and GxFDBTS bits of the
COGxCON1 register (Register 11-2).
DS40001709B-page 86Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
11.5.4RISING EVENT DEAD BAND
Rising event dead band adds a delay between the
COGxOUT1 signal deactivation and the COGxOUT0
signal activation. The rising event dead-band time
starts when the rising_event output goes true.
See Section 11.5.1, Asynchronous Delay Chain
Dead-band Delay and Section 11.5.2, Synchronous
Counter Dead-band Delay for more information on
setting the rising edge dead-band time.
11.5.5FALLING EVENT DEAD BAND
Falling event dead band adds a delay between the
COGxOUT1 signal deactivation and the COGxOUT0
signal activation. The falling event dead-band time
starts when the falling_event output goes true.
See Section 11.5.1, Asynchronous Delay Chain
Dead-band Delay and Section 11.5.2, Synchronous
Counter Dead-band Delay for more information on
setting the rising edge dead-band time.
11.5.6DEAD-BAND OVERLAP
There are two cases of dead-band overlap:
• Rising-to-falling
• Falling-to-rising
11.5.6.1Rising-to-Falling Overlap
In this case, the falling event occurs while the rising
event dead-band counter is still counting. When this
happens, the COGxOUT0 drive is suppressed and the
dead band extends by the falling event dead-band
time. At the termination of the extended dead-band
time, the COGxOUT1 drive goes true.
11.5.6.2Falling-to-Rising Overlap
In this case, the rising event occurs while the falling
event dead-band counter is still counting. When this
happens, the COGxOUT1 drive is suppressed and the
dead band extends by the rising event dead-band
time. At the termination of the extended dead-band
time, the COGxOUT0 drive goes true.
11.6Blanking Control
falling input events. Once started, blanking extends for
the time specified by the corresponding blanking
counter.
Blanking is timed by counting COG_clock periods from
zero up to the value in the blanking count register. Use
Equation 11-1 to calculate blanking times.
11.6.1FALLING EVENT BLANKING OF
RISING EVENT INPUTS
The falling event blanking counter inhibits rising event
inputs from triggering a rising event. The falling event
blanking time starts when the rising event output drive
goes false.
The falling event blanking time is set by the value
contained in the COGxBKF register (Register 11-12).
Blanking times are calculated using the formula shown
in Equation 11-1.
When the COGxBKF value is zero, the falling event
blanking is disabled and the blanking counter output is
true, thereby allowing the event signal to pass straight
through to the event trigger circuit.
11.6.2RISING EVENT BLANKING OF
FALLING EVENT INPUTS
The rising event blanking counter inhibits falling event
inputs from triggering a falling event. The rising event
blanking time starts when the falling event output drive
goes false.
The rising event blanking time is set by the value
contained in the COGxBKR register (Register 11-11).
When the COGxBKR value is zero, the rising event
blanking is disabled and the blanking counter output is
true, thereby allowing the event signal to pass straight
through to the event trigger circuit.
11.6.3BLANKING TIME UNCERTAINTY
When the rising and falling sources that trigger the
blanking counters are asynchronous to the
COG_clock, it creates uncertainty in the blanking time.
The maximum uncertainty is equal to one COG_clock
period. Refer to Equation 11-1 and Example 11-2 for
more detail.
Input blanking is a function, whereby the event inputs
can be masked or blanked for a short period of time.
This is to prevent electrical transients caused by the
turn-on/off of power components from generating a
false input event.
The COG contains two blanking counters: one
triggered by the rising event and the other triggered by
the falling event. The counters are cross-coupled with
the events they are blanking. The falling event
blanking counter is used to blank rising input events
and the rising event blanking counter is used to blank
It is possible to delay the assertion of either or both the
rising event and falling event. This is accomplished by
placing a non-zero value in COGxPHR or COGxPHF
phase delay count register, respectively
(Register 11-13 and Register 11-14). Refer to
Figure 11-5 for COG operation with CCP1 and phase
delay. The delay from the input rising event signal
switching to the actual assertion of the events is
calculated the same as the dead-band and blanking
delays. Please see Equation 11-1.
PIC16F753/HV753
T
min
Count=
T
max
Count1+
F
COG_clock
--------------------------=
T
uncertainty
T
maxTmin
–=
T
uncertainty
1
F
COG_clock
--------------------------=
Also:
Where:
TCount
Rising Phase DelayCOGxPHR
Falling Phase DelayCOGxPHF
Rising Dead BandCOGxDBR
Falling Dead BandCOGxDBF
Rising Event BlankingCOGxBKR
Falling Event BlankingCOGxBKF
COG_clock
F
Given:
Therefore:
CountAh10d==
F
COG_Clock
8MHz=
T
uncertainty
1
F
COG_clock
--------------------------=
1
8MHz
---------------=
125ns=
Proof:
T
min
Count
F
COG_clock
--------------------------
=
125ns10d=1.25s=
T
max
Count1+
F
COG_clock
--------------------------=
125ns10d1+=
1.375s=
Therefore:
T
uncertainty
T
maxTmin
–=
1.375s1.25s–=
125ns=
When the phase delay count value is zero, phase
delay is disabled and the phase delay counter output
is true, thereby allowing the event signal to pass
straight through to complementary output driver flop.
11.7.1CUMULATIVE UNCERTAINTY
It is not possible to create more than one COG_clock of
uncertainty by successive stages. Consider that the
phase delay stage comes after the blanking stage, the
dead-band stage comes after either the blanking or
phase delay stages, and the blanking stage comes
after the dead-band stage. When the preceding stage
is enabled, the output of that stage is necessarily
synchronous with the COG_clock, which removes any
possibility of uncertainty in the succeeding stage.
EQUATION 11-1:PHASE, DEAD-BAND AND
BLANKING TIME
CALCULATION
EQUATION 11-2:TIMER UNCERTAINTY
DS40001709B-page 88Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
11.8Auto-shutdown Control
Auto-shutdown is a method to immediately override
the COG output levels with specific overrides that
allow for safe shutdown of the circuit.
The shutdown state can be either cleared
automatically or held until cleared by software. In
either case, the shutdown overrides remain in effect
until the first rising event after the shutdown is cleared.
11.8.1SHUTDOWN
The shutdown state can be entered by either of the
following two mechanisms:
• Software generated
• External Input
11.8.1.1Software Generated Shutdown
Setting the GxASDE bit of the COGxASD0 register
(Register 11-7) will force the COG into the shutdown
state.
When auto-restart is disabled, the shutdown state will
persist until the first rising event after the GxASDE bit
is cleared by software.
When auto-restart is enabled, the GxASDE bit will
clear automatically and resume operation on the first
rising event after the shutdown input clears. See
Figure 11-8 and Section 11.8.3.2 “Auto-Restart”.
11.8.1.2External Shutdown Source
External shutdown inputs provide the fastest way to
safely suspend COG operation in the event of a Fault
condition. When any of the selected shutdown inputs
goes true, the output drive latches are reset and the
COG outputs immediately go to the selected override
levels without software delay.
Any combination of the input sources can be selected
to cause a shutdown condition. Shutdown input
sources include:
• HLTimer1 output
• HLTimer2 output
• C2OUT (low true)
• C1OUT (low true)
• COG1FLT pin (low true)
Shutdown inputs are selected independently with bits
of the COGxASD1 register (Register 11-8).
11.8.2PIN OVERRIDE LEVELS
The levels driven to the output pins, while the
shutdown is active, are controlled by the
GxASD0L<1:0> and GxASD1L<1:0> bits of the
COGxASD0 register (Register 11-7). GxASD0L<1:0>
controls the GxOUT0 override level and
GxASD1L<1:0> controls the GxOUT1 override level.
There are four override options for each output:
•Forced low
• Forced high
• Tri-state
• PWM inactive state (same state as that caused by
a falling event)
Note:The polarity control does not apply to the
forced low and high override levels.
11.8.3AUTO-SHUTDOWN RESTART
After an auto-shutdown event has occurred, there are
two ways to have the module resume operation:
• Software controlled
• Auto-restart
The restart method is selected with the GxARSEN bit
of the COGxASD0 register. Waveforms of a software
controlled automatic restart are shown in Figure 11-8.
11.8.3.1Software Controlled Restart
When the GxARSEN bit of the COGxASD0 register is
cleared, software must clear the GxASDE bit to restart
COG operation after an auto-shutdown event.
The COG will resume operation on the first rising
event after the GxASDE bit is cleared. Clearing the
shutdown state requires all selected shutdown inputs
to be false, otherwise, the GxASDE bit will remain set.
11.8.3.2Auto-Restart
When the GxARSEN bit of the COGxASD0 register is
set, the COG will restart from the auto-shutdown state
automatically.
The GxASDE bit will clear automatically and the COG
will resume operation on the first rising event after all
selected shutdown inputs go false.
Note:Shutdown inputs are level-sensitive, not
edge-sensitive. The shutdown state
cannot be cleared as long as the
shutdown input level persists, except by
disabling auto-shutdown.
Normal OutputShutdownNormal OutputShutdownNormal Output
Software Controlled Restart
Auto-Restart
CCP1
GxARSEN
Shutdown Input
GxASDE
GxASDL0
GxASDL1
COGxOUT0
COGxOUT1
Operating State
FIGURE 11-8:AUTO-SHUTDOWN WAVEFORM – CCP1 AS RISING AND FALLING EVENT INPUT
SOURCE
DS40001709B-page 90Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
11.9Buffer Updates
Changes to the phase, dead-band, and blanking count
registers need to occur simultaneously during COG
operation to avoid unintended operation that may
occur as a result of delays between each register
write. This is accomplished with the GxLD bit of the
COGxCON0 register and double buffering of the
phase, blanking, and dead-band count registers.
Before the COG module is enabled, writing the count
registers loads the count buffers without need of the
GxLD bit. However, when the COG is enabled, the
count buffers updates are suspended after writing the
count registers until after the GxLD bit is set. When the
GxLD bit is set, the phase, dead-band, and blanking
register values are transferred to the corresponding
buffers synchronous with COG operation. The GxLD
bit is cleared by hardware when the transfer is
complete.
11.10 Alternate Pin Selection
The COGxOUT0, COGxOUT1 and COGxFLT
functions can be directed to alternate pins with control
bits of the APFCON register. Refer to Register 5-1.
Note:The default COG outputs have high drive
strength capability, whereas the alternate
outputs do not.
11.11 Operation During Sleep
The COG continues to operate in Sleep provided that
the COG_clock, rising event, and falling event sources
remain active.
The HFINTSOC remains active during Sleep when the
COG is enabled and the HFINTOSC is selected as the
COG_clock source.
11.12 Configuring the COG
The following steps illustrate how to properly configure
the COG to ensure a synchronous start with the rising
event input:
1. Configure the desired COGxFLT input,
COGxOUT0 and COGxOUT1 pins with the
corresponding bits in the APFCON register.
2. Clear all ANSELA register bits associated with
pins that are used for COG functions.
3. Ensure that the TRIS control bits corresponding
to COGxOUT0 and COGxOUT1 are set so that
both are configured as inputs. These will be set
as outputs later.
4. Clear the GxEN bit, if not already cleared.
5.Set desired dead-band times with the COGxDBR
and COGxDBF registers.
6. Set desired blanking times with the COGxBKR
and COGxBKF registers.
7. Set desired phase delay with the COGxPHR
and COGxPHF registers.
8. Select the desired shutdown sources with the
COGxASD1 register.
9. Set up the following controls in COGxASD0
auto-shutdown register:
• Select both output overrides to the desired
levels (this is necessary, even if not using
auto-shutdown because start-up will be from
a shutdown state).
• Set the GxASDE bit and clear the GxARSEN
bit.
10. Select the desired rising and falling event sources
with the COGxRIS and COGxFIS registers.
11. Select the desired rising and falling event modes
with the COGxRSIM and COGxFSIM registers.
12. Configure the following controls in the
COGxCON1 register:
• Select the desired clock source
• Select the desired dead-band timing sources
13. Configure the following controls in the
COGxCON0 register:
• Select the desired output polarities.
• Set the output enables of the outputs to be
used.
14. Set the GxEN bit.
15. Clear TRIS control bits corresponding to
COGxOUT0 and COGxOUT1 to be used,
thereby configuring those pins as outputs.
16. If auto-restart is to be used, set the GxARSEN bit
and the GxASDE will be cleared automatically.
Otherwise, clear the GxASDE bit to start the
COG.
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is clearedq = Value depends on condition
bit 7Unimplemented: Read as ‘0’
bit 6GxRMHLT2: COGx Rising Event Input Source 6 Mode bit
GxRIHLT2 = 1:
1 = HLTimer2 low-to-high transition will cause a rising event after rising event phase delay
0 = HLTimer2 high level will cause an immediate rising event
GxRIHLT2 = 0:
HLTimer2 has no effect on rising event
bit 5GxRMHLT1: COGx Rising Event Input Source 5 Mode bit
GxRIHLT1 = 1:
1 = HLTimer1 low-to-high transition will cause a rising event after rising event phase delay
0 = HLTimer1 high level will cause an immediate rising event
GxRIHLT1 = 0:
HLTimer1 has no effect on rising event
bit 4GxRMT2M: COGx Rising Event Input Source 4 Mode bit
GxRIT2M = 1:
1 = Timer2 match with PR2 low-to-high transition will cause a rising event after rising event phase delay
0 = Timer2 match with PR2 high level will cause an immediate rising event
GxRIT2M = 0:
Timer2 match with PR2 has no effect on rising event
bit 3GxRMFLT: COGx Rising Event Input Source 3 Mode bit
GxRIFLT =
1 = COGxFLT pin low-to-high transition will cause a rising event after rising event phase delay
0 = COGxFLT pin high level will cause an immediate rising event
GxRIFLT = 0:
COGxFLT pin has no effect on rising event
bit 2GxRMCCP1: COGx Rising Event Input Source 2 Mode bit
GxRICCP1 =
1 = CCP1 low-to-high transition will cause a rising event after rising event phase delay
0 = CCP1 high level will cause an immediate rising event
GxRICCP1 = 0:
CCP1 has no effect on rising event
bit 1GxRMC2: COGx Rising Event Input Source 1 Mode bit
GxRIC2 =
1 = Comparator 2 low-to-high transition will cause a rising event after rising event phase delay
0 = Comparator 2 high level will cause an immediate rising event
GxRIC2 = 0:
Comparator 2 has no effect on rising event
bit 0GxRMC1: COGx Rising Event Input Source 0 Mode bit
GxRIC1 =
1 = Comparator 1 low-to-high transition will cause a rising event after rising event phase delay
0 = Comparator 1 high level will cause an immediate rising event
GxRIC1 = 0:
Comparator 1 has no effect on rising event
1:
1:
1:
1:
(1)
(1)
(1)
Note 1:These sources are pulses and therefore the only benefit of Edge mode over Level mode is that they can be
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is clearedq = Value depends on condition
bit 7Unimplemented: Read as ‘0’
bit 6GxFMHLT2: COGx Falling Event Input Source 6 Mode bit
GxFIHLT2 = 1:
1 = HLTimer2 low-to-high transition will cause a falling event after falling event phase delay
0 = HLTimer2 high level will cause an immediate falling event
GxFIHLT2 = 0:
HLTimer2 has no effect on falling event
bit 5GxFMHLT1: COGx Falling Event Input Source 5 Mode bit
GxFIHLT1 = 1:
1 = HLTimer1 low-to-high transition will cause a falling event after falling event phase delay
0 = HLTimer1 high level will cause an immediate falling event
GxFIHLT1 = 0:
HLTimer1 has no effect on falling event
bit 4GxFMT2M: COGx Falling Event Input Source 4 Mode bit
GxFIT2M = 1:
1 = Timer2 match with PR2 low-to-high transition will cause a falling event after falling event phase delay
0 = Timer2 match with PR2 high level will cause an immediate falling event
GxFIT2M = 0:
Timer2 match with PR2 has no effect on falling event
bit 3GxFMFLT: COGx Falling Event Input Source 3 Mode bit
GxFIFLT =
1 = COGxFLT pin low-to-high transition will cause a falling event after falling event phase delay
0 = COGxFLT pin high level will cause an immediate falling event
GxFIFLT = 0:
COGxFLT pin has no effect on falling event
bit 2GxFMCCP1: COGx Falling Event Input Source 2 Mode bit
GxFICCP1 =
1 = CCP1 low-to-high transition will cause a falling event after falling event phase delay
0 = CCP1 high level will cause an immediate falling event
GxFICCP1 = 0:
CCP1 has no effect on falling event
bit 1GxFMC2: COGx Falling Event Input Source 1 Mode bit
GxFIC2 =
1 = Comparator 2 low-to-high transition will cause a falling event after falling event phase delay
0 = Comparator 2 high level will cause an immediate falling event
GxFIC2 = 0:
Comparator 2 has no effect on falling event
bit 0GxFMC1: COGx Falling Event Input Source 0 Mode bit
GxFIC1 =
1 = Comparator 1 low-to-high transition will cause a falling event after falling event phase delay
0 = Comparator 1 high level will cause an immediate falling event
GxFIC1 = 0:
Comparator 1 has no effect on falling event
1:
1:
1:
1:
(1)
(1)
(1)
Note 1:These sources are pulses and therefore the only benefit of Edge mode over Level mode is that they can be
REGISTER 11-7:COGxASD0: COG AUTO-SHUTDOWN CONTROL REGISTER 0
R/W-0/0R/W-0/0R/W-0/0R/W-0/0R/W-0/0R/W-0/0U-0U-0
GxASDEGxARSENGxASD1L<1:0>GxASD0L<1:0>——
bit 7bit 0
Legend:
R = Readable bitW = Writable bitU = Unimplemented bit, read as ‘0’
u = Bit is unchangedx = Bit is unknown-n/n = Value at POR and BOR/Value at all other Resets
‘1’ = Bit is set‘0’ = Bit is clearedq = Value depends on condition
bit 7GxASDE: Auto-Shutdown Event Status bit
1 = COG is in the shutdown state
0 = COG is either not in the shutdown state or will exit the shutdown state on the next rising event
bit 6GxARSEN: Auto-Restart Enable bit
1 = Auto-restart is enabled
0 = Auto-restart is disabled
bit 5-4GxASD1L<1:0>: COGxOUT1 Auto-Shutdown Override Level Select bits
11 = COGxOUT1 is tri-stated when shutdown is active
10 = The inactive state of the pin, including polarity, is placed on COGxOUT1 when shutdown is active
01 =A logic ‘1’ is placed on COGxOUT1 when shutdown is active
00 =A logic ‘0’ is placed on COGxOUT1 when shutdown is active
bit 3-2GxASD0L<1:0>: COGxOUT0 Auto-Shutdown Override Level Select bits
11 = COGxOUT0 is tri-stated when shutdown is active
10 = The inactive state of the pin, including polarity, is placed on COGxOUT0 when shutdown is active
01 =A logic ‘1’ is placed on COGxOUT0when shutdown is active
00 =A logic ‘0’ is placed on COGxOUT0when shutdown is active
bit 1-0Unimplemented: Read as ‘0’
DS40001709B-page 98Preliminary 2013 Microchip Technology Inc.
PIC16F753/HV753
REGISTER 11-8:COGxASD1: COG AUTO-SHUTDOWN CONTROL REGISTER 1