سلام به همه دوستان
یکی از دوستانم برنامه ای به زبان شیرین بیسیک نوشته که در این برنامه داده ای توسط پین b2 میکر(atmega32) دریافت می شود این داده توسط میکروی دیگری ارسال می شود وتوسط این میکرو از طریق پین b2 دریافت می شود.
از آنجا که من به زبان بیسیک تسلط ندارم و می خواهم این برنامه را برای زبان c بنویسم ولی هرچه این برنامه را بالا وپایین کردم چیزی سر در نیاوردم.
دوستان خوشحال می شوم نظر شان را در ارتباط با برنامه زیر جهت دریافت داده توسط پینB.2 توضیح دهند
یکی از دوستانم برنامه ای به زبان شیرین بیسیک نوشته که در این برنامه داده ای توسط پین b2 میکر(atmega32) دریافت می شود این داده توسط میکروی دیگری ارسال می شود وتوسط این میکرو از طریق پین b2 دریافت می شود.
از آنجا که من به زبان بیسیک تسلط ندارم و می خواهم این برنامه را برای زبان c بنویسم ولی هرچه این برنامه را بالا وپایین کردم چیزی سر در نیاوردم.
دوستان خوشحال می شوم نظر شان را در ارتباط با برنامه زیر جهت دریافت داده توسط پینB.2 توضیح دهند
$regfile = "m32def.dat" : $crystal = 16000000
Open "comb.2:9600,8,n,1,inverted" For Input As #1
Open "coma.0:4800,8,n,1,inverted" For Output As #2
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
Config Lcd = 16 * 2
Config Watchdog = 4096 'reconfig to 4 sec
Config Scl = Portb.0
Config Sda = Portb.1
Config Kbd = Portd
Config Portc.6 = Output
Config Porta = Output
Config Portc.7 = Output
Data_in Alias Pinc.7
Dim Key As Byte , Key1 As Byte , Key2 As Byte , Bitk As Bit , Rkey(4) As Word , Pass_cheng As Eram Word , M4 As Eram Word , Bit_meno As Bit , Pass_cheng_b As Bit
Dim T As Word , Npx As Word , Np(3) As Word , Vau As Byte , Var1 As Byte , M1 As Word , M2 As Word , M3 As Word , Op As Word , Op1 As Word , Op2 As Word
Dim Rf(19) As Byte , C As String * 2 , B As Word , Bitpass As Bit , Bitw As Bit , Bit_tag_new As Bit , B1 As Word , B2 As Word , B3 As Byte , ' Bit_next As Bit
Dim Bit1 As Bit , Xu As Byte , B_meno As Bit , B_write_eeprom As Bit , B_ers As Bit , M5 As Word , B_ring As Bit
Dim Adres As Word , Value As Byte , Unit As Byte , O1 As Byte , O2 As String * 3
Const Addressw = 160 : Const Addressr = 161
Dim Pi As Word
Declare Sub Read_eeprom(byval Adres As Word , Value As Byte)
Declare Sub Write_rom(byval Adres As Word , Byval Value As Byte)
Declare Sub Keys(key As Byte )
Declare Sub Clsrkey
Declare Sub Run
Declare Sub Ring
Declare Sub Meno
Declare Sub Tag
Declare Sub Serchtag
Declare Sub Write_eeprom
Declare Sub Key_u
Declare Sub Erase_unit
Op = M4 : Waitms 50
If M4 = 350 Then : M3 = Pass_cheng : Waitms 50 : Else : M3 = 888 : End If
Cursor Off Noblink
Cls
Rl_door Alias Portc.6
B_write_eeprom = 0 : Bitpass = 0 : B_ers = 0 : B_meno = 0 : Xu = 0
T = 200
Pi = 0
Do
Waitms 1
T = T + 1
Call Keys(key)
If T > 200 Then
If T = 201 Then : Cls : Locate 2 , 1 : Lcd "TABAN ELCTRONIC" : End If
T = 201 : Bit1 = 1 : Xu = 0 : Clsrkey
Pi = Pi + 1 : If Pi = 1000 Then Start Watchdog
Call Tag
If Bit_tag_new = 1 Then Call Serchtag
Xu = 0
Else
Call Tag
Call Run
If Bit_tag_new = 1 Then Serchtag
If B_meno = 1 Then Meno
If B_write_eeprom = 1 Then Write_eeprom
If B_ers = 1 Then Erase_unit
End If
Loop
'-------------------------------------------------------
Sub Keys(key As Byte )
Key1 = Getkbd()
If Key2 = Key1 Then : Bitk = 0 : Else : Bitk = 1 : End If
If Key1 = 16 Then Bitk = 0
Key2 = Key1 : If Key1 < 12 Then : T = 0
Key = Lookup(key1 , Datakey)
Else : Key = 16 : End If
Return
End Sub
'--------------------------------------------------------------
Sub Clsrkey
Rkey(1) = 0 : Rkey(2) = 0 : Rkey(3) = 0 : Rkey(4) = 0
End Sub
'-----------------------------------------------------------------
Sub Run
If Bitk = 1 Then : If B_ring = 1 Then : Locate 1 , 1 : Lcd " " : B_ring = 0 : End If : If Key < 10 Then : If Xu = 0 Then : Locate 1 , 1 : Lcd " " : End If : Xu = Xu + 1 : Bitk = 0
If Xu = 1 Then Rkey(1) = Key
If Xu = 2 Then Rkey(2) = Key
If Xu = 3 Then Rkey(3) = Key
If Xu > 3 Then : Xu = 0 : Locate 1 , 1 : Lcd " " : Clsrkey : End If
Locate 1 , Xu : Lcd Rkey(xu)
End If
If Key = 10 Then : Locate 1 , 1 : Lcd " " : Clsrkey : Xu = 0
M1 = 0
Do
Call Keys(key) : M1 = M1 + 1 : Waitms 10 : If M1 = 150 Then : B_meno = 1 : T = 200 : Cls : End If
Loop Until Key <> 10
M1 = 0 : T = 200 : Return : End If
If Rkey(1) <> 0 Then : If Key = 11 Then : Xu = Xu -1 : Ring : End If : End If :
Bitk = 0 : Waitms 5 : End If
Return
End Sub
'--------------------------------------------------------------------------
Sub Meno
Pass_cheng_b = 0
L1:
Cls
Locate 1 , 1 : Lcd "INSERT PASSWORD "
Locate 2 , 1 : Lcd " [0**] "
Do
Call Keys(key) : Waitms 50
Loop Until Key = 16
Xu = 6 : Clsrkey : Bitk = 0
Do
Key_u
If Bitk = 1 Then : Bitk = 0
If M1 <> 0 Then : If Key = 11 Then
If Pass_cheng_b = 1 Then
M5 = M1
Cls
Locate 1 , 1 : Lcd " RE-PASSWORD "
Locate 2 , 1 : Lcd " [0**] "
Do
Call Keys(key) : Waitms 50
Loop Until Key = 16
Xu = 6 : Clsrkey : Bitk = 0
Do
Key_u
If Bitk = 1 Then : Bitk = 0
If M1 <> 0 Then : If Key = 11 Then
If M1 = M5 Then : Pass_cheng = M1 : Waitms 50 : M4 = 350 : Waitms 50 : Locate 2 , 1 : Lcd "PASS CHENG" : Wait 2 : Pass_cheng_b = 0 : M3 = M1 : Start Watchdog
Else
Cls
Locate 1 , 1 : Lcd " REJECT CHENG "
Locate 2 , 1 : Lcd " " : Wait 3
Start Watchdog
End If : End If : End If : End If
Loop
End If
If M1 = M3 Then
Locate 2 , 1 : Lcd "ACCEPTED " : Wait 2 : Cls : Locate 1 , 1 : Lcd "1>CHENG PASSWORD " : Locate 2 , 1 : Lcd "2>CARD OPTIONS"
Do
Call Keys(key)
If Bitk = 1 Then
If Key = 1 Then : Pass_cheng_b = 1 : Goto L1 : End If
If Key = 2 Then Goto Tr
If Key = 10 Then Start Watchdog
End If
Loop
Tr:
Cls : Locate 1 , 1 : Lcd "1>ADD CARD " : Locate 2 , 1 : Lcd "2>ERASE CARD"
Do
Call Keys(key) : Waitms 50
Loop Until Key = 16
Do
Call Keys(key)
If Bitk = 1 Then
If Key = 1 Then : B_write_eeprom = 1 : T = 200 : B_meno = 0 : Return : End If
If Key = 2 Then : B_ers = 1 : T = 200 : B_meno = 0 : Return : End If
If Key = 10 Then Start Watchdog
End If
Loop
Else
Locate 2 , 1 : Lcd "ACCESS DENIED" : Wait 2 : Goto L1
End If
End If : End If
If Key = 10 Then Start Watchdog
End If
Loop
B_meno = 0
End Sub
'---------------------------------------------------------------------------
Sub Ring
Var1 = Xu : Bit_tag_new = 0
If Var1 = 2 Then : Op = Rkey(1) * 100 : Op1 = Rkey(2) * 10 : Op2 = Op + Op1 : Op2 = Op2 + Rkey(3) : End If
If Var1 = 1 Then : Op = Rkey(1) * 10 : Op2 = Op + Rkey(2) : End If
If Var1 = 0 Then : Op2 = Rkey(1) : End If
Locate 1 , 1 : Lcd "RING to Unit:" : Lcd Op2 : T = 0 : Op2 = 0 : B_ring = 1 : Xu = 0
Portc.7 = 1
Var1 = Var1 + 1
For Vau = 1 To Var1
Wait 1
Select Case Rkey(vau)
Case 0 : Porta = 235
Case 1 : Porta = 123
Case 2 : Porta = 125
Case 3 : Porta = 126
Case 4 : Porta = 187
Case 5 : Porta = 189
Case 6 : Porta = 190
Case 7 : Porta = 219
Case 8 : Porta = 221
Case 9 : Porta = 222
End Select
Waitms 500 : Porta = 238 : Waitms 500
Next
Porta = 237 : Waitms 500 : Porta = 255 : Portc.7 = 0
P1:
Clsrkey
End Sub
'-------------------------------------------------------------------------------
Sub Serchtag()
If Bit_tag_new = 1 Then
T = 200
Bit_tag_new = 0 : B1 = 2 : B = 1 : B3 = 1
Ch1:
Call Read_eeprom(b1 , Value)
If Value = Rf(b3) Then : B3 = B3 + 1 : B1 = B + B3
If B3 = 11 Then : Locate 1 , 1 : Lcd "UNIT:" : Call Read_eeprom(b , Value) : Locate 1 , 6 : Lcd Value : Lcd " "
Rl_door = 1 : Wait 1 : Rl_door = 0 : Goto Ch2 : End If
Goto Ch1
Else
If B = 5501 Then Goto Ch2 : B = B + 11 : B3 = 1 : B1 = B + B3 : Goto Ch1 : End If
Ch2:
End If : Return
End Sub
'-------------------------------------------------------------------------------
Sub Tag
If Bitw = 1 Then Bitpass = 1
Serch:
Inputbin #1 , C
If C = "st" Then : Bitpass = 0 : Bit_tag_new = 1 : Locate 1 , 13 : Lcd "CARD" : For B3 = 1 To 11 : Rf(b3) = Waitkey(#1) : Next : End If
' Cls : Lcd Chr(rf(1)) ; : Lcd Chr(rf(2)) ; : Lcd Chr(rf(3)) ; : Lcd Chr(rf(4)) ; : Lcd Chr(rf(5)) ; : Lcd Chr(rf(6)) ; : Lcd Chr(rf(7)) ; : Lcd Chr(rf(8)) ; : Lcd Chr(rf(9)) ; : Lcd Chr(rf(10)) ; : Lcd Chr(rf(11)) ;
If Bitpass = 1 Then : Call Keys(key) : If Key = 10 Then Start Watchdog : Goto Serch : End If
Return
End Sub
'-------------------------------------------------------------------------------
Sub Write_eeprom
B_write_eeprom = 0 : B_meno = 0
Cls
B = 1 : Locate 2 , 1 : Lcd "UNIT :"
Do
Waitms 1
Call Keys(key)
Loop Until Key = 16
Xu = 6
Do
Key_u : If M1 <> 0 Then : If Key = 10 Then Start Watchdog : End If
Loop Until Key = 11
F1:
Call Read_eeprom(b , Value)
If Value = 250 Then
Else : B = B + 11 : If B = 5501 Then Lcd "FULL MEMORY " : Goto F1 : End If
Locate 1 , 1 : Lcd "INSERT CART" : Bitw = 1 : Tag : Locate 1 , 1 : Lcd "PLEASE WAIT" : Bitw = 0 : B3 = M1 : Call Write_rom(b , B3)
For B3 = 1 To 10 : B1 = B + B3 : Call Write_rom(b1 , Rf(b3)) : Next : Bit_tag_new = 0 : Return
End Sub
'------------------------------------------------------------------------------
Sub Key_u
Call Keys(key)
If Bitk = 1 Then : If Key < 10 Then : Xu = Xu + 1
If Xu = 7 Then Rkey(1) = Key
If Xu = 8 Then Rkey(2) = Key
If Xu = 9 Then Rkey(3) = Key
If Xu = 10 Then : Xu = 6 : Clsrkey
Else
Locate 2 , Xu : M1 = Xu - 6 : Lcd Rkey(m1) : End If : Waitms 400
If B_meno = 1 Then : Locate 2 , 7 : Lcd "***" : End If
M1 = Rkey(1) * 100 : M2 = Rkey(2) * 10 : M1 = M1 + M2 : M1 = M1 + Rkey(3)
End If : End If
End Sub
'-------------------------------------------------------------------------------
Sub Erase_unit
Cls
Locate 2 , 1 : Lcd "UNIT : "
B3 = 0 : B_ers = 0 : Clsrkey
Do
Waitms 1
Call Keys(key)
Loop Until Key = 16
Xu = 6
Do
Key_u : If M1 <> 0 Then : If Key = 10 Then Start Watchdog : End If
Loop Until Key = 11
B = 1 : B2 = 1
Do
Call Read_eeprom(b , Value)
If Value = M1 Then
For B1 = 0 To 10 : B2 = B + B1 : Call Write_rom(b2 , 250) : Next
B3 = B3 + 1 : B = B + 11
Else
B = B + 11 : End If
Loop Until B > 5512
T = 200 : B_meno = 0 : Cls : Return
End Sub
'-------------------------------------------------------------------------------
'____________________________________________ ___________________________________
'&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;
Sub Write_rom(byval Adres As Word , Value As Byte)
I2cstart
I2cwbyte Addressw
I2cwbyte Adres
I2cwbyte Value
I2cstop
Waitms 10
End Sub
'____________________________________________ ___________________________________
'&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;
Sub Read_eeprom(byval Adres As Word , Value As Byte)
I2cstart
I2cwbyte Addressw
I2cwbyte Adres
I2cstart
I2cwbyte Addressr
I2crbyte Value , Nack
I2cstop
End Sub
'-------------------------------------------------------------------------------
Datakey:
Data 10 , 7 , 4 , 1 , 0 , 8 , 5 , 2 , 11 , 9 , 6 , 3
Open "comb.2:9600,8,n,1,inverted" For Input As #1
Open "coma.0:4800,8,n,1,inverted" For Output As #2
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
Config Lcd = 16 * 2
Config Watchdog = 4096 'reconfig to 4 sec
Config Scl = Portb.0
Config Sda = Portb.1
Config Kbd = Portd
Config Portc.6 = Output
Config Porta = Output
Config Portc.7 = Output
Data_in Alias Pinc.7
Dim Key As Byte , Key1 As Byte , Key2 As Byte , Bitk As Bit , Rkey(4) As Word , Pass_cheng As Eram Word , M4 As Eram Word , Bit_meno As Bit , Pass_cheng_b As Bit
Dim T As Word , Npx As Word , Np(3) As Word , Vau As Byte , Var1 As Byte , M1 As Word , M2 As Word , M3 As Word , Op As Word , Op1 As Word , Op2 As Word
Dim Rf(19) As Byte , C As String * 2 , B As Word , Bitpass As Bit , Bitw As Bit , Bit_tag_new As Bit , B1 As Word , B2 As Word , B3 As Byte , ' Bit_next As Bit
Dim Bit1 As Bit , Xu As Byte , B_meno As Bit , B_write_eeprom As Bit , B_ers As Bit , M5 As Word , B_ring As Bit
Dim Adres As Word , Value As Byte , Unit As Byte , O1 As Byte , O2 As String * 3
Const Addressw = 160 : Const Addressr = 161
Dim Pi As Word
Declare Sub Read_eeprom(byval Adres As Word , Value As Byte)
Declare Sub Write_rom(byval Adres As Word , Byval Value As Byte)
Declare Sub Keys(key As Byte )
Declare Sub Clsrkey
Declare Sub Run
Declare Sub Ring
Declare Sub Meno
Declare Sub Tag
Declare Sub Serchtag
Declare Sub Write_eeprom
Declare Sub Key_u
Declare Sub Erase_unit
Op = M4 : Waitms 50
If M4 = 350 Then : M3 = Pass_cheng : Waitms 50 : Else : M3 = 888 : End If
Cursor Off Noblink
Cls
Rl_door Alias Portc.6
B_write_eeprom = 0 : Bitpass = 0 : B_ers = 0 : B_meno = 0 : Xu = 0
T = 200
Pi = 0
Do
Waitms 1
T = T + 1
Call Keys(key)
If T > 200 Then
If T = 201 Then : Cls : Locate 2 , 1 : Lcd "TABAN ELCTRONIC" : End If
T = 201 : Bit1 = 1 : Xu = 0 : Clsrkey
Pi = Pi + 1 : If Pi = 1000 Then Start Watchdog
Call Tag
If Bit_tag_new = 1 Then Call Serchtag
Xu = 0
Else
Call Tag
Call Run
If Bit_tag_new = 1 Then Serchtag
If B_meno = 1 Then Meno
If B_write_eeprom = 1 Then Write_eeprom
If B_ers = 1 Then Erase_unit
End If
Loop
'-------------------------------------------------------
Sub Keys(key As Byte )
Key1 = Getkbd()
If Key2 = Key1 Then : Bitk = 0 : Else : Bitk = 1 : End If
If Key1 = 16 Then Bitk = 0
Key2 = Key1 : If Key1 < 12 Then : T = 0
Key = Lookup(key1 , Datakey)
Else : Key = 16 : End If
Return
End Sub
'--------------------------------------------------------------
Sub Clsrkey
Rkey(1) = 0 : Rkey(2) = 0 : Rkey(3) = 0 : Rkey(4) = 0
End Sub
'-----------------------------------------------------------------
Sub Run
If Bitk = 1 Then : If B_ring = 1 Then : Locate 1 , 1 : Lcd " " : B_ring = 0 : End If : If Key < 10 Then : If Xu = 0 Then : Locate 1 , 1 : Lcd " " : End If : Xu = Xu + 1 : Bitk = 0
If Xu = 1 Then Rkey(1) = Key
If Xu = 2 Then Rkey(2) = Key
If Xu = 3 Then Rkey(3) = Key
If Xu > 3 Then : Xu = 0 : Locate 1 , 1 : Lcd " " : Clsrkey : End If
Locate 1 , Xu : Lcd Rkey(xu)
End If
If Key = 10 Then : Locate 1 , 1 : Lcd " " : Clsrkey : Xu = 0
M1 = 0
Do
Call Keys(key) : M1 = M1 + 1 : Waitms 10 : If M1 = 150 Then : B_meno = 1 : T = 200 : Cls : End If
Loop Until Key <> 10
M1 = 0 : T = 200 : Return : End If
If Rkey(1) <> 0 Then : If Key = 11 Then : Xu = Xu -1 : Ring : End If : End If :
Bitk = 0 : Waitms 5 : End If
Return
End Sub
'--------------------------------------------------------------------------
Sub Meno
Pass_cheng_b = 0
L1:
Cls
Locate 1 , 1 : Lcd "INSERT PASSWORD "
Locate 2 , 1 : Lcd " [0**] "
Do
Call Keys(key) : Waitms 50
Loop Until Key = 16
Xu = 6 : Clsrkey : Bitk = 0
Do
Key_u
If Bitk = 1 Then : Bitk = 0
If M1 <> 0 Then : If Key = 11 Then
If Pass_cheng_b = 1 Then
M5 = M1
Cls
Locate 1 , 1 : Lcd " RE-PASSWORD "
Locate 2 , 1 : Lcd " [0**] "
Do
Call Keys(key) : Waitms 50
Loop Until Key = 16
Xu = 6 : Clsrkey : Bitk = 0
Do
Key_u
If Bitk = 1 Then : Bitk = 0
If M1 <> 0 Then : If Key = 11 Then
If M1 = M5 Then : Pass_cheng = M1 : Waitms 50 : M4 = 350 : Waitms 50 : Locate 2 , 1 : Lcd "PASS CHENG" : Wait 2 : Pass_cheng_b = 0 : M3 = M1 : Start Watchdog
Else
Cls
Locate 1 , 1 : Lcd " REJECT CHENG "
Locate 2 , 1 : Lcd " " : Wait 3
Start Watchdog
End If : End If : End If : End If
Loop
End If
If M1 = M3 Then
Locate 2 , 1 : Lcd "ACCEPTED " : Wait 2 : Cls : Locate 1 , 1 : Lcd "1>CHENG PASSWORD " : Locate 2 , 1 : Lcd "2>CARD OPTIONS"
Do
Call Keys(key)
If Bitk = 1 Then
If Key = 1 Then : Pass_cheng_b = 1 : Goto L1 : End If
If Key = 2 Then Goto Tr
If Key = 10 Then Start Watchdog
End If
Loop
Tr:
Cls : Locate 1 , 1 : Lcd "1>ADD CARD " : Locate 2 , 1 : Lcd "2>ERASE CARD"
Do
Call Keys(key) : Waitms 50
Loop Until Key = 16
Do
Call Keys(key)
If Bitk = 1 Then
If Key = 1 Then : B_write_eeprom = 1 : T = 200 : B_meno = 0 : Return : End If
If Key = 2 Then : B_ers = 1 : T = 200 : B_meno = 0 : Return : End If
If Key = 10 Then Start Watchdog
End If
Loop
Else
Locate 2 , 1 : Lcd "ACCESS DENIED" : Wait 2 : Goto L1
End If
End If : End If
If Key = 10 Then Start Watchdog
End If
Loop
B_meno = 0
End Sub
'---------------------------------------------------------------------------
Sub Ring
Var1 = Xu : Bit_tag_new = 0
If Var1 = 2 Then : Op = Rkey(1) * 100 : Op1 = Rkey(2) * 10 : Op2 = Op + Op1 : Op2 = Op2 + Rkey(3) : End If
If Var1 = 1 Then : Op = Rkey(1) * 10 : Op2 = Op + Rkey(2) : End If
If Var1 = 0 Then : Op2 = Rkey(1) : End If
Locate 1 , 1 : Lcd "RING to Unit:" : Lcd Op2 : T = 0 : Op2 = 0 : B_ring = 1 : Xu = 0
Portc.7 = 1
Var1 = Var1 + 1
For Vau = 1 To Var1
Wait 1
Select Case Rkey(vau)
Case 0 : Porta = 235
Case 1 : Porta = 123
Case 2 : Porta = 125
Case 3 : Porta = 126
Case 4 : Porta = 187
Case 5 : Porta = 189
Case 6 : Porta = 190
Case 7 : Porta = 219
Case 8 : Porta = 221
Case 9 : Porta = 222
End Select
Waitms 500 : Porta = 238 : Waitms 500
Next
Porta = 237 : Waitms 500 : Porta = 255 : Portc.7 = 0
P1:
Clsrkey
End Sub
'-------------------------------------------------------------------------------
Sub Serchtag()
If Bit_tag_new = 1 Then
T = 200
Bit_tag_new = 0 : B1 = 2 : B = 1 : B3 = 1
Ch1:
Call Read_eeprom(b1 , Value)
If Value = Rf(b3) Then : B3 = B3 + 1 : B1 = B + B3
If B3 = 11 Then : Locate 1 , 1 : Lcd "UNIT:" : Call Read_eeprom(b , Value) : Locate 1 , 6 : Lcd Value : Lcd " "
Rl_door = 1 : Wait 1 : Rl_door = 0 : Goto Ch2 : End If
Goto Ch1
Else
If B = 5501 Then Goto Ch2 : B = B + 11 : B3 = 1 : B1 = B + B3 : Goto Ch1 : End If
Ch2:
End If : Return
End Sub
'-------------------------------------------------------------------------------
Sub Tag
If Bitw = 1 Then Bitpass = 1
Serch:
Inputbin #1 , C
If C = "st" Then : Bitpass = 0 : Bit_tag_new = 1 : Locate 1 , 13 : Lcd "CARD" : For B3 = 1 To 11 : Rf(b3) = Waitkey(#1) : Next : End If
' Cls : Lcd Chr(rf(1)) ; : Lcd Chr(rf(2)) ; : Lcd Chr(rf(3)) ; : Lcd Chr(rf(4)) ; : Lcd Chr(rf(5)) ; : Lcd Chr(rf(6)) ; : Lcd Chr(rf(7)) ; : Lcd Chr(rf(8)) ; : Lcd Chr(rf(9)) ; : Lcd Chr(rf(10)) ; : Lcd Chr(rf(11)) ;
If Bitpass = 1 Then : Call Keys(key) : If Key = 10 Then Start Watchdog : Goto Serch : End If
Return
End Sub
'-------------------------------------------------------------------------------
Sub Write_eeprom
B_write_eeprom = 0 : B_meno = 0
Cls
B = 1 : Locate 2 , 1 : Lcd "UNIT :"
Do
Waitms 1
Call Keys(key)
Loop Until Key = 16
Xu = 6
Do
Key_u : If M1 <> 0 Then : If Key = 10 Then Start Watchdog : End If
Loop Until Key = 11
F1:
Call Read_eeprom(b , Value)
If Value = 250 Then
Else : B = B + 11 : If B = 5501 Then Lcd "FULL MEMORY " : Goto F1 : End If
Locate 1 , 1 : Lcd "INSERT CART" : Bitw = 1 : Tag : Locate 1 , 1 : Lcd "PLEASE WAIT" : Bitw = 0 : B3 = M1 : Call Write_rom(b , B3)
For B3 = 1 To 10 : B1 = B + B3 : Call Write_rom(b1 , Rf(b3)) : Next : Bit_tag_new = 0 : Return
End Sub
'------------------------------------------------------------------------------
Sub Key_u
Call Keys(key)
If Bitk = 1 Then : If Key < 10 Then : Xu = Xu + 1
If Xu = 7 Then Rkey(1) = Key
If Xu = 8 Then Rkey(2) = Key
If Xu = 9 Then Rkey(3) = Key
If Xu = 10 Then : Xu = 6 : Clsrkey
Else
Locate 2 , Xu : M1 = Xu - 6 : Lcd Rkey(m1) : End If : Waitms 400
If B_meno = 1 Then : Locate 2 , 7 : Lcd "***" : End If
M1 = Rkey(1) * 100 : M2 = Rkey(2) * 10 : M1 = M1 + M2 : M1 = M1 + Rkey(3)
End If : End If
End Sub
'-------------------------------------------------------------------------------
Sub Erase_unit
Cls
Locate 2 , 1 : Lcd "UNIT : "
B3 = 0 : B_ers = 0 : Clsrkey
Do
Waitms 1
Call Keys(key)
Loop Until Key = 16
Xu = 6
Do
Key_u : If M1 <> 0 Then : If Key = 10 Then Start Watchdog : End If
Loop Until Key = 11
B = 1 : B2 = 1
Do
Call Read_eeprom(b , Value)
If Value = M1 Then
For B1 = 0 To 10 : B2 = B + B1 : Call Write_rom(b2 , 250) : Next
B3 = B3 + 1 : B = B + 11
Else
B = B + 11 : End If
Loop Until B > 5512
T = 200 : B_meno = 0 : Cls : Return
End Sub
'-------------------------------------------------------------------------------
'____________________________________________ ___________________________________
'&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;
Sub Write_rom(byval Adres As Word , Value As Byte)
I2cstart
I2cwbyte Addressw
I2cwbyte Adres
I2cwbyte Value
I2cstop
Waitms 10
End Sub
'____________________________________________ ___________________________________
'&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;&&&&&&&&&& ;
Sub Read_eeprom(byval Adres As Word , Value As Byte)
I2cstart
I2cwbyte Addressw
I2cwbyte Adres
I2cstart
I2cwbyte Addressr
I2crbyte Value , Nack
I2cstop
End Sub
'-------------------------------------------------------------------------------
Datakey:
Data 10 , 7 , 4 , 1 , 0 , 8 , 5 , 2 , 11 , 9 , 6 , 3
دیدگاه