Alapok, kiolvasás
Kód: Egész kijelölése
Const clkaddr=&HA2
Dim .... (variables)
Print "{027}[2JTime status:"
Do
I2cstart 'generate start
I2cwbyte Clkaddr 'write addres of PCF8583
I2cwbyte 2 'select second register
I2cstart 'generate repeated start
L_temp1b = Clkaddr + 1
I2cwbyte L_temp1b 'write address for reading info
I2crbyte Clk_s , Ack '&h02 read seconds (00...59)
If Clk_s.7 = 1 Then
Csipog1 'Csak teszt!
Goto Ujraolvas 'nem megbizhato az adat (VL reg)
End If
Clk_s.7 = 0
I2crbyte Clk_m , Ack '&h03 read minutes (00...59)
Clk_m.7 = 0 '7. bit torlese
I2crbyte Clk_h , Ack '&h04 read hours (00...23)
Clk_h.7 = 0
Clk_h.6 = 0
I2crbyte Clk_d , Ack '&h05 read days (01....31)
Clk_d.7 = 0
Clk_d.6 = 0
I2crbyte L_temp1b , Ack '&H06 weekday (nem haszn.) het napjai (0...6)
I2crbyte Clk_wm , Ack '&h07 month/centaury (7.bit: cent. 1-20xx, 0-19xx)
Clk_cent = Clk_wm.7
Clk_wm.7 = 0
Clk_wm.6 = 0
Clk_wm.5 = 0
I2crbyte Clk_y , Nack '&h08 Year
I2cstop 'generate stop
Print "{027}[2;1f"; ' VT100 emulation set pos to 2,2
Print Bcd(clk_h) ; ":" ; Bcd(clk_m) ; ":" ; Bcd(clk_s)
Print "" ; Bcd(clk_d) ; "." ; Bcd(clk_wm) ; "." ;
If Clk_cent = 1 Then
Print "20";
Else
Print "19";
End If
Print Bcd(clk_y) ; "."
Print "Err:" ; Err
Waitms 50
Ujraolvas:
Loop Until Inkey() = 27