Send 16-Bit Control signal through SPI

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

Send 16-Bit Control signal through SPI

Jump to solution
1,938 Views
fernando_barrio
Contributor III

Hi,

For our application a digital to analog converter is being used that requires a 16-Bit control signal, however the toolbox is only allowing me to send an 8-bit signal. Is there anyway around this?

Thank you in advance for your help,

Fernando

0 Kudos
Reply
1 Solution
1,743 Views
constantinrazva
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca‌,

The link to the 2nd picture is broken so I can not see it.

In your model I saw that you set the baud rate to 80MHz - that is not a valid value; the SPI will go up to 8MHz. You can take this example and see if it works (note that I change 1 pin from your configuration for easier testing; you can change it back to what you previously had). 

Here is the SPI running at 1MHz - you can edit the settings in the SPI Config block and make it run at 8MHz also.

pastedImage_1.png

Kind regards,

Razvan.

View solution in original post

4 Replies
1,743 Views
constantinrazva
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca‌,

Yes, you can send 16bit messages through SPI - select the Frame size to be 16 bits and use a data store memory with dimension minimum 2 uint8s. 

pastedImage_1.pngpastedImage_1.png

The transfer block sets the transfer width according to its input.

Note: the width of the data memory store should be multiple of 2 (because you've set 2bytes as the frame size).

I've attached a simple example here. Hope this helps.

Kind regards,

Razvan.

1,742 Views
fernando_barrio
Contributor III

Hi constantinrazvan.chivu‌,

I appreciate your model and help, unfortunately I could not get it working still only using C code. The following is the SPI timing specs;

pastedImage_1.png

And in C the configuration that worked was as follows (it was tested with both 8 and 16 bits); 

In Simulink I have it set up as follows with the memory block using uint8(2);

pastedImage_2.png

I believe these should be correct, I have tried various different configurations with the test file to get this to work on simulink with no luck.

Please let me know if you have any other suggestions.

Thank you,

Fernando

0 Kudos
Reply
1,744 Views
constantinrazva
NXP Employee
NXP Employee

Hello fernando.barrios@uwaterloo.ca‌,

The link to the 2nd picture is broken so I can not see it.

In your model I saw that you set the baud rate to 80MHz - that is not a valid value; the SPI will go up to 8MHz. You can take this example and see if it works (note that I change 1 pin from your configuration for easier testing; you can change it back to what you previously had). 

Here is the SPI running at 1MHz - you can edit the settings in the SPI Config block and make it run at 8MHz also.

pastedImage_1.png

Kind regards,

Razvan.

1,742 Views
fernando_barrio
Contributor III

It works great, thank you for all your help!

Have a good weekend,

Fernando

0 Kudos
Reply