A large delay can be created by nesting several loops, like such:
start:
for hours = 0 to 23
for minutes = 0 to 59
for seconds = 0 to 59
pause 1000
next seconds
next minutes
next hours
-your code here-
goto start
This will work, and be reliable, but it run a little slow. (I paused exactly a second, but didn't take into account the loop overhead)
Other delay loops exist, many with better accuracy than you can get with this one. Any delay loop is subject to the accuracy of the oscilator for the PIC, as such you'll never get exactly 24.00000 hours delay. It'll run fast or slow and your event will migrate around the clock as time goes by.
But I'm guessing that you actualy want the event to hapen at a set time each day. For that you need an RTC (real time clock). There are many options available. (check out the ones from Maxim, www.maxim-ic.com) Or if you have AC mains available you can set the PIC up to count the sine waves (they have excelent long-term timing accuracy, most plug-in clocks use this method).
-Denny




Bookmarks