can anyone help with the following code as its not working
i'm trying to set the output to 100 if the timer is less than 5000 and 001 if its above....
Code:
device = 16F876a 'PIC device
CMCON = 7 'disable comparators
TRISB = %11111111 'Portb as inputs
TRISA = %00000000 'Porta as outputs
porta = %00000000 'Set all outputs low
T1CON.0=0 'stop the timer
TMR1H = 0 'Set the high part of the timer value to 0
TMR1L = 0 'Set the low part of the timer value to 0
T1CON.0=1 'start the timer
MyCount VAR WORD
Start:
MyCount.HighByte = TMR0H 'Get high byte of counter
MyCount.LowByte = TMR0L 'Get low byte of counter
IF MyCount > 5000 THEN 'if the timer value > than your number
porta = %00000001
gosub timer_reset
else
porta = %00000100
endif
Goto Start
timer_reset:
T1CON.0=0 'stop the timer
TMR1H = 0 'Set the high part of the timer value to 0
TMR1L = 0 'Set the low part of the timer value to 0
T1CON.0=1 'start the timer
return
Bookmarks