Техническая Спецификация для Microchip Technology ARD00385

Скачать
Страница из 570
 2009-2011 Microchip Technology Inc.
DS39957D-page 243
PIC18F87K90 FAMILY
FIGURE 18-1:
CAPTURE MODE OPERATION BLOCK DIAGRAM 
18.2.3
SOFTWARE INTERRUPT
When the Capture mode is changed, a false capture
interrupt may be generated. The user should keep the
CCP4IE bit (PIE4<1>) clear to avoid false interrupts
and should clear the flag bit, CCP4IF, following any
such change in operating mode.
18.2.4
CCP PRESCALER
There are four prescaler settings in Capture mode.
They are specified as part of the operating mode
selected by the mode select bits (CCP4M<3:0>).
Whenever the CCP module is turned off, or the CCP
module is not in Capture mode, the prescaler counter
is cleared. This means that any Reset will clear the
prescaler counter.
Switching from one capture prescaler to another may
generate an interrupt. Doing that also will not clear the
prescaler counter – meaning the first capture may be
from a non-zero prescaler.
 shows the recommended method for
switching between capture prescalers. This example
also clears the prescaler counter and will not generate
the “false” interrupt.
EXAMPLE 18-1:
CHANGING BETWEEN 
CAPTURE PRESCALERS
CCPR5H
CCPR5L
TMR1H
TMR1L
Set CCP5IF
TMR5
Enable
Q1:Q4
CCP5CON<3:0>
CCP5 Pin
Prescaler
 1, 4, 16
and
Edge Detect
TMR1
Enable
C5TSEL0
C5TSEL0
CCPR4H
CCPR4L
TMR1H
TMR1L
Set CCP4IF
TMR3
Enable
CCP4CON<3:0>
CCP4 Pin
Prescaler
 1, 4, 16
TMR3H
TMR3L
TMR1
Enable
C4TSEL0
C4TSEL1
C4TSEL0
C4TSEL1
TMR5H
TMR5L
and
Edge Detect
4
4
4
Note:
This block diagram uses CCP4 and CCP5, and their appropriate timers, as an example. For details on all
of the CCP modules and their timer assignments, see 
 and 
CLRF
CCP4CON
; Turn CCP module off
MOVLW NEW_CAPT_PS
; Load WREG with the
; new prescaler mode
; value and CCP ON
MOVWF CCP4CON
; Load CCP4CON with
; this value