YES!!!
The test loop adds execution time, which causes your time before check to be longer.
There are prolly some differences in how you can use timer 1 and timer 2, but if they are set up as counters triggered by fosc/4, they will count the same.
You have a few choices in how to deal with getting accurate times. the first and always pointed at is to use interrupts. The second is to auto adjust the count while the program is running. to do this, once the timer is greater then target number, subtract target number from the CURRENT timer value. when you reload the timer, reload it with your reload value + the difference just calculated. Mind you, that is for a counter counting up. If using PR (as with timer 2) you can just load timer 2 with the difference. then it will count from adjusted number to PR value, instead of from zero to PR.
Did any of that make sense? Both methods are valid and useful depending on application. (Thanks PBP members for the auto correct idea)





Bookmarks