Not that I can't think out of the box, but I've asked around and tried whatever is possible, to display counting in LCD, not to display in LCD, to display only the final value, etc, but i still can't manage to get the timer to display in 1ms timing interval. I know that the PIC can continue counting by itself, but, even I try to make it display only the final value, but it still can't display the accurate readings.
Sorry for asking questions that might consider too easy for some others, but I am totally new in this. I need the timer to measure the human response time.
MY CODE:
'MAIN PROGRAM
'------------
ResetTimer:
GoSub SetReg
LCDOUT $FE, 1
Timer1H = 0
Timer1L = 0
MicroThousandths = 0
Thousandths = 0
Hundredths =0
Seconds = 0
Main:
LCDOUT $FE, $80, "Test Mode 1"
'LCDOUT $FE, $C0, "Visual Response Test"
If ButStart = 1 Then goto StartTimer
Goto Main
StartTimer:
LCDOUT $Fe, 1
LCDOUT $FE, $80, "Calculating..."
T1CON.0=1
Looping:
While PIR1.0=0
Wend
PIR1.0=0
Thousandths=Thousandths+1
If Thousandths>9 Then
Thousandths=0
Hundredths=Hundredths+1
If Hundredths>99 Then
Hundredths=0
Seconds=Seconds+1
Endif
Endif
If ButStop = 1 Then goto StopTimer
Goto Looping
StopTimer:
T1CON.0 = 0
LCDOUT $Fe, 1
GoSub GetValue
DisplayResult:
LCDOUT $FE, $80, "Time Elapsed"
LCDOUT $FE,$C0, dec2 Seconds, ".", dec2 Hundredths, ":", dec Thousandths
If ButStart = 1 Then goto StartTimer
If ButReset = 1 Then goto ResetTimer
goto DisplayResult
'SUBROUTINES
'===========
'Get value from Timer1 Register
'------------------------------
GetValue:
Timer1H=TMR1H
Timer1L=TMR1L
Return
'Reset Timer1 Register to Start from 1ms interval
'-----------------------------------------
SetReg:
TMR1H = $FC
TMR1L = $18
Return
Now, what is wrong with my codes? Correct me please.
Bookmarks