I2CのREAD

Tip / ログイン to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
user_3987996
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

添付ファイルのSingle Read Mode operationの動作をCYPRESSのAPIを使用して

実現できるのでしょうか?

書き込みが正しくできているか確認したいのですが、上手く関数が作れません。

ご教示ください。

0 件の賞賛
1 解決策
HirotakaT_91
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

はい、可能です。

添付いただいた日本ケミコンのNCM-03Vのアプリケーションノートを見る限り、通常のI2CのRead動作なので、問題なくCyU3PI2cReceiveBytes() APIで実装可能です。

ctrlMaskの2bit目を1にし、Start locationの位置をSingle Byte用に設定します。

I2Cでは、Read/Write動作はSlave addressに続いて指定されますので、リピートスタートコンディション(Sr)の後のSlave addressを格納しているバッファの最下位ビットを1に指定します。

以下、ご参考までにコード例を提示致します。

I2C Single Read Operation example code on FX3

CyU3PReturnStatus_t

sensorSingleReadOperation ( uint8_t slaveAddr, uint8_t regAddr, uint8_t buf)

{

    CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

    CyU3PI2cPreamble_t preamble;

    preamble.buffer[0] = slaveAddr;

    preamble.buffer[1] = regAddr;

    preamble.buffer[2] = slaveAddr | 0x1;

    preamble.length    = 3;

    preamble.ctrlMask  = 0x0002;              /*  Send start bit after 2nd byte (buffer[1]) of preamble. */            

    apiRetStatus = CyU3PI2cReceiveBytes (&preamble, buf, 1, 0);

    SensorI2CAccessDelay (apiRetStatus);

    return apiRetStatus;

}

上記のコード例を参考に動作するか試していただければと思います。

よろしくお願い致します。

Hirotaka Takayama

元の投稿で解決策を見る

5 返答(返信)