-1

I am currently using a pic16f1825 with an eeprom (24LC16BI/OT) and I'm trying to read from the eeprom. There is already a file on the eemprom but the trouble I am having is what address do I use because I was reading the datasheet and it says that the address for reading is 1010 with a R/W bit of 1. So is that the address or is there a different address that I need to use as well because I want to go through the file to search for a key word and if I do that don't I need to have different addresses each time to read something different?

  • It really depends on how the two are connected. – Some programmer dude Jul 14 '17 at 15:59
  • @Someprogrammerdude what do you mean by it depends on how they are connected, if your taking about in the circuit then its trough the scl and sda lines of the eeprom to the those corresponding lines in the pic – mohammed saleh Jul 14 '17 at 16:02
  • So it's connected through [I²C](https://en.wikipedia.org/wiki/I%C2%B2C)? Unless you have a library with functions to communicate through an I²C interface you have to start learning that first. – Some programmer dude Jul 14 '17 at 16:08
  • @Someprogrammerdude I already have a library for communicating through an I2C and I have an EEPROM library for reading and writing – mohammed saleh Jul 14 '17 at 16:18

1 Answers1

0

For the read operation, the EEPROM has 'Sequential read mode'

8.3 Sequential Read

Sequential reads are initiated in the same way as a random read, except that once the 24XX16 transmits the first data byte, the master issues an acknowledge as opposed to a Stop condition in a random read. This directs the 24XX16 to transmit the next sequentiallyaddressed 8-bit word (Figure 8-3).

I will try to simplify the steps :

  1. Send start condition.
  2. Send a write-control-signal ie 10100000.
  3. You get a ACK signal
  4. Then send read address you want to start at. If its at the start, then simply 00000000.
  5. You get a ACK signal.
  6. Send Start condition, to stop write mode and start new read mode.
  7. Send read-control byte 10100001.
  8. You get the first data-byte
  9. You send ACK signal
  10. You get next data-byte.
  11. Continue 9-10, till you send a Stop condition.

Steps 1-5 makes the internal-address-pointer of the EEPROM point to the read address you want to start at (00000000 in the above case). The rest is taken care internally by the chip. It increments the pointer after each ACK signal issued by the Master. This way, you can read the entire range.

Community
  • 1
  • 1
zeekhuge
  • 1,594
  • 1
  • 13
  • 23
  • so I just wanted to know if I understood what you meant. So I first send the I2C_Start command then send the write command with the address 0xA0 then I send the address I want to read from so I2C_Write(0x00) then I send the start command again and then I say I2C_Read(0xA1) then send the ack signal. – mohammed saleh Jul 17 '17 at 12:52
  • I dont think the I2C_read() should need a parameter. You sure that is how you will call read function ? That probably depends on the library you are using. – zeekhuge Jul 17 '17 at 15:06
  • Also, I think you have misunderstood how the library works. The write() function of the library wont "write" on the EEPROM, it will "write" the given byte to the device. So, 'Send a wrtie-control-signal ie `10100000`' is equivalent to `I2C_write(10100000)`. And similarly for the read functions. – zeekhuge Jul 17 '17 at 15:08
  • so when you said send the ack signal do I do I2C_Read() or I2C_Write? – mohammed saleh Jul 17 '17 at 15:52
  • I would say none of these. But the actual method depends on what library you are using. I would suggest you to read documentation of that library first and then ask any other question. – zeekhuge Jul 17 '17 at 21:56