PSoC4100SP:I2CMaster Write Program

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

cross mob
RyYo_1406951
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Below, the same sentences are written in English and Japanese.

・English
Please tell me how to use API "SCB_I2CMasterWriteBuf".
The component data sheet has the following usage example of "SCB_I2CMasterWriteBuf".

・Japanese(日本語)
API"SCB_I2CMasterWriteBuf"の使用方法について教えてください。
"SCB_I2CMasterWriteBuf"の使用例として、コンポネントデータシート以下のような記載あります。

図1.png

・English
Is the program in red frame correct in the process of clearing and confirming the status of I2C?
Is the program in red frame required when using "SCB_I2CMasterWriteBuf"?
If not required, I am considering deleting it.

・Japanese(日本語)
赤枠内のプログラムは、I2Cのステータスのクリア・確認処理で間違いないでしょうか?
赤枠内のプログラムは、"SCB_I2CMasterWriteBuf"使用する上で必須でしょうか?
必須でない場合、削除を検討しています。

Regards,

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

こんにちは、

In the document it suggests to use SCB_I2CMaserWriteBuf() when you want to let I2C work background.

Then it suggests you to check the status to make sure the operation is complete,

but doing the check just after the SCB_I2CMasterWriteBuf() loses the big merit of using this function.

So I suppose this is only showing "how" to check status and not how to use SCB_I2CMasterWriteBuf().

In the document it writes "the SCB_I2CMaserStatus() function can be used to ..."

このドキュメントによると SCB_I2CMasterWriteBuf() に書込みたいデータを与えて置けば、

他のマスターとのアービトレーション等も含めて送信処理をバックグラウンドでやってくれると書かれていると思います。

その為、プログラムはすぐに他の処理に移れるのですが、

どこかでその関数(SCB_I2CMasterWriteBuf()) が正常に終了したかを確認する方法の例として

以降の for ループによるチェックが書かれていると考えます。

実際に SCB_I2CMasterWriteBuf() の直後で転送待ちを行ってしまうと、

この関数を使うメリットの大きな部分が失われてしまうと思います。

ドキュメントでは、"SCB_I2CMasterStatus() を使用して転送の結果を調べることができます"

といった意味の記載になっています。

> ・English
> Is the program in red frame correct in the process of clearing and confirming the status of I2C?

I think so.

FYI, the for loop is just waiting for the completion, it does not take care of any other error condition so in the worst case the program will block here.


> Is the program in red frame required when using "SCB_I2CMasterWriteBuf"?
> If not required, I am considering deleting it.

As I wrote above, I think that you can delete it from here,

but checking the status before the next transaction is recommended.

> ・Japanese(日本語)
> 赤枠内のプログラムは、I2Cのステータスのクリア・確認処理で間違いないでしょうか?

私も同じ理解です。

あえて言えば for ループは終了待ち処理で、エラー等に対してはなにも処理をしていないので

最悪の場合、プログラムはここでロックします。


> 赤枠内のプログラムは、"SCB_I2CMasterWriteBuf"使用する上で必須でしょうか?
> 必須でない場合、削除を検討しています。

この場所から削除するのは問題ないと思いますが、

次の転送を行う前には、ステータスのチェックを行うことをお勧めします。

moto

View solution in original post

3 Replies
ShanmathiN_06
Employee
Employee
100 replies posted 50 replies posted 25 replies posted

Hi,

You can refer to CE222306 I2C_SCB_Master, by navigating to PSoC Creator-> File-> Code example.

In your firmware, you also need to check if there is no error by checking the return flag of SCB_I2CMasterWriteBuf API.

Thanks,
Shanmathi

0 Likes

Thank you for your answer.

I check Sample.

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

こんにちは、

In the document it suggests to use SCB_I2CMaserWriteBuf() when you want to let I2C work background.

Then it suggests you to check the status to make sure the operation is complete,

but doing the check just after the SCB_I2CMasterWriteBuf() loses the big merit of using this function.

So I suppose this is only showing "how" to check status and not how to use SCB_I2CMasterWriteBuf().

In the document it writes "the SCB_I2CMaserStatus() function can be used to ..."

このドキュメントによると SCB_I2CMasterWriteBuf() に書込みたいデータを与えて置けば、

他のマスターとのアービトレーション等も含めて送信処理をバックグラウンドでやってくれると書かれていると思います。

その為、プログラムはすぐに他の処理に移れるのですが、

どこかでその関数(SCB_I2CMasterWriteBuf()) が正常に終了したかを確認する方法の例として

以降の for ループによるチェックが書かれていると考えます。

実際に SCB_I2CMasterWriteBuf() の直後で転送待ちを行ってしまうと、

この関数を使うメリットの大きな部分が失われてしまうと思います。

ドキュメントでは、"SCB_I2CMasterStatus() を使用して転送の結果を調べることができます"

といった意味の記載になっています。

> ・English
> Is the program in red frame correct in the process of clearing and confirming the status of I2C?

I think so.

FYI, the for loop is just waiting for the completion, it does not take care of any other error condition so in the worst case the program will block here.


> Is the program in red frame required when using "SCB_I2CMasterWriteBuf"?
> If not required, I am considering deleting it.

As I wrote above, I think that you can delete it from here,

but checking the status before the next transaction is recommended.

> ・Japanese(日本語)
> 赤枠内のプログラムは、I2Cのステータスのクリア・確認処理で間違いないでしょうか?

私も同じ理解です。

あえて言えば for ループは終了待ち処理で、エラー等に対してはなにも処理をしていないので

最悪の場合、プログラムはここでロックします。


> 赤枠内のプログラムは、"SCB_I2CMasterWriteBuf"使用する上で必須でしょうか?
> 必須でない場合、削除を検討しています。

この場所から削除するのは問題ないと思いますが、

次の転送を行う前には、ステータスのチェックを行うことをお勧めします。

moto