Shop OBEX P1 Docs P2 Docs Learn Events
use Eeprom — Parallax Forums

use Eeprom

JohnnyfumiJohnnyfumi Posts: 14
edited 2008-05-31 14:33 in Propeller 1
hi I'm trying to use an external eeprom whit my propeller board; this is 24LC1025, now i want to use it for read and write byte on it. Is there anybody can help me? I'm using the object Basic_I2C_Driver.spin i try to write binary value "%101", but i read only value "11111111". where is my fault ? [noparse];)[/noparse]

Johnny

Comments

  • Agent420Agent420 Posts: 439
    edited 2008-05-30 15:29
    You may want to include your source code and even a basic schematic of the project... Might help clarify things.
  • JohnnyfumiJohnnyfumi Posts: 14
    edited 2008-05-30 15:48
    hi Agent420, for the schematic i follow the indication on the propeller website (i use the pin 4 and pin 5 as SCL and SDA instead of pin 28 and pin 29). For the low level code i use the file "Basic_I2c_Drive.spin" and the follow main file

    CON
    · pippo = %101
    ··ACK····· =·5
    · i2cSCL= 4
    OBJ
    · eeprom: "Basic_I2C_Driver"
    · fullduplex : "fullduplex"
    ·
    Pub Main
    · eeprom.Initialize(i2cSCL)
    · eeprom.Start(i2cSCL)
    · eeprom.Write(i2cSCL,pippo)

    · fullduplex.start(0,1,0,57600)
    · waitcnt(clkfreq/4 + cnt)
    · repeat 4
    ··· fullduplex.tx(%101)
    ··· fullduplex.rxflush

    tankyou so much for your disponibility

    Johnny
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-30 18:03
    Start and Write are low level functions used internally and made available for use with devices other than EEPROM. You need to use the ReadByte and WriteByte methods for EEPROM. Please look at the comments in Basic_I2C_Driver.spin for examples and their definitions. Remember that you have to use WriteWait or put in a 5ms pause after writing a byte to allow the EEPROM to finish the write operation.
  • JohnnyfumiJohnnyfumi Posts: 14
    edited 2008-05-31 13:31
    Hi Mike,

    thank you for advice, i look at WriteByte and ReadByte methods but i don't understand how to use the method's parameters

    WriteByte(SCL, devSel, addrReg, data)

    probably SCL is a SCL pin (in my case is 4 pin), but i don't kwon more about "devSel", "addrReg" and "data" can you help me?

    I have a second question, can i use this methods (ReadByte and WriteByte) whit an eeprom LC1025 or i have to choose a different device such as LC256?

    thanks a lot

    johnny
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-31 14:33
    Use "eeprom#EEPROM" for "devSel". This is the standard value for a device select code for the 1st EEPROM on an I2C bus and is defined in "Basic_I2C_Driver" as "EEPROM".

    "addrReg" is the EEPROM address value to be used.

    "data" is the byte value to be written

    All of the above information is in the comments in "Basic_I2C_Driver". Please read the comments. There's a lot of useful information there
    including an example of the use of the ReadPage and WritePage routines.
Sign In or Register to comment.