قراره که 60تا led در ابتدا روشن بعد به ترتیب خاموش بشن البته فایل اصلیمو نداشتم اینو دوباره نوشتم احتمالا بازم مشکل داره راستش مشکل اینه که تو پروتئوس میبندم ولی دفعه اول که اعدادو نشون میده و میره سراغ led ها دفعه بعد که پرش میکنه و باید مقدار جدید اعدادو نشون بده این کارو نمیکگنه باید چیکار کرد
$regfile = "m16def.dat"
$crystal = 8000000
$lib "mcsbyte.lbx" ' for smaller code
$lib "ds1307clock.lib" ' modified lib
$framesize = 16
$hwstack = 24
$swstack = 16
Config Pina.0 = Input
Config Pina.1 = Input
Config Pina.2 = Input
Config Portb.0 = Output
Config Portb.1 = Output
Config Portb.2 = Output
Config Portb.3 = Output
Config Portb.6 = Output
Config Portb.7 = Output
Config Portd = Output
Config Portc = Output
Config Porta.7 = Output
Config Porta.6 = Output
Config Porta.5 = Output
Config Porta.4 = Output
Config Porta.0 = Output
Config Porta.1 = Output
Config Sda = Portb.6
Config Scl = Portb.7
Const Ds1307w = &HD0 ' Addresses of Ds1307 clock
Const Ds1307r = &HD1
Enable Interrupts
Config Clock = User ' this will dim the bytes automatic
Dim Weekday As Byte
'Time$ = "23
59" ' to watch the day changing value
'Date$ = "11-13-02"
Dim S As Byte , M As Byte , H As Byte , Ma As Word , Mlb As Byte , Sc As Byte
Dim A As Byte , B As Byte , Mha As Word , Mla As Word , Lm As Word
Dim Mh As Byte , Index As Byte , R As Byte , Jump As Byte , Jump1 As Byte
Dim Ml As Byte
Dim Hh As Byte
Dim Hl As Byte , S1 As Byte , L As Byte , Delaye As Byte
Ok Alias Pina.4
Up Alias Pina.5
Down Alias Pina.6
Delaye = 3
'*************************************** start *****************************************
Jump1 = 1
Hom:
Gosub Getdatetime
Mh = _min / 10
Ml = _min Mod 10
Hh = _hour / 10
Hl = _hour Mod 10
Porta = 8
Portb = Hh
Waitms Delaye
Porta = 4
Portb = Hl
Waitms Delaye
Porta = 2
Portb = Mh
Waitms Delaye
Porta = 1
Portb = Ml
Waitms Delaye
If Jump = 1 Then Goto Sc2
If Jump1 = 1 Then Goto Sc
'***************************************** * sec ********************************************
Sc:
Do
Index = &B00000001
For R = 0 To 7
Portc = 0
Portd = 0
Portc = Index
Rotate Index , Left
For M = 0 To 7
Portd = Lookup(m , A)
Gosub Getdatetime
Incr Sc
If Sc = 60 Then
Sc = 0
Set Jump
Goto Hom
End If
Next M
Next R
'**************************************** sec b **********************************************
Sc2:
Jump = 0
Index = &B00000001
For R = 0 To 7
Portc = Index
Rotate Index , Left
For M = 0 To 7
Portd = Lookup(m , H)
Gosub Getdatetime
Incr Sc
If Sc = 60 Then
Goto Hom
End If
Next M
Next R
If Ok = 0 Then
Waitms 150
Goto Settime
End If
Loop
End
'called from ds1307clock.lib
Getdatetime:
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' start address in 1307
I2cstart ' Generate start code
I2cwbyte Ds1307r ' send address
I2crbyte _sec , Ack
I2crbyte _min , Ack ' MINUTES
I2crbyte _hour , Ack ' Hours
I2crbyte Weekday , Ack ' Day of Week
I2crbyte _day , Ack ' Day of Month
I2crbyte _month , Ack ' Month of Year
I2crbyte _year , Nack ' Year
I2cstop
_sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
Return
$regfile = "m16def.dat"
$crystal = 8000000
$lib "mcsbyte.lbx" ' for smaller code
$lib "ds1307clock.lib" ' modified lib
$framesize = 16
$hwstack = 24
$swstack = 16
Config Pina.0 = Input
Config Pina.1 = Input
Config Pina.2 = Input
Config Portb.0 = Output
Config Portb.1 = Output
Config Portb.2 = Output
Config Portb.3 = Output
Config Portb.6 = Output
Config Portb.7 = Output
Config Portd = Output
Config Portc = Output
Config Porta.7 = Output
Config Porta.6 = Output
Config Porta.5 = Output
Config Porta.4 = Output
Config Porta.0 = Output
Config Porta.1 = Output
Config Sda = Portb.6
Config Scl = Portb.7
Const Ds1307w = &HD0 ' Addresses of Ds1307 clock
Const Ds1307r = &HD1
Enable Interrupts
Config Clock = User ' this will dim the bytes automatic
Dim Weekday As Byte
'Time$ = "23

'Date$ = "11-13-02"
Dim S As Byte , M As Byte , H As Byte , Ma As Word , Mlb As Byte , Sc As Byte
Dim A As Byte , B As Byte , Mha As Word , Mla As Word , Lm As Word
Dim Mh As Byte , Index As Byte , R As Byte , Jump As Byte , Jump1 As Byte
Dim Ml As Byte
Dim Hh As Byte
Dim Hl As Byte , S1 As Byte , L As Byte , Delaye As Byte
Ok Alias Pina.4
Up Alias Pina.5
Down Alias Pina.6
Delaye = 3
'*************************************** start *****************************************
Jump1 = 1
Hom:
Gosub Getdatetime
Mh = _min / 10
Ml = _min Mod 10
Hh = _hour / 10
Hl = _hour Mod 10
Porta = 8
Portb = Hh
Waitms Delaye
Porta = 4
Portb = Hl
Waitms Delaye
Porta = 2
Portb = Mh
Waitms Delaye
Porta = 1
Portb = Ml
Waitms Delaye
If Jump = 1 Then Goto Sc2
If Jump1 = 1 Then Goto Sc
'***************************************** * sec ********************************************
Sc:
Do
Index = &B00000001
For R = 0 To 7
Portc = 0
Portd = 0
Portc = Index
Rotate Index , Left
For M = 0 To 7
Portd = Lookup(m , A)
Gosub Getdatetime
Incr Sc
If Sc = 60 Then
Sc = 0
Set Jump
Goto Hom
End If
Next M
Next R
'**************************************** sec b **********************************************
Sc2:
Jump = 0
Index = &B00000001
For R = 0 To 7
Portc = Index
Rotate Index , Left
For M = 0 To 7
Portd = Lookup(m , H)
Gosub Getdatetime
Incr Sc
If Sc = 60 Then
Goto Hom
End If
Next M
Next R
If Ok = 0 Then
Waitms 150
Goto Settime
End If
Loop
End
'called from ds1307clock.lib
Getdatetime:
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' start address in 1307
I2cstart ' Generate start code
I2cwbyte Ds1307r ' send address
I2crbyte _sec , Ack
I2crbyte _min , Ack ' MINUTES
I2crbyte _hour , Ack ' Hours
I2crbyte Weekday , Ack ' Day of Week
I2crbyte _day , Ack ' Day of Month
I2crbyte _month , Ack ' Month of Year
I2crbyte _year , Nack ' Year
I2cstop
_sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour)
Return
دیدگاه