سلام بچه ها
من یه اشکال عجیب و غریب برام پیش اومده. وقفه خارجی درست کار نمیکنه. من یه برنامه واسه تست نوشتم ولی درست کار نمیکنه. :angry:
توی این برنامه من میخوام اگه برای بار اول وقفه اعمال بشه یه کار خاص انجام بده. اگه برای بار دوم وقفه اعمال بشه یه کار دیگه انجام بده و ....
برنامه رو واستون میزارم ببینید اشکالش کجاست؟
در ضمن برای اینکه جلوی نویز رو بگیرم یه دونه تاخیر هم گذاشتم
$regfile = "m32def.dat"
$crystal = 8000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db7 = Portb.7 , Db6 = Portb.6 , Db5 = Portb.5 , Db4 = Portb.4 , E = Portb.3 , Rs = Portb.1
Enable Interrupts
On Int0 Int0_isr
Config Portd = Input
Config Portc = Output
Portc = 0
Dim Test1 As Bit , Test2 As Bit
Cls
Lcd "Iran"
Dim A As Byte
Enable Int0
Here:
Idle
Goto Here
End 'end program
Int0_isr:
Test1 = Pind.2
Waitms 1
Test2 = Pind.2
If Test1 <> Test2 Then
Goto Exitroutin
End If
Cls
Incr A
Toggle Portc.0
Select Case A
Case 1:
Lcd "First is OK"
Case 2:
Lcd "second is OK"
Case 3:
Lcd "Third is OK"
Case 4:
Lcd "Forth is OK"
A = 0
End Select
Exitroutin:
Return
من یه اشکال عجیب و غریب برام پیش اومده. وقفه خارجی درست کار نمیکنه. من یه برنامه واسه تست نوشتم ولی درست کار نمیکنه. :angry:
توی این برنامه من میخوام اگه برای بار اول وقفه اعمال بشه یه کار خاص انجام بده. اگه برای بار دوم وقفه اعمال بشه یه کار دیگه انجام بده و ....
برنامه رو واستون میزارم ببینید اشکالش کجاست؟
در ضمن برای اینکه جلوی نویز رو بگیرم یه دونه تاخیر هم گذاشتم
$regfile = "m32def.dat"
$crystal = 8000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db7 = Portb.7 , Db6 = Portb.6 , Db5 = Portb.5 , Db4 = Portb.4 , E = Portb.3 , Rs = Portb.1
Enable Interrupts
On Int0 Int0_isr
Config Portd = Input
Config Portc = Output
Portc = 0
Dim Test1 As Bit , Test2 As Bit
Cls
Lcd "Iran"
Dim A As Byte
Enable Int0
Here:
Idle
Goto Here
End 'end program
Int0_isr:
Test1 = Pind.2
Waitms 1
Test2 = Pind.2
If Test1 <> Test2 Then
Goto Exitroutin
End If
Cls
Incr A
Toggle Portc.0
Select Case A
Case 1:
Lcd "First is OK"
Case 2:
Lcd "second is OK"
Case 3:
Lcd "Third is OK"
Case 4:
Lcd "Forth is OK"
A = 0
End Select
Exitroutin:
Return
دیدگاه