here is a Basic program to set the time and date. It's not comfortable yet, but it works. You have to modify lines 80-140 to the actual time.
Code: Select all
10 RTC=$3dfc00 : rem RTC72421 base address
20 S1=0:S10=1*2:MI1=2*2:MI10=3*2:H1=4*2:H10=5*2:D1=6*2:D10=7*2:MO1=8*2:MO10=9*2
30 Y1=10*2:Y10=11*2:W=12*2:CD=13*2:CE=14*2:CF=15*2
40 poke RTC+CF,4 : rem 24h format
50 poke RTC+CD,4 : rem no interrupts
60 gosub 500
80 poke RTC+Y10,1:poke RTC+Y1,4 : rem 20(14)
90 poke RTC+MO10,0:poke RTC+MO1,7 : rem 07 (July)
100 poke RTC+D10,1:poke RTC+D1,5 : rem 15
110 poke RTC+H10,2:poke RTC+H1,0 : rem 20h (20:01:00)
120 poke RTC+MI10,0:poke RTC+MI1,1 : rem 01m
130 poke RTC+S10,0:poke RTC+S1,0 : rem 00s
140 poke RTC+W,2 : rem 02 (Tuesday)
150 poke RTC+CD,4 : rem no interrupts
160 print "Date/Time set"
500 poke RTC+CD,5 : HOLD Bit = 1
510 if (peek(RTC+CD) and 2) <> 0 then poke RTC+CD,4:goto 500
520 return
Attached is a program which prints the current RTC values. EmuTOS already uses the RTC too.
If you are going to read from the RTC keep in mind that only databus lines D0-D3 are connected to the RTC. D4-D7 can have any value and are not valid.
Thus AND the values coming from the RTC with 0xf.
Simon