How to send 4 bit data from NI8452?
Afficher commentaires plus anciens
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.
Réponses (1)
Walter Roberson
le 18 Jan 2026
0 votes
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 commentaires
Pratik
le 19 Jan 2026
Modifié(e) : Walter Roberson
le 19 Jan 2026
Walter Roberson
le 19 Jan 2026
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 ?
Catégories
En savoir plus sur Data Type Conversion dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!