How to send 4 bit data from NI8452?
13 views (last 30 days)
Show older comments
Hello,
I want to send (0xAFF adress + 48bits data) sequence over SPI using NI8452 from Matlab. The write function of SPI object sends unit8 data, which converts above data into (0x0AFF + 48bit data), which changes the functionality of the next connected device.
I looked for the CS pin accessibility from code, so that CS can be enabled after 4 CLK cycles. But, I dont find any control over CS pin in Matlab.
Please let me know how I can code to send (0xAFF adress + 48bits data) sequence.
0 Comments
Answers (1)
Walter Roberson
on 18 Jan 2026 at 3:36
https://www.mathworks.com/matlabcentral/answers/346770-data-truncation-to-4-word-lengths-when-using-the-spi-transmit-block-in-the-ti-c2000-support-package implies that the device works in 8 bit multiples,
https://www.mathworks.com/help/matlab/supportpkg/analog-input-using-spi.html implies that you pad out to byte multiples if the device uses something that is not a multiple of 8 bits.
2 Comments
Pratik
on 19 Jan 2026 at 11:12
Edited: Walter Roberson
on 19 Jan 2026 at 20:05
Walter Roberson
on 19 Jan 2026 at 20:11
You should be considering using
typecast(hex_seq, 'uint8')
However, the result will be 10 bytes, which is not going to fit the 64 bit buffer.
I do not understand the connection between "0xAFF address + 48bits data" and what you are constructing ?
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!