Documente Academic
Documente Profesional
Documente Cultură
dat"
'"8535def.dat"
$crystal = 8000000
Dim Detik As Byte
'Atur As Bit
'Atur As Bit
Dim M As Byte
Dim J As Byte
Config Porta = Output , Portd = Output , Portc = Output
Config Portb = Input
Portb = 255
'Portd = 255
Const Conter = 22336
'periode 1 detik
Tccr1a = 0
Set Tccr1b.3
Seting:
Detik = 0
Menit = 0
Jam = 0
Do
If Pinb.0 = 0 Then
Waitms 400
Menit = Menit + 1
End If
If Menit >= 60 Then
Menit = 0
End If
If Pinb.1 = 0 Then
Waitms 400
Jam = Jam + 1
End If
If Jam >= 24 Then
Jam = 0
End If
If Pinb.2 = 0 Then
Waitms 400
Exit Do
End If
Gosub Tampil
Loop
On Compare1a Pencacah
Enable Compare1a
Enable Interrupts
Do
If Cacah >= 1 Then
Cacah = 0
End If
If Detik >= 60 Then
Detik = 0
'Waitms 100
Menit = Menit + 1
End If
If Menit >= 60 Then
Menit = 0
Jam = Jam + 1
End If
If Jam >= 24 Then
Jam = 0
End If
If Pinb.2 = 0 Then
Waitms 400
'Waitms 100
Exit Do
End If
Gosub Tampil
Loop
Goto Seting
End
Tampil:
Porta.0 = Cacah
J = Makebcd(jam)
M = Makebcd(menit)
D = Makebcd(detik)
Reset Portd.0
Reset Portd.1
Portc = D
'Makebcd(detik)
Waitms 6
'00
Portd.0 = 1
Portd.1 = 1
Reset Portc
Reset Portd.2
Reset Portd.3
Portc = M
'Makebcd(menit)
Waitms 6
'00
Portd.2 = 1
Portd.3 = 1
Reset Portc
Reset Portd.4
Reset Portd.5
Portc = J
Waitms 6
Portd.4 = 1
Portd.5 = 1
Reset Portc
Waitms 6
Return
Pencacah:
Incr Detik
Incr Cacah
Return
'Makebcd(jam)
'00