$regfile = "m16def.dat"
$crystal = 8000000
$lib "mcsbyte.lbx" ' for smaller code
$lib "ds1307clock.lib" ' modified lib
$framesize = 16
$hwstack = 24
$swstack = 16
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 Pinb.4 = Input
Config Portd = Output
Config Portc = Output
Config Pina.7 = Input
Config Pina.6 = Input
Config Porta.5 = Output
Config Pina.4 = Input
Config Porta.3 = Output
Config Porta.2 = Output
Config Porta.1 = Output
Config Porta.0 = 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$ = "2359" ' 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
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 , Q As Byte
Dim Ml As Byte
Dim Hh As Byte
Dim Hl As Byte , S1 As Byte , L As Byte , Delaye As Byte , Secovf As Byte
Ok Alias Pina.4
Up Alias Pina.7
Down Alias Pinb.4
Delaye = 3
'*************************************** start *****************************************
' 13 november 2002
Hom:
Gosub Getdatetime
Mh = _min / 10
Ml = _min Mod 10
Hh = _hour / 10
Hl = _hour Mod 10
R = _sec
Portb = Hh
Porta = 8
Waitms 3
Portb = Hl
Porta = 4
Waitms 3
Portb = Mh
Porta = 2
Waitms 3
Portb = Ml
Porta = 1
Waitms 3
If Q = 1 Then Goto S1
If Q = 0 Then Goto S
'***************************************** * sec ********************************************
S:
Q = 1
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)
Incr Secovf
Gosub Getdatetime
If Secovf = 60 Then
Secovf = 0
Goto Hom
End If
Next M
Next R
'**************************************** sec b **********************************************
S1:
Q = 0
Index = &B00000001
For R = 0 To 7
Portc = 0
Portd = &HFF
Portc = Index
Rotate Index , Left
For M = 0 To 7
Portd = Lookup(m , H)
Incr Secovf
Gosub Getdatetime
If Secovf = 60 Then
Secovf = 0
Goto Hom
End If
Next M
Next R
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
سلام دوستان میتونین در مورد این برنامه راهنمایی کنین و تجربیات ارزشمندتونو در اختیار بنده حقیر قرار بدین راستش
قراره که ساعتو نشون بده بعد 60تاled رو به ترتیب روشن کنه بعد دوباره بره دقیقه و ساعتو که بعد از هر دقیقه تغییر میکنه ( البته فقط دقیقه )نشون بده بعد به ترتیب اونled هارو خاموش کنه و دوباره دقیقه و ساعت و الی اخر ایا درسته این برنامه تو پروتئوس انگار درست جواب نمیده برنامه مشکلی داره :cry: نمی فهمم دوباره که قراره دقیقه رو ساعت رو نشون بده نشون نمیده و میره سراغ 60تا led یعنی فقط اول بار نشون میده ولی دیگه فقط میره سراغ 60led و اونارو خاموش روشن میکنه و دقیقه و ساعتو تغییر نمیده oo: :angry: :angry: :angry: مشکل کجاست ممنون میشم راهنمایی کنین
$crystal = 8000000
$lib "mcsbyte.lbx" ' for smaller code
$lib "ds1307clock.lib" ' modified lib
$framesize = 16
$hwstack = 24
$swstack = 16
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 Pinb.4 = Input
Config Portd = Output
Config Portc = Output
Config Pina.7 = Input
Config Pina.6 = Input
Config Porta.5 = Output
Config Pina.4 = Input
Config Porta.3 = Output
Config Porta.2 = Output
Config Porta.1 = Output
Config Porta.0 = 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$ = "2359" ' 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
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 , Q As Byte
Dim Ml As Byte
Dim Hh As Byte
Dim Hl As Byte , S1 As Byte , L As Byte , Delaye As Byte , Secovf As Byte
Ok Alias Pina.4
Up Alias Pina.7
Down Alias Pinb.4
Delaye = 3
'*************************************** start *****************************************
' 13 november 2002
Hom:
Gosub Getdatetime
Mh = _min / 10
Ml = _min Mod 10
Hh = _hour / 10
Hl = _hour Mod 10
R = _sec
Portb = Hh
Porta = 8
Waitms 3
Portb = Hl
Porta = 4
Waitms 3
Portb = Mh
Porta = 2
Waitms 3
Portb = Ml
Porta = 1
Waitms 3
If Q = 1 Then Goto S1
If Q = 0 Then Goto S
'***************************************** * sec ********************************************
S:
Q = 1
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)
Incr Secovf
Gosub Getdatetime
If Secovf = 60 Then
Secovf = 0
Goto Hom
End If
Next M
Next R
'**************************************** sec b **********************************************
S1:
Q = 0
Index = &B00000001
For R = 0 To 7
Portc = 0
Portd = &HFF
Portc = Index
Rotate Index , Left
For M = 0 To 7
Portd = Lookup(m , H)
Incr Secovf
Gosub Getdatetime
If Secovf = 60 Then
Secovf = 0
Goto Hom
End If
Next M
Next R
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
سلام دوستان میتونین در مورد این برنامه راهنمایی کنین و تجربیات ارزشمندتونو در اختیار بنده حقیر قرار بدین راستش
قراره که ساعتو نشون بده بعد 60تاled رو به ترتیب روشن کنه بعد دوباره بره دقیقه و ساعتو که بعد از هر دقیقه تغییر میکنه ( البته فقط دقیقه )نشون بده بعد به ترتیب اونled هارو خاموش کنه و دوباره دقیقه و ساعت و الی اخر ایا درسته این برنامه تو پروتئوس انگار درست جواب نمیده برنامه مشکلی داره :cry: نمی فهمم دوباره که قراره دقیقه رو ساعت رو نشون بده نشون نمیده و میره سراغ 60تا led یعنی فقط اول بار نشون میده ولی دیگه فقط میره سراغ 60led و اونارو خاموش روشن میکنه و دقیقه و ساعتو تغییر نمیده oo: :angry: :angry: :angry: مشکل کجاست ممنون میشم راهنمایی کنین
دیدگاه