Hi,
First you need to set GP5 as an input. Then you set the function of the TMR1 module using the T1CON register. The value of the TMR1 module is can be read/written from/to using TMR1H and TMR1L register.
Here's a shot at it (untested):
Code:
TRISA.5 = 1 'Set GP5 to input.
Count Var Word
Temp var byte
'Set TMR1 to increment on rising edge of T1CKI pin, no prescaler, no sync to internal clock, TMR 1 is on.
T1CON = %00000111
Loop:
Count.highbyte = TMR1H 'Get high byte of counter
Count.Lowbyte = TMR1L 'Get low byte of counter
'Make sure that the counter did not roll over between reads of the high and low byte.
Temp var TMR1H 'Get highbyte again.
If Temp - Count.HighByte <> 0 then 'The two values differs so we read it again.
Count.HighByte = TMR1H
Count.LowByte = TMR1L
ENDIF
Serout ser,T9600,[#Count,13,10] 'Send count to computer.
Pause 100
Goto Loop
As I said - not tested but should be close to what you want.
(Edit)
Oh..I forgot...
You can stop counting by setting bit0 of T1CON to 0, start again by setting it to 1 and you can set the TMR1H and TMR1L register to what ever you want by writing to them just like any other variable.
/Henrik Olsson.
Bookmarks