You are here

I2C Questions and Errors | Cypress Semiconductor

I2C Questions and Errors

Summary: 4 Replies, Latest post by catacon on 08 Jul 2012 03:17 PM PDT
Verified Answers: 0
Last post
Log in to post new comments.
catacon's picture
11 posts

Hey all,

I have been working on interfacing with an Aptina Imager (MT9P031) which uses I2C for configuration.  I have the GPIF setup to interface with the imager and GPIOs setup as enables, disables, etc.  I have been able to interface I2C with other devices, but I am having issues with the Imager.  We have the Imager working with and FX2, so much of the protcol I am using is copied from the FX2 firmware.

1) When using CyU3PI2cWaitForAck() or CyU3PI2cTansmitBytes() to write to the Imager registers, both functions return '74' which is CY_U3P_ERROR_FAILURE.  When I check the I2C error code with CyU3PI2cGetErrorCode(), it returns '15' which is not listed in the error code enumeration.  Any idea what this means?

status = CyU3PI2cTransmitBytes(&preamble, data, 2, 0);

2) When using CyU3PI2cSendCommand() to write to the Imager registers, it will always return CY_U3P_SUCCESS even if I use the wrong imager address or configure the preamble incorrectly.  Any idea why it always returns a success?

status = CyU3PI2cSendCommand(&preamble, 4, CyFalse);

3) As far as I understand, the ctrlMask member of the Preamble sets the start and stop bits AFTER each bit of the preamble.  Does the I2C API automatically send a start bit BEFORE the first preamble bit?  Does it send a stop bit after the last I2C bit, preamble or otherwise?




RobK's picture
81 posts


Q1) I observed the same issue! The Cypress Tech support admitted that this is an undocumenetd error-code and they wanna fix this in next SDK-release. I observed this error-code when I used the wrong slave-address, maybe it's a similar issue inyour application?!

Q2) No idea since I never used this API. But the API CyU3PI2cTransmitBytes() had a similar bug where it always returned success if only 1 byte was sent. This is fixed with SDK1.1. So maybe a similar issue  here?!

Q3) I think the start bit before the first byte is set automatically but if the direction is changed ("read slave" to "write slave" or "write slave" to "read slave") in your preamble you have to set a repeated start-condition in the controlMask. If you want to have a STOP condition after getting an ACK from slave as a response to a byte in your preamble you need also to specify this in the contolMask.

rskv's picture
Cypress Employee
1134 posts

 Regarding I2C APIs, I would recommend you to create a tech support case (MyAccount -> MyCases).


catacon's picture
11 posts

Thanks for the replies.  I kind of assumed that 'error 15' was just undocumented.  I did get this error with another device when I had a couple jumpers on the DVK set incorrectly (J45 and J42).  I am sure everything is connected correctly this time, though.  And I know I have the imager address correct.

I was able to get a scope of the I2C lines and it looks like it only sends the first byte of the preamble (device address).  So I assume this means that the imager is simply not able to respond.

catacon's picture
11 posts

So I was able to solve this.  It actually had nothing to do with the I2C functions.  The image sensor requires an external clock which I was providing via a complex GPIO.  SInce the GPIO I was using is part of the GPIF, I was overloading it, but I was not setting the second parameter of CyU3PDeviceGpioOverride() to CyFalse which overrides the GPIO as complex.  So the image sensor was never active which is why is would not respond to I2C functions. 

Log in to post new comments.