Send and receive multiple bytes through I2C

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Send and receive multiple bytes through I2C

932件の閲覧回数
AsierMaser
Contributor II

Hi all,

I was wondering if there is any way of sending and receiving multiple bytes through I2C. I see that the I2c_SyncTransmit block has a buffer size input, so I guess it is possible, but the Data Rx output is a uint8 variable. In case I want to receive 8 bytes, am I supposed to build a buffer of eight uint8? If this is the case, how do I know when to increase the position of the FIFO?

I also have a similar question with transmission. Data Tx in a uint8 input, so I can't send the eight bytes concatenated. How should a I send the data then?

Thanks in advance,

BR

0 件の賞賛
返信
2 返答(返信)

839件の閲覧回数
CristinaB
NXP Employee
NXP Employee

 

Hello @AsierMaser,

 

Yes, it is possible to send and receive multiple bytes using the I2C block. The Data Rx output and Data Tx input can be Data Store memory blocks containing vectors of uint8 data types, as you can see in the image below.

If you want to send multiple bytes from the master, you can simply create a Data Store Memory block containing the bytes and give it as an input (Data Tx) for the block, using the Data Store Read block.

If you want to request multiple bytes from the slave, you must specify the number of bytes in the Buffer Size block input, create a Data Store Memory block with the same size as the number of bytes, and provide it as an output for the block using the Data Store Write block.

 
 

Data Store MemoryData Store Memory

Hope this helps,

Cristina

0 件の賞賛
返信

864件の閲覧回数
AsierMaser
Contributor II
UP
0 件の賞賛
返信