I modified the CE220818 to send out 2 bytes of data to an I2C slave. Please check the attached project, emulated slave logs and I2C bus scope shots.
You could use that as a reference. If you still face any issues with the attached project, please send the scope shots of your I2C bus (SDA and SCL).
Hi, thanks for the reply.
Sadly this code seems to fail in this point:
if ((0u == (MASTER_ERROR_MASK & masterStatus)) &&
(TX_PACKET_SIZE == Cy_SCB_I2C_MasterGetTransferCount(I2C_HW, &I2C_context)))
status = TRANSFER_CMPLT;
in particular this condition: (0u == (MASTER_ERROR_MASK & masterStatus)
is always false, and i can't understand why.
I've tried to monitoring the output of both scl and sda lines to see if they were behaving correctly and as far as i can understand it seems that they are working well.
Any further suggestion?
Thanks in advance
Can you check what is the master status, when the IF condition is executed?
Also, pls share the I2C bus wave forms when the master status has errors.
The master status is:
0x00220000 and that doesn't seem to be one of the macros defined in the API documentation
This is a shot taken to an oscilloscope of the 2 waveforms. The upper one is the SDA and the other is the SCL line.
I hope this is what you were asking for.
I think that the waveform of the SCL is odd, it should be high in normal state, according to the documentation od the I2C protocol. I'm missing something?
Thanks for your time and patience.
The problem was i had to connect my device through different pull-up resistors and also there was a missing line in the code: mI2C_Start();
Thanks for your time and help.