Professional Documents
Culture Documents
MCU - PIC24FV32KA304 - MICROCHIP - Section 15. Input Capture - 39701a PDF
MCU - PIC24FV32KA304 - MICROCHIP - Section 15. Input Capture - 39701a PDF
Input Capture
HIGHLIGHTS
This section of the manual contains the following major topics:
15
Capture
Input
15.1 INTRODUCTION
This section describes the input capture module and its associated operational modes. The input
capture module is used to capture a timer value from one of two selectable time bases upon an
event on an input pin. The input capture features are quite useful in applications requiring
frequency (Time Period) and pulse measurement. Figure 15-1 depicts a simplified block diagram
of the input capture module.
Refer to the specific device data sheet for further information on the number of channels
available in a particular device. All input capture channels are functionally identical. In this
section, an ‘x’ in the pin name or register name is a generic reference to an input capture channel
in place of a specific input capture channel number.
The input capture module has multiple operating modes which are selected via the ICxCON
register. The operating modes include:
• Capture timer value on every falling edge of input applied at the ICx pin
• Capture timer value on every rising edge of input applied at the ICx pin
• Capture timer value on every 4th rising edge of input applied at the ICx pin
• Capture timer value on every 16th rising edge of input applied at the ICx pin
• Capture timer value on every rising and every falling edge of input applied at the ICx pin
• Device wake-up from capture pin during CPU Sleep and Idle modes
The input capture module has a four-level FIFO buffer. The number of capture events required
to generate a CPU interrupt can be selected by the user.
16 16
ICTMR
1 0
(ICxCON<7>)
Prescaler Edge Detection Logic FIFO
Counter and R/W
(1, 4, 16) Clock Synchronizer Logic
ICx pin
3 ICM<2:0> (ICxCON<2:0>)
FIFO
Mode Select
ICOV, ICBNE (ICxCON<4:3>)
ICxBUF
ICI<1:0>
Interrupt
ICxCON Logic
System Bus
Set Flag ICxIF
(in IFSx Register)
Note: An ‘x’ in a signal, register or bit name denotes the number of the capture channel.
001 = Capture mode, every edge – rising and falling (the ICI<1:0> bits do not control interrupt
Input
Note 1: Timer selections may vary. Refer to the device data sheet for details.
15.3 INITIALIZATION
When the input capture module is reset or in the Off mode (ICM<2:0> = 000), the input capture
logic should:
• Reset the overflow condition flag to a logic ‘0’
• Reset the receive capture FIFO to the empty state
• Reset the prescale count
Figure 15-2: Simple Capture Event Timing Diagram, Time Base Prescaler = 1:1
TCY
ICxIF Set
ICx pin
Note 1
Note 1: A capture signal edge that occurs in this region will result in a capture buffer entry value of 1 or 2 timer counts from the capture
signal edge.
Figure 15-3: Simple Capture Event Timing Diagram, Time Base Prescaler = 1:4
ICx pin
Capture Data n
15
Capture
Input
// The following code shows how to read the capture buffer when
// an interrupt is generated.
TMRy n–3 n–2 n–1 n n+1 n+2 n+3 n+4 n+5 n+6
ICx pin
15
Capture
Input
15
Capture
Input
15
Capture
Input
DS39701A-page 15-12
ICxCON — — ICSIDL — — — — — ICTMR ICI1 ICI0 ICOV ICBNE ICM2 ICM1 ICM0 0000
Legend: x = unknown value on Reset, — = unimplemented, read as ‘0’. Reset values are shown in hexadecimal.
Advance Information
Resets
IFS0 — — AD1IF U1TXIF U1RXIF SPI1IF SPF1IF T3IF T2IF OC2IF IC2IF — T1IF OC1IF IC1IF INT0IF 0000
IFS2 — — PMPIF — — — OC5IF — IC5IF IC4IF IC3IF — — — SPI2IF SPF2IF 0000
IEC0 — — AD1IE U1TXIE U1RXIE SPI1IE SPF1IE T3IE T2IE OC2IE IC2IE — T1IE OC1IE IC1IE INT0IE 0000
IEC2 — — PMPIE — — — OC5IE — IC5IE IC4IE IC3IE — — — SPI2IE SPF2IE 0000
IPC0 — T1IP2 T1IP1 T1IP0 — OC1IP2 OC1IP1 OC1IP0 — IC1IP2 IC1IP1 IC1IP0 — INT0IP2 INT0IP1 INT0IP0 4444
IPC1 — T2IP2 T2IP1 T2IP0 — OC2IP2 OC2IP1 OC2IP0 — IC2IP2 IC2IP1 IC2IP0 — — — — 4440
IPC9 — IC5IP2 IC5IP1 IC5IP0 — IC4IP2 IC4IP1 IC4IP0 — IC3IP2 IC3IP1 IC3IP0 — — — — 4440
Legend: — = unimplemented, read as ‘0’. Reset values are shown in hexadecimal.
ICx pin
(Input Capture Mode)
IC10 IC11
IC15
15
Capture
Input
Question 1: Can the input capture module be used to wake the device from Sleep
mode?
Answer: Yes. When the input capture module is configured to ICM<2:0> = 111 and the respective
channel interrupt enable bit is asserted (ICxIE = 1), a rising edge on the capture pin will wake-up
the device from Sleep (see Section 15.8 “Input Capture Operation in Power-Saving States”).
Note: Please visit the Microchip web site (www.microchip.com) for additional application
notes and code examples for the PIC24F family of devices.
15
Capture
Input