It's suppoased to be a loop every 10ms.
Not an insult every 10 ms.
It's like a "Pack of Wolves".
And wasssup didn't start anything.
Y'all need to mellow out, and write some code.
Here's mine...
Code:
ReadingTaken VAR BIT
TRM0IF VAR INTCON.2
TMR0IE VAR INTCON.5
TimerReload CON 60
OPTION_REG = %11010111 ; Assign Prescaler to TMR0, 1:256, internal clock
TMR0 = TimerReload ; Load timer for first delay
TMR0IF = 0 ; Clear the interrupt flag
ReadingTaken = 0 ; indicate reading hasn't been taken yet
TMR0IE = 1 ; Enable TMR0 interrupt
ON INTERRUPT GOTO TakeReading
Main:
If ReadingTaken then ; Wait for reading to be taken
ReadingTaken = 0 ; Indicate the reading has been handled
; -- Reading has been taken, do something with it here --
endif
GOTO Main
DISABLE
TakeReading:
TMR0 = TimerReload ; reload timer for next period
TMR0IF = 0 ; Clear the interrupt flag
; -- this is called every ~10.036ms -- (with 20mhz OSC)
; Take your reading
ReadingTaken = 1 ; Tell main loop that a reading has been taken
RESUME
ENABLE
HTH,
Bookmarks