Menu
JAQForum Ver 19.10.27

Forum Index : Microcontroller and PC projects : RP2350-Touch-LCD-2.8

   Page 2 of 2    
Posted: 09:38pm
23 Oct 2025
Copy link to clipboard
phil99
Guru


  Quote  It seems to be a problem with the RTC-chip implemented to the board (that mmBasic officially does not support)
The issue may not only be writing the year to the RTC but also reading it back with RTC GETTIME if it is using different registers to the regular RTCs.

I guess there are a number of ways forward.
1) As the months and days appear ok the easiest and crudest method is to substitute the correct year at bootup with something like:-
Sub MM.STARTUP
  RTC GETTIME
  Date$ = Left$(Date$,6) + "2025"
End Sub
  Quote  The command OPTION RTC AUTO ENABLE can also be used to set an automatic update of the TIME$ and DATE$ read only variables from the real time clock chip on boot and every hour.
So to avoid the year being overwritten don't use OPTION RTC AUTO ENABLE.

2) The Waveshare example programs presumably manage to set the PCF85063A RTC correctly so see if you can convert that section to MMBasic Subs for writing and reading the chip.

3) From the PCF85063A datasheet create your own RTC Subs.

4) If enough people use this chip perhaps it can be added to the firmware.

Edit.
Haven't got a PCF85063A but have been having a play with a DS3231 to see if there is a simple way to set and read the year.
This might work for the PCF85063A
RTC SetReg &H0A, &H25 'first nibble is BCD decade, second is BCD year

Sub MM.STARTUP
  Local year%
  RTC GETTIME
  RTC GetReg &H0A, year% 'read the year register
  year% = (year%>>4)*10 + (year% and 7) 'convert BCD nibbles to decimal
  Date$ = Left$(Date$,8) + Str$(year%) 'add the year to the date.
End Sub


The DS3231 test. change the register address from &h06 to &h0A to try on the PCF85063A
> Dim year%, newYear%
> newYear%=&h42 : RTC SetReg &H06, newYear% 'set year to 2042
> RTC GetReg &H06, year% : year% = (year%>>4)*10 + (year% and 7) : date$ = Left$(Date$,8) + Str$(year%)
> ? date$
24-10-2042
>

Edited 2025-10-24 12:55 by phil99

Footnote added 2025-10-26 17:46 by phil99
Red Face Time!
Did not test long enough, replace BCD to decimal converter with this.
year% = (year%>>4)*10 + (year% and 15) 'convert BCD nibbles to decimal
 
Posted: 06:57am
24 Oct 2025
Copy link to clipboard
Mixtel90
Guru


It wouldn't be so bad if there was a good reason to use that particular RTC chip other than cost. :(  It's not as if you can rely on its accuracy. Setting the year seems to be a bit superfluous on a chip that will need to be corrected monthly (if you're lucky).
 
   Page 2 of 2    


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025