String through SPI in MBDT

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

String through SPI in MBDT

813件の閲覧回数
avinashstarkenn
Contributor III

Hello,

I am using S32k344 with MBDT.

I am able to send numerical value using SPI blocks.

But how send and receive strings like 'Hello' using SPI.

I am using example 'SPI Master Asynchronous Interrupt Transfer S32CT'

Please can you explain using images.

0 件の賞賛
返信
1 返信

778件の閲覧回数
Irina_Costachescu
NXP Employee
NXP Employee

Hi @avinashstarkenn 

If you were able to validate your numerical data transmission, there should be no issues when trying to send strings via SPI. You can see a string as an array of uint8 elements, since each character can be represented numerically on 8 bits. The Spi_SetupEB function is the one that sets up the data to be transmitted for the selected Channel and it expects a buffer of uint8 elements as its input.

Hence, for transmitting the "hello" string via SPI you could use a Simulink Constant block with the Value parameter set to uint8('hello') and feed it to the Source Buffer input of the block, like illustrated in the image below.

Irina_Costachescu_1-1697734333372.png

If we setup the transmission buffer in this way, after deploying the application on target, you could connect a logic analyzer device to the target board on the pins of the instance corresponding to Channel0 used in the model, and you should see the "hello" string on the MOSI line. (I have used Channel0 for this, which is associated to the LPSPI2 Master Instance, as described by the configuration project associated to the model modelName_Config.mex file).

Irina_Costachescu_2-1697734536410.png

 

Please let us know if this is the use case that you are interested in or if more details are required from our side.

Thank you,
Irina

0 件の賞賛
返信