How about using 3 If-Then's insead of one with 3 OR's?
Ioannis
How about using 3 If-Then's insead of one with 3 OR's?
Ioannis
I spent all night trying to find the best way ... I think this is
And everywhere there is any = 0, I replaced the @ clrf, +1 replaced with @ incf.Code:If month=2 then If year//4<>0 then DMonth=29 else DMonth=28 endif else Dmonth=30+month.0 endif If day>Dmonth then @ CLRF _Day @ INCF _Month,F If month>12 then
The end result was the RTC which consumes about 2uA and code size about 500B.![]()
I think you have to change the <>0 to =0 when you test for the modulo 4.
A better solution to cover more years (you code will not cover year 2100) is to use mod 400, mod 100 and mod 4 to test for leap year (mod 100 is NOT leap year, while 400 and 4 ARE leap years).
Of course we may not live in year 2100, but just in case...
Now about the @ commands, just be sure you are on page 0. Else you have to check the page bits. Or put this subroutine on top of your code.
Ioannis
Last edited by Ioannis; - 30th May 2011 at 11:13.
Thanks for that... It was just typo... 0-99 year is fine for this aplication.
On the top of ISR I have BSR=0, and isr routine is on top of my programm.
If I may suggest, make the minutes and hours update in your main loop and not in Interrupt. A temp variable wll be needed for this.
Ioannis
If pic loses power, it goes to sleep. And everything is shut off, only tmr1 is on. So i need that in ISR. Is there better way?
Bookmarks