Hi
I'm trying to add an external EEPROM to my Cypress EZ-USB NX2LP-Flex dev kit, and accessing it using the library functions EZUSB_ReadI2C(), EZUSB_WriteI2C() and EZUSB_WaitForEEPROMWrite().
I plugged in a new 2Kbit EEPROM in the DIP socket and thought it was the only EEPROM there, and I tried reading it at address 0xA0, and was able to get all 0xFFs. I tried to write a single byte to the EEPROM with the following code:
BYTE xdata temp1; BYTE xdata temp2[8]; BOOL wrOK = FALSE; temp1 = 0x01; while (!wrOK) wrOK = EZUSB_WriteI2C(0xA0,0x01, &temp1);
I then read to read 8 bytes back with the following code
EZUSB_ReadI2C(0xA0,0x08, &temp2);
Instead of getting all 0xFF except for the 1st byte, I got all 0x01.
I then realized that there are more than 1 I2C EEPROM connected to the SDA/SCL lines, so I'm wondering how do I address the correct one? And once I do that, how do I specify the memory address within the chip? I know the device address for all EEPROM starts with 1010(0xA), but I'm confused as to the later 4bits.
Thanks.
The specific EEPROM Datasheet will tell you how to assign the low-order address bits.
I've looked at the datasheets. The one I'm using is a Microchip 24AA08. According to the datasheet,
3.6 Device Addressing A control byte is the first byte received following the Start condition from the master device (Figure 3-2). The control byte consists of a four-bit control code. For the 24XX08,this is set as '1010' binary for read and write operations. The next three bits of the control byte are the block-select bits (B2, B1, B0). B2 is a 'don't care' for the 24XX08. They are used by the master device to select which of the four 256 word-blocks of memory are to be accessed. These bits are in effect the three Most Significant bits of the word address. The last bit of the control byte defines the operation to be performed. When set to '1', a read operation is selected. When set to '0' a write operation is selected. Following the Start condition, the 24XX08 monitors the SDA bus checking the device type identifier being transmitted and, upon receiving a '1010' code, the slave device outputs an Acknowledge signal on the SDA line. Depending on the state of the R/W bit, the 24XX08 will select a read or write operation.
It seems to suggest that the lower order address bits are used to select among 4 banks within the chip, rather than to select the actual chip itself, out of many chips. This is why I'm confused. Isn't the 7bit I2C address meant to address devices, and not addresses within a device?
This brings me to my next question, supposing I have the actual device address. How then would I address within the device using the EZUSB_WriteI2C() and EZUSB_ReadI2C() functions? These functions only allow me to specify device address, length and data structure to write from/read to. It doesn't let me specify the word address.
"How then would I address within the device using the EZUSB_WriteI2C() and EZUSB_ReadI2C() functions?"
I think you said those functions were provided by Cypress - so you'll have to ask Cypress that one!
I was hoping people have used these functions before and could give me a faster response. The local Cypress reps aren't exactly very responsive or knowledgeable.
Anyone else?
View all questions in Keil forum