Creating bit stream for SPI devices

3 views (last 30 days)
Mpathan
Mpathan on 26 Oct 2021
Edited: Venkatesh Chilapur on 27 Oct 2021
Device: Ti C2000 F2837xD Microcontroller
I'm working on controlling my device via SPI. I'm wokring on creating a model where I can output a sine wave from DAC channel 0.
To do this I need to:
Command Address Command Payload
0011 0000 sinewave date [16 data bits]
I have been trying to create my stream of data as shown below. Would this be an adequate method to creating data streams to control devices via spi ? Can i use the pack block to create a 24 bit stream ?

Answers (1)

Venkatesh Chilapur
Venkatesh Chilapur on 27 Oct 2021
Edited: Venkatesh Chilapur on 27 Oct 2021
Hi,
Please refer the shipping example - c28x_spi_eeprom/Write EEPROM Data which will provide a very good overview on how you can setup the data for transmission using the SPI Master Transfer block. Command and Adress for command can be provided in the block mask of the SPI Master Transfer block under Register address field.
Also Note: If you select the STE pin provided by the SPI peripheral in Configuration Parameters, the slave is deselected between data transfers. In this case, the Explicit GPIO calls option must be used to set Slave select pin to ensure that the slave is selected continuously for multiple data transfers.
For additional queries please connect directly to MathWorks' tech support.
Regards,
Venkatesh C

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!