beautypg.com

4 tachometer code example, 10 .4 tachometer code example -6, 4tachometercodeexample – Maxim Integrated MAX31782 User Manual

Page 94

background image

MaximIntegrated 10-6

MAX31782 User’s Guide

Revision 0; 8/11

10.4TachometerCodeExample

The following pseudocode shows how to set up tachometer 0 . This example does not generate any interrupts, but
instead the captured tachometer value can be periodically polled by software .
Tachometer setup:

TACHCN0_bit.TPS = 3;

//tachometer clock is sysclk / 64 or 62.5kHz

TACHCN0_bit.TRPS = 1;

//set for 2 pulses per revolution

TACHCN0_bit.TEXEN = 1;

//enable edge capture of TACH.0 pin

TACHCN0_bit.TACHE = 1;

//start the tachometer count

Reading the tachometer:

tach_counts = TACHR0;

//store the captured tachometer counts for the last

revolution in a variable