Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:57 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Saving Data to RTC

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 12:53am 01 Feb 2019
Copy link to clipboard 
Print this post

I started a new thread for this.

So I have played around with Grogsters code and came up with..

SUB SAVETORTC
Local X 'A local X variable, perhaps totally seperate from a global X
For X=1 to 3 'Step through the three-byte date data, and save it to the RTC RAM
RTC SETREG 50+X, MID$(R$,X,1) 'Put data into RTC register R$ is numeric
Next
END SUB


SUB READRTC
R_Save$=""
Local X,BYTE
For X=1 to 3
RTC GETREG 50+X,BYTE
R_Save$=R_Save$+CHR$(BYTE) ' use "Rain_Saved = Val(R_Save$)" to get value
Next
END SUB


it runs without error but does not work, whether it is not writing or not reading I don't know or maybe both.


"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 12:55am 01 Feb 2019
Copy link to clipboard 
Print this post

Think I found a mistake....
OOPS WRONG THINKING THERE
cancel that.
Edited by palcal 2019-02-02
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 02:43am 01 Feb 2019
Copy link to clipboard 
Print this post

I don't have a RTC with ram but you are trying to save a character when it should be a number

I have converted your SUBs to FUNCTIONs and added ASC(MID$(R$,X,1))

  Quote   rain$ = "456"
x = SAVETORTC(rain$)

oldrain$ = READRTC$()
PRINT oldrain$

FUNCTION SAVETORTC(R$)
LOCAL X 'A local X variable, perhaps totally seperate from a global X
FOR X=1 TO 3 'Step through the three-byte date data, and save it to the RTC RAM
RTC SETREG 50+X, ASC(MID$(R$,X,1)) 'Put data into RTC register R$ is numeric
NEXT
END FUNCTION


FUNCTION READRTC$()
LOCAL X,B, R$
FOR X=1 TO 3
RTC GETREG 50+X,B
R$=R$+
CHR$(B) ' use "Rain_Saved = Val(R_Save$)" to get value
NEXT
READRTC$ = R$
END FUNCTION


I have used RETREG and GETREG to configure clock options without any issues.

Jim
VK7JH
MMedit
 
Print this page


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