دوستان سلام
من این برنامه رو نوشتم ولی تایمر مشکل داره لطفا کمک کنین
$regfile "m8def.dat"
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Portc.5 , E = Portc.4 , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0
Config Pind.0 = Output
Config Pind.2 = Output
Config Pinb.4 = Input
Config Pind.5 = Input
Config Pind.6 = Input
Config Pind.7 = Input
Config Pinb.1 = Input
Config Pinb.2 = Input
Config Pinb.3 = Input
Config Pind.3 = Output
Config Pind.1 = Output
Config Debounce = 100
Config Timer1 = Timer , Prescale = 1024
Enable Interrupts
Enable Ovf1
Dim A As Word
Dim S As Byte
Dim Z As Word
Dim T As Byte
Dim Sh As Word
Dim Ti As Byte
Dim Ala As Byte
Dim X As Byte
Dim Lsb_a As Byte
Dim Lsb_b As Byte
Dim Lsb_c As Byte
Ddrd.5 = 0 : Portd.5 = 1
Ddrd.6 = 0 : Portd.6 = 1
Ddrd.7 = 0 : Portd.7 = 1
Ddrb.1 = 0 : Portb.1 = 1
Ddrb.2 = 0 : Portb.2 = 1
S = 0
Declare Sub Mas
Declare Sub Asg
Declare Sub Ssa
Readeeprom Ala , 10
Readeeprom Ti , 15
Readeeprom Sh , 20
Cls
Cursor Off
Home
Lcd " "
Home L
Lcd " "
Wait 2
Cls
Locate 1 , 4
Lcd "###TEST###"
Set Portd.0
Set Portd.1
Waitms 500
Reset Portd.0
Reset Portd.1
Wait 1
Main:
Cls
Locate 1 , 4 : Lcd "***MAIN***"
Do
Locate 2 , 7 : Lcd " " ; X
Locate 2 , 10 :
Debounce Pinb.1 , 0 , Mas , Sub
Debounce Pinb.2 , 0 , Asg , Sub
Debounce Pind.5 , 0 , Ssa , Sub
If Pind.3 = 0 Then
If Pinb.4 = 1 Then Goto Alarm
If Pinb.3 = 1 Then Goto Alarm
End If
If Pinb.1 = 0 Then Incr Sh
Writeeeprom Sh , 20
Waitms 5
If Portb.1 = 0 Then X = 0
If X => Ti Then Goto Alarm2
Enable Timer1
Timer1 = 57724
On Ovf1 Tim1
Loop
Sub Ssa
If Pind.5 = 0 Then Incr T
Waitms 50
If T > 3 Then T = 0
Waitms 100
If T = 1 Then
Waitms 100
Goto Prog1
End If
If T = 2 Then
Waitms 100
Goto Prog2
End If
If T = 3 Then
Waitms 100
Goto Setup3
End If
End Sub
Sub Mas
Cls
Locate 1 , 10
Lcd "PART2"
Locate 2 , 12
Lcd Z
Locate 1 , 1 : Lcd "PART"
Locate 2 , 2 : Lcd A
Incr A
Lsb_a = High(a)
Waitms 5
End Sub
Sub Asg
Cls
Locate 1 , 1 : Lcd "PART"
Locate 2 , 2 : Lcd A
Locate 1 , 10
Lcd "PART2"
Locate 2 , 12
Lcd Z
Incr Z
Lsb_b = High(z)
End Sub
Prog1:
Cls
Do
Home
Lcd "SETUP ALARM TIME"
Locate 2 , 8 : Lcd Ala
If Pind.6 = 0 Then Incr Ala
Waitms 50
If Pind.7 = 0 Then Decr Ala
Writeeeprom Ala , 10
Waitms 5
If Ala > 30 Then Ala = 0
If Pind.5 = 0 Then
Waitms 50
Goto Main
End If
Loop
Prog2:
Cls
Do
Home
Lcd "BLINK PART TIME"
Locate 2 , 7
Lcd Ti
If Pind.6 = 0 Then Incr Ti
Waitms 50
If Pind.7 = 0 Then Decr Ti
Waitms 50
Writeeeprom Ti , 15
Waitms 5
If Pind.5 = 0 Then
Waitms 50
Goto Main
End If
Loop
Setup3:
Cls
Do
Locate 1 , 6
Lcd "ALL PART"
Locate 2 , 7
Lcd Sh
If Pind.5 = 0 Then
Goto Main
End If
Loop
Alarm:
Set Portd.3
Do
Set Portd.0
Incr S
Wait 1
If S => Ala Then
Waitms 100
Reset Portd.0
Goto Main
End If
Loop
Alarm2:
Do
Set Portd.1
Incr S
Wait 1
If S => Ala Then
Wait 100
Reset Portd.1
Goto Main
End If
Loop
End
Tim1:
Incr X
Return
من این برنامه رو نوشتم ولی تایمر مشکل داره لطفا کمک کنین
$regfile "m8def.dat"
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Portc.5 , E = Portc.4 , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0
Config Pind.0 = Output
Config Pind.2 = Output
Config Pinb.4 = Input
Config Pind.5 = Input
Config Pind.6 = Input
Config Pind.7 = Input
Config Pinb.1 = Input
Config Pinb.2 = Input
Config Pinb.3 = Input
Config Pind.3 = Output
Config Pind.1 = Output
Config Debounce = 100
Config Timer1 = Timer , Prescale = 1024
Enable Interrupts
Enable Ovf1
Dim A As Word
Dim S As Byte
Dim Z As Word
Dim T As Byte
Dim Sh As Word
Dim Ti As Byte
Dim Ala As Byte
Dim X As Byte
Dim Lsb_a As Byte
Dim Lsb_b As Byte
Dim Lsb_c As Byte
Ddrd.5 = 0 : Portd.5 = 1
Ddrd.6 = 0 : Portd.6 = 1
Ddrd.7 = 0 : Portd.7 = 1
Ddrb.1 = 0 : Portb.1 = 1
Ddrb.2 = 0 : Portb.2 = 1
S = 0
Declare Sub Mas
Declare Sub Asg
Declare Sub Ssa
Readeeprom Ala , 10
Readeeprom Ti , 15
Readeeprom Sh , 20
Cls
Cursor Off
Home
Lcd " "
Home L
Lcd " "
Wait 2
Cls
Locate 1 , 4
Lcd "###TEST###"
Set Portd.0
Set Portd.1
Waitms 500
Reset Portd.0
Reset Portd.1
Wait 1
Main:
Cls
Locate 1 , 4 : Lcd "***MAIN***"
Do
Locate 2 , 7 : Lcd " " ; X
Locate 2 , 10 :
Debounce Pinb.1 , 0 , Mas , Sub
Debounce Pinb.2 , 0 , Asg , Sub
Debounce Pind.5 , 0 , Ssa , Sub
If Pind.3 = 0 Then
If Pinb.4 = 1 Then Goto Alarm
If Pinb.3 = 1 Then Goto Alarm
End If
If Pinb.1 = 0 Then Incr Sh
Writeeeprom Sh , 20
Waitms 5
If Portb.1 = 0 Then X = 0
If X => Ti Then Goto Alarm2
Enable Timer1
Timer1 = 57724
On Ovf1 Tim1
Loop
Sub Ssa
If Pind.5 = 0 Then Incr T
Waitms 50
If T > 3 Then T = 0
Waitms 100
If T = 1 Then
Waitms 100
Goto Prog1
End If
If T = 2 Then
Waitms 100
Goto Prog2
End If
If T = 3 Then
Waitms 100
Goto Setup3
End If
End Sub
Sub Mas
Cls
Locate 1 , 10
Lcd "PART2"
Locate 2 , 12
Lcd Z
Locate 1 , 1 : Lcd "PART"
Locate 2 , 2 : Lcd A
Incr A
Lsb_a = High(a)
Waitms 5
End Sub
Sub Asg
Cls
Locate 1 , 1 : Lcd "PART"
Locate 2 , 2 : Lcd A
Locate 1 , 10
Lcd "PART2"
Locate 2 , 12
Lcd Z
Incr Z
Lsb_b = High(z)
End Sub
Prog1:
Cls
Do
Home
Lcd "SETUP ALARM TIME"
Locate 2 , 8 : Lcd Ala
If Pind.6 = 0 Then Incr Ala
Waitms 50
If Pind.7 = 0 Then Decr Ala
Writeeeprom Ala , 10
Waitms 5
If Ala > 30 Then Ala = 0
If Pind.5 = 0 Then
Waitms 50
Goto Main
End If
Loop
Prog2:
Cls
Do
Home
Lcd "BLINK PART TIME"
Locate 2 , 7
Lcd Ti
If Pind.6 = 0 Then Incr Ti
Waitms 50
If Pind.7 = 0 Then Decr Ti
Waitms 50
Writeeeprom Ti , 15
Waitms 5
If Pind.5 = 0 Then
Waitms 50
Goto Main
End If
Loop
Setup3:
Cls
Do
Locate 1 , 6
Lcd "ALL PART"
Locate 2 , 7
Lcd Sh
If Pind.5 = 0 Then
Goto Main
End If
Loop
Alarm:
Set Portd.3
Do
Set Portd.0
Incr S
Wait 1
If S => Ala Then
Waitms 100
Reset Portd.0
Goto Main
End If
Loop
Alarm2:
Do
Set Portd.1
Incr S
Wait 1
If S => Ala Then
Wait 100
Reset Portd.1
Goto Main
End If
Loop
End
Tim1:
Incr X
Return
دیدگاه