- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, I am experiencing some trouble when trying to get some data from an I2C port on Cy8CKit-059, I am trying to read 8 bytes through the port, everything in the code works well but the retrieved data is always 0. I checked on the protocol analyzer, and it seems that the data stops transmitting because of master nak's after the first read, even though I2C_MasterReadBuf is called with an 8 on the cnt parameter.
the routine looks as follows (Ommiting the transmit part):
uint8_t ErrorCondition = I2C_MasterReadBuf(PortAdress, InputBuffer, BytesToRead, I2C_MODE_COMPLETE_XFER);
if(ErrorCondition){Return};
uint8_t status = I2C_MasterStatus();
while((status & (I2C_MSTAT_RD_CMPLT | I2C_MSTAT_ERR_XFER)) == 0u)
{
status = I2C_MasterStatus();
}
if(status&I2C_MSTAT_RD_CMPLT){return I2C_Bus::ErrorConditions::Success;}
else{return I2C_Bus::ErrorConditions::UnknownError;}
After the execution of the previous code, InputBuffer contains only zeros
Solved! Go to Solution.
- Labels:
-
PSoC5 LP MCU
- Tags:
- i2c
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've solved it, the problem was somewhere else in the code, thanks for your help, the code above works as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A word of advise (on any processor) when using I2C : Start with Presence detection of I2C devices. Check i2c adress range to confirm the correct slaves are detected. Mind that 50% of libraries (and datasheets) use 8-bit adress notation (0x10,0x12,0x14..0xFE) and the other 50% uses 7-bit adress notation (0x08, 0x09, 0x0A, 0x0B...0x7F). 8-bit 0x10 equals 7-bit 0x08. Make sure you understand the differences
When you get that working, you can continue sending real information to/from the slaves.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
By any chance, can you download my sample below
https://community.infineon.com/t5/Code-Examples/MCU-Tester-a-Swiss-Army-Knife-for-PSoC-CY8CKIT-059-v...
and try i2c command such as "scan" and "read" ?
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've solved it, the problem was somewhere else in the code, thanks for your help, the code above works as expected