Quote Originally Posted by crazyhellos View Post
Hi everyone,
I also cant figure out is how to include the yearcounting. The years are in 4 so
ready for every leapyear. How must I set this rigister.

Ps everything is on a 16F628A and a 4x20 lcd.

Here's my coding (dutch)
I think this is not PicBasicPro code. However, the date and year are combined into 1 byte, the month is another byte. Remember, the format is BCD. This is a small fragment of my code that handles the date.
Code:
' read the RTC date in BCD format
RTC_GetDate:
    I2Cread   SDA, SCL, $A2, DayYear, [gr[0]]
    Date[0] = gr[0] & $3f
    Date[2] = gr[0] >> 6
    I2Cread   SDA, SCL, $A2, Month, [Date[1]]
    
    ' if the RTC year has advanced, advance the baseyear too
    I2Cread   SDA, SCL, $A2, LastYear, [gr[0]]
    if Date[2] <> gr[0] then
      I2Cwrite  SDA,SCL, $A2, LastYear, [Date[2]]     ' record the current rTC year
      
      I2Cread   SDA, SCL, $A2, BaseYear, [gr[0]]
      gr[0] = gr[0] + 1     ' advance the baseyear
      I2Cwrite  SDA,SCL, $A2, BaseYear, [gr[0]]
    endif
    
    ' add the baseyear to the Current RTC year
    I2Cread   SDA, SCL, $A2, BaseYear, [gr[0]]
    Date[2] = Date[2] + gr[0]
    return

' Set date in BCD format
RTC_SetDate:
    ' Store the lastyear
    gr[0] = Date[2] & 3     ' the RTC year
    I2Cwrite  SDA,SCL, $A2, LastYear, [gr[0]]
    gr[0] = (gr[0] << 6)+(Date[0] & $3f)
    I2Cwrite  SDA, SCL, $A2, DayYear, [gr[0],Date[1]]
    
    ' store the baseyear
    gr[0] = Date[2] & $fc   ' the lowest 2 bits are in the RTC year
    I2Cwrite  SDA,SCL, $A2, BaseYear, [gr[0]]
    return
Jerson