سلام.
من این برنامه رو واست نوشتم.
سورس و شبیه ساز رو واست پیوست کردم.
کد:
$regfile = "m32def.dat" : $crystal = 8000000
Config Portc = Output : Config Portb = Output
Config Timer1 = Timer , Prescale = 64
Segment Alias Portb
Defbyte S2 , S3 , S4 , S5 , S6 , S7 , S8
Dim K As Byte
Enable Timer1
On Timer1 Tim
Main:
Do
Debounce Pind.2 , 1 , Zooj , Sub
Debounce Pind.3 , 1 , Fard , Sub
Portc = &H01
Segment = Lookup(s1 , Segmentdata)
Waitus 100
Portc = &H02
Segment = Lookup(s2 , Segmentdata)
Waitus 100
Portc = &H04
Segment = Lookup(s3 , Segmentdata)
Waitus 100
Loop
End
Segmentdata:
Data &H3F , &H06 , &H5B , &H4F , &H66 , &H6D , &H7D , &H07 , &H7F , &H6F
Zooj:
K = 1 : S1 = 0 : S2 = 0 : S3 = 0 : Enable Interrupts
jmp main
Fard:
K = 2 : S1 = 0 :S2 = 0 :S3 = 0 : Enable Interrupts
jmp main
Tim:
If K = 1 Then : S1 = S1 + 2
If S1 > 9 Then : S1 = 0 : Incr S2 : End If
If S2 > 9 Then : S1 = 0 : S2 = 0 : Incr S3 : End If
If S3 = 1 Then : S1 = 0 : S2 = 0 : S3 = 1 : K = 0 : Disable Interrupts : End If
End If
If K = 2 Then
If S1 > 1 Then : S1 = S1 + 1 : S1 = S1 / 2 : End If
Incr S1 : S1 = S1 * 2 : S1 = S1 - 1
If S1 > 9 Then : S1 = 1 : Incr S2 : End If
If S2 > 9 Then : S1 = 9 : S2 = 9 : Disable Interrupts : K = 0 : End If
End If
Return
موفق باشی...