Code:
StartTimer:
LCDOUT $Fe, 1
LCDOUT $FE, $80, "Calculating..."
T1CON.0=1
Start the timer before doing anything with the LCD. The LCD commands take time. It'll skew the result quite a bit.
Code:
GetValue:
Timer1H=TMR1H
Timer1L=TMR1L
When stopping the timer, you'll also have to account for the extra cycles taken during the GOSUBs and other code to get there...if you want a really accurate result.
And T1 is going to overflow every 65.536us, slightly more than 15 times per second.
If you press the button at 70,000us, you'll get a result of 4,464, not the result you want.
How you plan on accounting for the rollover?
Bookmarks