You are here

How to read from I2C device (PCF8574A) that is not EEPROM ? | Cypress

How to read from I2C device (PCF8574A) that is not EEPROM ?

Summary: 1 Reply, Latest post by aasi on 17 Jan 2012 04:27 AM PST
Verified Answers: 0
Last post
Log in to post new comments.
Vytautas2's picture
User
36 posts

Hi,

I would like to read the status of Philips PCF8574A (http://www.nxp.com/documents/data_sheet/PCF8574.pdf) pins P0-P7.

The command CyU3PI2cReceiveBytes that works well with I2C EEPROM reading does not work with PCF8574A.

Instead of reading (buffer always returns 0), it causes writing and changes current state of P0-P7. How to read them without changing their state ? Thanks.

CyU3PI2cPreamble_t preamble;

uint8_t tmp_addr;

tmp_addr = 0x7C;

preamble.buffer[0] = tmp_addr;

preamble.buffer[1] = 0;

preamble.buffer[2] = 0;

preamble.buffer[3] = tmp_addr | 0x1;

preamble.length = 4;

preamble.ctrlMask = 0x0004;

tmp_i2c_test_buf_len = 1;

apiRetStatus = CyU3PI2cReceiveBytes (&preamble, tmp_i2c_test_buf, tmp_i2c_test_buf_len, 0);

 
aasi's picture
Cypress Employee
1166 posts

In EEPROM read case you send the address of the location you want to read and then read. So in your code you're writing 0x0000 and then reading.

In the case of the I/O port expander as per the datasheet, page 11 you just be just doing a read (remove the first 3 write i.e. the address and 0x0000 and it should work fine). This would explain your writing of 0 as well.

Cheers,

Anand

Log in to post new comments.