Thank you for the answers.
I can't put the whole code here because it's more than 4000 rows but I can here to give part of the i2c code that reads the time from pfc8563T.
[code:1:728d746361]
...
Dim S As Byte At &H160 Overlay
Dim M As Byte At &H161 Overlay
Dim H As Byte At &H162 Overlay
Dim D As Byte At &H163 Overlay
Dim W As Byte At &H164 Overlay
Dim Mesic As Byte At &H165 Overlay
Dim Year As Byte At &H166 Overlay
Dim Cent As Integer
Dim Cas As Word
Dim Den_dekod As Byte
Dim Hodina_dekod As Byte
Dim Minuta_dekod As Byte
Dim Tm(7) As Byte At &H160
Dim Den As String * 7
Dim I As Byte
Declare Sub Gettime()
...
Sub Gettime()
Tm(1) = 2 'point to second register
I2creceive &HA3 , Tm(1) , 1 , 7 'write the second address and get 7 bytes back
End Sub
...
Call Gettime
'Config Portb.7 = Output
W = W And &H7
If W = 0 Then Den = "Nedele "
If W = 1 Then Den = "Pondeli"
If W = 2 Then Den = "Utery "
If W = 3 Then Den = "Streda "
If W = 4 Then Den = "Ctvrtek"
If W = 5 Then Den = "Patek "
If W = 6 Then Den = "Sobota "
H = H And &H3F
M = M And &H7F
S = S And &H7F
Cent = Mesic And &H80
If Cent = 0 Then
Cent = 1900
Else
Cent = 2000
End If
Mesic = Mesic And &H1F
Cent = Cent + Makedec(year)
D = D And &H3F
...
[/code:1:728d746361]
When I call command gettime wrote config portb. 7 = output so the backlight will turn off after a while and during moments light up again. everything else is working on. When I disable substitution gettime so backlight works, but I do not have rtc :(
↧