Here's a list of examples...
http://www.picbasic.co.uk/forum/show...2&postcount=18
_
> Accuracy is not very important so long as its approximatly 1sec.
Darrel - You forgot to list the obvious...
PAUSE 1000
thanks for the replies
i cant use pause as i have other processes that need to be run..
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
OK, i see you have disabled the analog comparator, but not the ADCs
ADCON1=7
And... seems to miss some TIMER setting, like clock source, prescaller, Prescaller assignment.
AND, maybe i'm wrong but TIMER0 on this one is a 8 bit counter....
and have a closer look to those
maybe it's a copy/paste mistake tooCode:MyCount.HighByte = TMR0H 'Get high byte of counter MyCount.LowByte = TMR0L 'Get low byte of counter![]()
Last edited by mister_e; - 29th April 2007 at 16:16.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Thanks for the help
It seems I’m barking up the wrong tree then as I don't want to use an external clock source, and i can’t interrupt the program or pause it.
Is it possible simply to increment a variable every execution cycle?
i.e.
tick var byte
tick_flag var byte
start:
If tick > 99 then
Tick = 0
tick_flag = 1
Else
tick = tick + 1
End if
Goto start ‘ loop
But how can I approximate this to a time scale I can use. The datasheet state the execution cycle time as 1uS , forgive my ignorance but does that mean the above code will increment every 1uS ?
Bookmarks