Is it possible to use a for loop to create a timer in software? It does not need to be very accurate. I cannot use timer0, timer1 or timer2 for I am already using them for user interface. See below of an example of what I am trying to achieve. It works but why will it not work correctly?
rx:
for i = 0 to 60000
timer = timer + i
pause 1
next i
if (timer == 60000)then
trigger = trigger + 1
timer = 0
endif
if (trigger == 1)then
trigger = 0
goto a2d
else
goto rx
endif
I am using a PIC16F876A @ 20Mhz. I know the instruction cycle is around 200ns and the pause is for 1ms. It takes 1000ms to equal 1sec thus 60000.
Thanks in advance,
Scott
Bookmarks