PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
incap_switch_pulse_measure.c File Reference
#include "pic24_all.h"
#include <stdio.h>

Go to the source code of this file.

Functions

void CONFIG_SW1 ()
 Switch1 configuration.
 

Detailed Description

Measures the pulse width of pushbutton switching using input capture and Timer2 For more accuracy, use an external crystal and define CLOCK_CONFIG=PRIPLL_8MHzCrystal_40MHzFCY in the MPLAB project. Remove this macro if you wish to use the internal oscillator. Typical crystal accuracy for through hole is +/-20 pmm, so for a 100000 us pulse width measurement this is +/- 2 us.

This code works with PIC24E/dsPIC33 but a better way of measuring long capture periods with this family would be to use cascaded input captures to form a 32-bit input capture register.

Definition in file incap_switch_pulse_measure.c.