English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (366/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
EXAMPLE 15-1: INPUT CAPTURE EXAMPLE CODE
/*
The following code segment initialized the timer and setup the input capture
module.
*/
...
//Initialize timer 2
T2CON = 0x0
// Stop and Init Timer
TMR2 = 0x0;
// Clear timer register
PR2 = 0x7000;
// Load period register
T2CONSET = 0x8000;// Start Timer
// Init IC1 module
IC1CON = 0x8081;//Enable Module, use timer 2,
//Capture mode 1 (capture every edge)
...
//Read the capture data if available
int cap_data;
while( IC1CONbits.ICBNE ) // while data available in capture FIFO
{
cap_data = IC1BUF;
... //process data
}
...
DS61143E-page 364
Preliminary
© 2008 Microchip Technology Inc.