2025-01-02 07:51 PM
I have to read a 20-bit SSI signal. I connected it to a SPI interface as a “Receive Only Slave”.
It appears that the SPI interface is limited to 16-bits.
We could live with the first 16-bits of a 20-bit word. Can the SPI receiver do that?
2025-01-02 09:02 PM
> We could live with the first 16-bits of a 20-bit word. Can the SPI receiver do that?
Yes, it could.
A better solution would be to use a 10-bit word size and read two of them. That gets you all 20 bits.
2025-01-03 07:53 PM
Yes, the SPI config should be able to set 4bit... 32bit word size: for instance: set 4bit and wait for 4 words (or as TDK has mentioned (2x10bit, I am not sure if 10bits is possible or just 4,8,12,16,...?).
You might be able to configure also 16bit as word size and receive one "complete" word. The problem is just: you will get 4 additional bits afterwards (nSS is still active, the SPI Slave still receiving). Even you could check that one word (16bits) was received - the next cycle is not really completed. And no idea what what happens if the SPI Receiver remains in an incomplete state: it will potentially not start again to receive a new word (unless you reset it and start it again.
Best is really to check if you can figure as "N times Xbits_as_word" (to make sure the entire transaction would be complete as 2x10 or 5x4, .....).
2025-01-04 10:09 AM
2025-01-04 11:08 AM
It looks like the STM32L496’s SPI RX FIFO is either 8-bit or 16-bit.
Would you expect this to capture the above waveform:
hspi3.Init.DataSize = SPI_DATASIZE_10BIT;
...
uint16_t buf[2];
HAL_SPI_Receive(&hspi3, (uint8_t*)buf, 2, 1000);
2025-01-04 02:03 PM
> Would you expect this to capture the above waveform:
Yes. Note that the call needs to happen before data is sent. And it will time out after 1 second.
You will have to reconstruct the 20-bit word from two 10-bit words each stored as a uint16_t. Lower 10 bits of each uint16_t will have half of the data.