با سلام من نحوه استفاده از eeram راتو این سایت دیدم ولی متوجه نشدم لطفا اگر کسی روش اون رو با فارسی با زبان بیسیک بلده به من می تونه یاد بده ممنون از شما
اطلاعیه
Collapse
No announcement yet.
استفاده از eeram
Collapse
X
-
پاسخ : استفاده از eeram
اینم یک برنامه با بیسیک
'for test external eeprom
$regfile = "89c2051.dat"
$crystal = 12000000 'you can use 12 MHz
$large
Config Lcdpin = Pin , Db4 = P3.4 , Db5 = P3.5 , Db6 = P3.6 , Db7 = P3.7 , E = P3.0 , Rs = P3.1
Display On
Config Scl = P1.0
Config Sda = P1.1
Config I2cdelay = 1
Cursor Off
Const Dataa = "external eeprom"
Cls
Locate 1 , 1
Lcd Dataa
Wait 2
Cls
Dim X As Byte
Dim Weeprom As Byte
Dim Reeprom As Byte
Dim Address As Byte
Const Adreswrite = 160 'write of 2404 when a0-3 is low
Const Adresread = 161 'read adres of 2404 when a0-3 is low
Address = 1
Do
For X = 1 To 10
Locate 1 , 1
Lcd "write.. " ; X ; " "
Locate 2 , 1
Lcd "X=" ; X ; " "
Address = X
Weeprom = X
Gosub Writeeeprom_external
Waitms 150
Next X
For X = 1 To 10
Address = X
Gosub Readeeprom_external
Locate 1 , 1
Lcd "read.. " ; Reeprom ; " "
Locate 2 , 1
Lcd "X=" ; X ; " "
Waitms 150
Next X
Loop
'----------now read the value back into the var a -------------------
End
'==================
Writeeeprom_external:
I2cstart 'generate start
I2cwbyte Adreswrite 'send slaveadres
'I2cwbyte 0
I2cwbyte Address 'send adres of EEPROM
I2cwbyte Weeprom 'send a value
I2cstop 'generate stop
Waitms 10 'wait 10 mS because that is the time that the chip needs to write the data
Return
'==================
Readeeprom_external:
I2cstart 'generate start
I2cwbyte Adreswrite 'write slaveadres
'I2cwbyte 0
I2cwbyte Address 'write adres of EEPROM to read
I2cstart 'generate repeated start
I2cwbyte Adresread 'write slaveadres of EEPROM
I2crbyte Reeprom , Nack 'receive value into a. 9 means last byte to receive
I2cstop 'generate stop
Return
اگه مردم می دونستن زمان چقدر با ارزشه دیگه هیچ وقت کفش بند دار نمی خریدن البرت انیشتن
دیدگاه