کسی میدونه مشکل این برنامه کجاست ؟ من میخوام تعداد فشرده شدنه کلید رو اندازه بگیرم و تو متغیر A بریزم و رو ال سی دی نمایش بدم. با وقفه که نمونه برنامه این هست جواب میده راحت.
$regfile = "m32def.dat".dat "
$Crystal = 8000000
'---------------------------
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Portc.2 , E = Portc.3 , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Config Portb = Input
Config Porta = Output
'--------------------------
Dim A As Byte
Dim B As Byte
Dim X As Byte
Dim C As Byte
Do
Cursor Off
Locate 1 , 1
Lcd A
X = Pinb
'-------------------------------------
If X = &B00000001 Then Goto Cunt1
'-------------------------------------
Loop
End
Cunt1:
Incr A
Cls
LOCATE 1,1
LCD A
RETURN
درواقع مشکل اینه که مقدار A از درونه لیبل برنمیگرده و تو حلقه D0 قرار بگیره
نمونه برنامه با وفقه هم اینه.سوال اینجاست که چرا از درونه لیبل برنامه وقفه مقدار برمیگرده اما توی برنامه بالا بر نمیگرده.
$regfile = "m32def.dat"
$crystal = 8000000
'------------------------
Config Porta = Output
Config Portd = Input
Set Portd.2
Config Int0 = Falling
Porta.1 = 0
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Porta.0 , E = Porta.2 , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7
'-------------------------
Enable Interrupts
Enable Int0
On Int0 Lable
'-------------------------
Dim A As Byte
Dim B As Byte
'-------------------------
Initlcd
Cursor Off
Cls
Lcd "Interrupt test"
Wait 1
Cls
Do
Locate 2 , 1
Set Porta.3
Waitms 100
Reset Porta.3
Waitms 100
Loop
End
;----------------------------------
Lable:
Cls
Incr A
If A > 255 Then A = 0
Lcd A
Return
$regfile = "m32def.dat".dat "
$Crystal = 8000000
'---------------------------
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Portc.2 , E = Portc.3 , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Config Portb = Input
Config Porta = Output
'--------------------------
Dim A As Byte
Dim B As Byte
Dim X As Byte
Dim C As Byte
Do
Cursor Off
Locate 1 , 1
Lcd A
X = Pinb
'-------------------------------------
If X = &B00000001 Then Goto Cunt1
'-------------------------------------
Loop
End
Cunt1:
Incr A
Cls
LOCATE 1,1
LCD A
RETURN
درواقع مشکل اینه که مقدار A از درونه لیبل برنمیگرده و تو حلقه D0 قرار بگیره
نمونه برنامه با وفقه هم اینه.سوال اینجاست که چرا از درونه لیبل برنامه وقفه مقدار برمیگرده اما توی برنامه بالا بر نمیگرده.
$regfile = "m32def.dat"
$crystal = 8000000
'------------------------
Config Porta = Output
Config Portd = Input
Set Portd.2
Config Int0 = Falling
Porta.1 = 0
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Porta.0 , E = Porta.2 , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7
'-------------------------
Enable Interrupts
Enable Int0
On Int0 Lable
'-------------------------
Dim A As Byte
Dim B As Byte
'-------------------------
Initlcd
Cursor Off
Cls
Lcd "Interrupt test"
Wait 1
Cls
Do
Locate 2 , 1
Set Porta.3
Waitms 100
Reset Porta.3
Waitms 100
Loop
End
;----------------------------------
Lable:
Cls
Incr A
If A > 255 Then A = 0
Lcd A
Return
دیدگاه