Skip to main content
NEdom.1
Associate III
February 24, 2026
Solved

Problems reading SSI encoder devices using SPI Master RX only on STM32F405RGTx

  • February 24, 2026
  • 2 replies
  • 163 views

I got an angle encoder with SSI interface, which is Synchronized Serial Interface. The output data is 21-bit. No CS signal is needed.

I have implemented using SPI1 master mode RX only reading this encoder, with SPI_CLK as the serial clock and SPI_MISO for data input. The data size to read is set to 3 bytes,  but the clock is transmitted one more byte as intended. HOW DID THIS HAPPEN? Does the SPI send a dummy address on receiving?

The clock is generated immediately upon calling 

__attribute__((aligned(4))) uint8_t raw_angle[16] = {0};

HAL_SPI_Receive_IT(&hspi1, raw_angle, 3);

The data captured by logic analyzer:

NEdom1_0-1771933127367.png

The CubeMX setting is as below:

NEdom1_1-1771933279977.png

 

I found that SPI_SR_RXNE is left triggered after 3 bytes read by the HAL API, so I have to clear the flag before calling HAL_SPI_Receive_IT. 

while((SPI1->SR & SPI_SR_RXNE)){
	SPI1->DR;
}
HAL_SPI_Receive_IT(&hspi1, raw_angle, 3);

 

I have also tried DMA mode using HAL_SPI_Receive_DMA(&hspi1, raw_angle, 4) , but no luck of success. The DMA hits HAL_SPI_ERROR_FLAG error.  The CubeMX setting is as below:

 
 

NEdom1_5-1771934758899.png

It is said that it's bad practice using DMA for small amount of data, but I still want to know how to get it work. Anyone could help? Thanks a lot.

 

 

 

 

Best answer by TDK

SPI RX only mode generates clocks automatically. Use two-way mode if you need a specific number of bytes to be read. MOSI does not need hooked up.

2 replies

Technical Moderator
February 24, 2026
"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Saket_Om"
TDK
TDKBest answer
Super User
February 24, 2026

SPI RX only mode generates clocks automatically. Use two-way mode if you need a specific number of bytes to be read. MOSI does not need hooked up.

"If you feel a post has answered your question, please click ""Accept as Solution""."