How to send 4 bit data from NI8452?
Mostrar comentarios más antiguos
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.
Respuestas (1)
Walter Roberson
el 18 de En. de 2026
0 votos
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.
4 comentarios
Pratik
el 19 de En. de 2026
Editada: Walter Roberson
el 19 de En. de 2026
Walter Roberson
el 19 de En. de 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 ?
Pratik
el 11 de Mzo. de 2026
Movida: Walter Roberson
el 11 de Mzo. de 2026
Walter Roberson
el 11 de Mzo. de 2026
data64 = uint64(Preamble) * 2^62 + uint64(Address)*2^52 + uint64(Word);
data8 = typecast(data64, 'uint8');
Now transmit data8. The individual parts of it are each 8 bit integers and so will have no problem with the SPI.
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!