Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > How to read from I2C device (PCF8574A) that is not EEPROM ?

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



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

Post Reply
Follow this topic



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

Vytautas2 posted on 16 Jan 2012 5:30 AM PST
Top Contributor
36 Forum 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);

 




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

aasi posted on 17 Jan 2012 02:27 AM PST
Cypress Employee
1170 Forum 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






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 06/15/20