PDA

View Full Version : Example code for capture series of pulses, using internal timers?



CuriousOne
- 9th March 2013, 05:39
Hello.

Does anyone has some code?

Just want to have look, how it should be done properly.

HenrikOlsson
- 9th March 2013, 07:10
Most hardware timers can be setup as counters with external clock input.
Here's a snippet using TMR1 on a 16F88. (Not verified to work but should do so....)

TRISB.6 = 1 ' T1CKI is on RB6, make sure it's an input
T1CON = %00000111 ' Enable TMR1 as a counter, 1:1 prescale, no sync.

Main:
LCDOUT $FE, 1, "Pulsecount: ", DEC TMR1H*256 + TMR1L
Pause 250
Goto Main

/Henrik.