Hi all,
while trying to use I2C-module of FX3 some strange behaviour occured:
1.) I can't get out a speed of 1MHz on I2C-bus! If I set the bitrate in struct CyU3PI2cConfig_t to 1000000 (1MHz) I see only the I2C-startcondition on oscilloscope and then the whole I2C-bus hangs up!
Setting the bitrate to:
100kHz => works fine
400kHz => works fine
900kHz => I2C-bus shows only ~700kHz ?!
1MHz => I2C hangs up!
VIO5 is 3.2V (measured).
2.) There might be a problem with the API CyU3PI2cTransmitBytes(). The API returns in any case CY_U3P_SUCCESS, even if there is no I2C-slave available on the bus. I called the API's CyU3PI2cTransmitBytes() and CyU3PI2cWaitForAck() subsequently (using the code below) without having a slave on the bus (so there is no ACK for sure! I checked it on oscilloscope) and the API:
CyU3PI2cTransmitBytes() returned CY_U3P_SUCCESS => I'd expect CY_U3P_ERROR_FAILURE (acc. FX3APIGuide)
CyU3PI2cWaitForAck() returned CY_U3P_ERROR_TIMEOUT as expected
This is the according code-snippet:
=> the variable dmaUsb2CpuBuffer.buffer holds a valid address (pointing to a character) and dmaUsb2CpuBuffer.count = 1!
i2cPreamble.buffer[0] = 0xB0;
i2cPreamble.ctrlMask = 0;
i2cPreamble.length = 1;
apiRetStatus = CyU3PI2cWaitForAck (&i2cPreamble, 3); // repeat it 3 times if didn't got ACK
if(apiRetStatus == CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "CyU3PI2cWaitForAck() succeeded!\r\n");
}
else
{
CyU3PDebugPrint (4, "CyU3PI2cWaitForAck() failed: %s\r\n", appGetErrorString(apiRetStatus));
}
// write preamble and data received from USB to I2C
apiRetStatus = CyU3PI2cTransmitBytes(&i2cPreamble, dmaUsb2CpuBuffer.buffer,
dmaUsb2CpuBuffer.count, 0);
if (apiRetStatus == CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "CyU3PI2cTransmitBytes() succeeded!\r\n");
}
else
{
CyU3PDebugPrint (4, "CyU3PI2cTransmitBytes() failed: %s\r\n", appGetErrorString(apiRetStatus));
}
Could you pls help me to get rid of this!
I'm using SKD Beta3.1 and FX3's Dvlp-board.
Thanks a lot!
Regards,
Robert
|