String through SPI in MBDT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

String through SPI in MBDT

807 Views
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 Kudos
Reply
1 Reply

772 Views
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 Kudos
Reply