i2c write one byte addressing in Fx3s

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JaYe_3798301
Level 2
Level 2

Hi,

I am trying to get the i2c write working in my Fx3S.

The Fx3S worked as a i2c master, and my i2c slave device is at one byte addressing mode.

After modifying the sample code to:

    preamble.length    = 2;

    preamble.buffer[0] = IAP2_I2C_WRITE_ADDRESS_RST_HIGH;   

    preamble.buffer[1] = ACCESSORY_CERTIFICATE_SERIAL_NUMBER; //0x4E

    preamble.ctrlMask  = 0x0000;

    status = CyU3PI2cTransmitBytes (&preamble, buffer, 1, 0);

The i2C waveform I got is as follows:

pastedImage_2.png

How should I correctly set if I do not want the additional 0x00 byte following 0x4E?

0 Likes
1 Solution

Hello Jay,

- Apologies. You are right. The CyU3PI2cTransmitBytes() API would return immediately if the byteCount parameter is set to 0 and there would be no I2C transfer.

- Modify the preamble buffer to contain the device address (IAP2_I2C_WRITE_ADDRESS_RST_HIGH) and include a data buffer that is passed as a parameter to the CyU3PI2cTransmitBytes. Fill the data buffer with the ACCESSORY_CERTIFICATE_SERIAL_NUMBER and pass it to the CyU3PI2cTransmitBytes() API.

- When CyU3PI2cTransmitBytes()byteCount parameter is set to 0, there will be no I2c transfer.

Best regards,

Srinath S

View solution in original post

0 Likes
3 Replies
SrinathS_16
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello,

EDIT: Please ignore this response as it is INCORRECT.

Please modify as below.

status = CyU3PI2cTransmitBytes (&preamble, buffer, 0, 0);

The preamble data contains the address and the first byte of data to be followed. So, the byteCount parameter of the CyU3PI2cTransmitBytes should be set to 0. Since you have set this to '1', there is an additional byte of data after the preamble being sent.

Best regards,

Srinath S

0 Likes

Hi Srinath,

I've modified the code following your suggestion.

    preamble.length    = 2; 

    preamble.buffer[0] = IAP2_I2C_WRITE_ADDRESS_RST_HIGH;     

    preamble.buffer[1] = ACCESSORY_CERTIFICATE_SERIAL_NUMBER; //0x4E 

    preamble.ctrlMask  = 0x0000; 

 

    status = CyU3PI2cTransmitBytes (&preamble, buffer, 0, 0); 

However, there would be no i2c waveform out if the 3rd parameter of CyU3PI2cTransmitBytes  is 0.

And I verified it with my logic analyzer.

Does the API not accept byteCount to be 0?

Jay

0 Likes

Hello Jay,

- Apologies. You are right. The CyU3PI2cTransmitBytes() API would return immediately if the byteCount parameter is set to 0 and there would be no I2C transfer.

- Modify the preamble buffer to contain the device address (IAP2_I2C_WRITE_ADDRESS_RST_HIGH) and include a data buffer that is passed as a parameter to the CyU3PI2cTransmitBytes. Fill the data buffer with the ACCESSORY_CERTIFICATE_SERIAL_NUMBER and pass it to the CyU3PI2cTransmitBytes() API.

- When CyU3PI2cTransmitBytes()byteCount parameter is set to 0, there will be no I2c transfer.

Best regards,

Srinath S

0 Likes