On Sun, Jul 18, 2010 at 4:55 AM, Rob Hamerling <[email protected]>wrote:
> > Hi Vasile, > > > I don't have a library in jallib acception, however routines below works >> OK for me. >> > > If you don't mind I have some comments. > > > > const bit RTC_enabled = 1 >> const bit RTC_disabled = 0 >> >> procedure RTC_writing (bit in value) is >> RTCCFG_RTCWREN = value -- 1 enabled, 0 disabled >> EECON2 = 0x55 -- \ required sequence >> EECON2 = 0xAA -- / >> RTCCFG_RTCWREN = 1 ; allow writting to RTCCFG >> end procedure >> > > I think this procedure doesn't work as you think/hope. > It works OK, my RTCC is in test since about a month, however you may change it as you wish to, or as Kyle said. > > 1. > Kyle recommended to use > 'asm bank RTCCFG' > in stead of your > RTCCFG_RTCWREN = value > to prepare for accessing RTCCFG after EECON2 > > 2. > Your statement sets the bank for RTCCFG properly, but the result of the > procedure is always RTCWREN = '1' (the last statement), regardless if called > with 'value' 0 or 1. > > > > > procedure read_time () is >> -- read hour >> RTCCFG_RTCPTR1 = 0 >> RTCCFG_RTCPTR0 = 1 >> if RTCCFG_RTCSYNC == 0 then >> hour = RTCVALL >> end if >> ;H2 = (hour & 0b0000_1111) + 0x30 >> ;H1 = ((hour >> 4) & 0b0000_1111) + 0x30 >> -- read minute >> RTCCFG_RTCPTR1 = 0 >> RTCCFG_RTCPTR0 = 0 >> if RTCCFG_RTCSYNC == 0 then >> minute = RTCVALH >> end if >> ;M2 = (minute & 0b0000_1111) + 0x30 >> ;M1 = ((minute >> 4) & 0b0000_1111) + 0x30 >> -- read seconds >> RTCCFG_RTCPTR1 = 0 >> RTCCFG_RTCPTR0 = 0 >> if RTCCFG_RTCSYNC == 0 then >> second = RTCVALL >> end if >> ;S2 = (second & 0b0000_1111) + 0x30 >> ;S1 = ((second >> 4) & 0b0000_1111) + 0x30 >> end procedure >> > > 3. You simply skip reading a RTCVALL/H register when RTCSYNC is '1'. > That might give strange results! > > 4. > You don't make use of the automatic decrementation of the RTCPTR<1,0> bits > (not required but is shorter). > > Except for item 3 my comments may not prevent your application from working > properly. And even 3. might not harm when you read often enough. So it is > more a matter of 'clean' programming. > > Thanks again for publishing your source! > I have my RTC library working pretty well. I need to do some cleanup and > test the alarm-related parts before making it available in Jallib. When > somebody urgently needs the time and date functions I might publish the > library without alarm functions and save that for a later release. > > > Regards, Rob. > > -- > Rob Hamerling, Vianen, NL (http://www.robh.nl/) > > -- > You received this message because you are subscribed to the Google Groups > "jallib" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<jallib%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/jallib?hl=en. > > -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
