cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

muto_1207481
New Contributor

I have executed the following function to initialize the I2C slave device, but it seems that communication is not working properly.

I2CMAST_MasterClearStatus();

Stat = I2CMAST_MasterWriteBuf(AQM0802_ADW, &TestData, 2,  I2CMAST_MODE_COMPLETE_XFER);

for(;;) {

     if(0u != (I2CMAST_MasterStatus() & I2CMAST_MSTAT_WR_CMPLT))

break;

}

※Note Slave Address:0x7c、The contents of TestData are 0x80,0x34

Additional information:Implementation is a fixed function

The actual waveform as a result of executing the WriteBuf function is (See attached document)

It seems that only the first slave address is transferred from the actual waveform

There seems to be no problem with the transfer timing of the slave address.

I would appreciate any good advice on this phenomenon.

Thank you

Timming.png

0 Likes
1 Solution
VenkataD_41
Moderator
Moderator

Hi,

Can you please follow the following firmware flow and try once?

    (void) I2CM_I2CMasterClearStatus();

  

    /* Start I2C write and check status*/

    if(I2CM_I2C_MSTR_NO_ERROR == I2CM_I2CMasterWriteBuf(I2C_SLAVE_ADDR,

                                    buffer, PACKET_SIZE,

                                    I2CM_I2C_MODE_COMPLETE_XFER))

    {

        /*If I2C write started without errors,

        / wait until I2C Master completes write transfer

        */

        while (0u == (I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_WR_CMPLT))

        {

            /* Wait */

        }

      

        /* Display transfer status */

        if (0u == (I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_ERR_XFER))

        {

            /* Check if all bytes was written */

            if (I2CM_I2CMasterGetWriteBufSize() == BUFFER_SIZE)

            {

                status = TRANSFER_CMPLT;

            }

        }

    }

The above firmware flow is taken from the Cypress code example on SCB based I2C Master. I am attaching the code example for your reference. Please test it at your side and update us.

Thanks

Ganesh

View solution in original post

0 Likes
3 Replies
VenkataD_41
Moderator
Moderator

Hi,

Can you please follow the following firmware flow and try once?

    (void) I2CM_I2CMasterClearStatus();

  

    /* Start I2C write and check status*/

    if(I2CM_I2C_MSTR_NO_ERROR == I2CM_I2CMasterWriteBuf(I2C_SLAVE_ADDR,

                                    buffer, PACKET_SIZE,

                                    I2CM_I2C_MODE_COMPLETE_XFER))

    {

        /*If I2C write started without errors,

        / wait until I2C Master completes write transfer

        */

        while (0u == (I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_WR_CMPLT))

        {

            /* Wait */

        }

      

        /* Display transfer status */

        if (0u == (I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_ERR_XFER))

        {

            /* Check if all bytes was written */

            if (I2CM_I2CMasterGetWriteBufSize() == BUFFER_SIZE)

            {

                status = TRANSFER_CMPLT;

            }

        }

    }

The above firmware flow is taken from the Cypress code example on SCB based I2C Master. I am attaching the code example for your reference. Please test it at your side and update us.

Thanks

Ganesh

View solution in original post

0 Likes
muto_1207481
New Contributor

早速 返信ありがとうございます。

サンプルコードに従って確認しましたが

エラーもなく転送でき、送信済バッファー数(2個)も確認しましたが問題ありませんでした。

現象としては同じでした。(波形観測でも確認)

一点気になることがあります。

WriteByte()関数などでも試しましたが

クロック9番目のSDAは常に”H"でNAK状態?

この状態が悪さしていると事は考えられないのでしょうか?

ご教示のほど よろしくお願いします。

0 Likes
muto_1207481
New Contributor

再度 コードを確認した結果

スレーブアドレスのミスであることが判明しました。

左詰めのアドレスを指定しなければいけないところをデータシートのアドレスを

そのまま使っていたことによる不具合でした。

ありがとうございました。

0 Likes