Use Timer1 something like this;
Code:
DEFINE OSC 20
DEFINE LOADER_USED 1
Symbol T1IF = PIR1.0 ' Timer1 TMR1IF overflow flag bit
SYMBOL TMR1ON = T1CON.0 ' Timer1 ON/OFF control bit
T1CON = 0 ' Prescaler = 1:1, Timer off
Cycles Var Word ' Holds Timer1 counts
Main:
TMR1H = 0
TMR1L = 0
T1IF = 0 ' Clear timer1 int flag
T1CON = 1 ' Start timer
' --- Insert PBP commands or groups to time below
' --- MAX time @ 20MHz = 65,536 x 200nS = 13.1072mS
' --- MAX time @ 4MHz = 65,536 * 1uS = 65.536mS
' --- with 1:1 prescale on TMR1.
serout2 0,16416,["ABC",13,10] ' Send 5 bytes at 19,200 bps
' ----------------------------------------
T1CON = 0 ' Stop Timer1
Cycles.lowbyte = TMR1L ' Get low byte
Cycles.highbyte = TMR1H ' Get high byte
' Display Time result
Hserout ["Timer1 Ticks = ",Dec Cycles,13,10]
IF T1IF THEN
HSEROUT ["TMR1 Over-flow, add 65,536 cycles to result",13,10]
T1IF = 0
ENDIF
PAUSE 1000
Here:
Goto Here ' Sit & spin after measurements
Bookmarks