Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 1 month ago.
How to implement of 32bit or 24bit SPI communication
Dear All,
I want to implement 24bit or 32bit SPI communication module for NUCLEO-767ZI. A SPI master is 767ZI and slave is a digital IC of adc. If you know the method, please tell me the way.
Thank you.
2 Answers
7 years, 1 month ago.
In case the device does not support 32 bit messages, but only 16 bits or 8 bits packets you have to split the data in one or more parts, For example:
int data; SPI spi(p5, p6, p7); // mosi, miso, sclk DigitalOut cs(p8); int main() ( data =0x12345678; // Chip must be deselected cs = 1; // Setup the spi for 16 bit data, high steady state clock, // second edge capture, with a 1MHz clock rate spi.format(16, 1); spi.frequency(1000000); // Select the device by setting chip select low cs =0 ; // Send spi.write ((data >> 16) & 0xFFFF); // MSB part first spi.write (data & 0xFFFF); // LSB part // Deselect the device cs =1 ; }
5 years, 9 months ago.
Hello,
Did you find any solution? I need to read an encoder SSI protocol. For me read 16 + 16 is not working due to timeout between executions. I only receive 2 times the same package due to timeout. I need full 32 pulses clock, not 16+16
Regards
SPI shouldn't care what the clock rate is or if it pauses, as long as the chip select stays low you should be able to put any pause you like in the middle of a transfer.
posted by 28 Mar 2019Hello,
Thanks for response, but the encoder is SSI protocolo and have this inconvenience:
https://www.rls.si/en/faq#Binary-synchronous-serial-output-SSI_15
so CLK period must be less than pause period, so the period pause between executions makes monoflop of encoder reset and send again the same information in the second execution.
The only way to work with the encoder is send and receive 32 clock signals without pausing.
Regards
posted by 28 Mar 2019