zu erst ein schönes Weihnachtsfest euch allen!
Ich habe folgendes Problem:
nach langem suchen habe ich einen Code gefunden (unten) mit dem ich mein eeprom beschreiben und auch wieder auslesen kann.
Mir ist nur noch schleierhaft, wie ich die Speicherzellen/Speicherbereiche, also in hex, für jedes Byte der 64kbit ermitteln kann.
Und was sagt Ihr zu dem Code, gibt es eine bessere Methode, um über I2C auf ein eeprom zu zugreifen?
=>code bitte<=
Vielen Dank und gute und erholsame Feiertage!Code:$regfile = "m32def.dat" $crystal = 16000000 $baud = 9600 $hwstack = 228 $swstack = 228 $framesize = 128 $lib "i2c_twi.lbx" Config Twi = 400000 ' Init TWBR und TWSR ' TWI gleich einschalten, das macht Bascom ansonsten erst beim I2CStart ! TWCR = &B00000100 ' nur TWEN setzen '----------------- LCD Display an Port c =>Conector SV9------------------------------------------------------------------------------------------------- Config Lcdpin = Pin , Db4 = Portc.5 , Db5 = Portc.4 , Db6 = Portc.3 , Db7 = Portc.2 , E = Portc.6 , Rs = Portc.7 ' Pinbelegung "LCD-Port)" ' SV8 6 5 4 3 7 8 ' Pinbelegung SV9 Board '------------------ DS1820 on pinA 0 (pull up)-------------------------------------------------------------------------------------------------------------------------------------- ' '--------- Eeprom Anschlüße ------ Config Sda = Portc.1 'SDA und SCL definieren Config Scl = Portc.0 Const E_ctlw = &HA0 Const E_ctlr = &HA1 Dim E_ah As Byte Dim E_al As Byte Dim E_addr As Word Dim E_dat As Byte Dim Dat As Byte Declare Sub E_write(byval E_addr As Word , Dat As Byte) Declare Sub E_read(byval E_addr As Word , E_dat As Byte) Declare Sub 24lc256_test call 24lc256_test end ' Routine to test the 24LC256 ' Sub 24lc256_test 'Test read and writes Print "Testing I2C Eeprom" Dat = 10 For E_addr = &H1000 To &H1010 Call E_write(e_addr , Dat) Call E_read(e_addr , E_dat) Print E_dat ; " "; Incr Dat Incr Dat Incr Dat ' +1 +1 +1 Next E_addr Print Print "Here a counter should appear from 0, 3, 6, 9, 12, 15, 18,21, 24, 27 etc." Print "End of Test" End Sub ' Routine to write the 24LC256 ' Sub E_write(byval E_addr As Word , Dat As Byte) E_ah = High(e_addr) E_al = Low(e_addr) I2cstart I2cwbyte E_ctlw I2cwbyte E_ah I2cwbyte E_al I2cwbyte Dat I2cstop Waitms 10 End Sub ' Routine to read the 24LC256 ' Sub E_read(byval E_addr As Word , E_dat As Byte) E_ah = High(e_addr) E_al = Low(e_addr) I2cstart I2cwbyte E_ctlw I2cwbyte E_ah I2cwbyte E_al I2cstart I2cwbyte E_ctlr I2crbyte E_dat , Nack I2cstop ' End Sub
MAT







Zitieren

Lesezeichen