cancel
Showing results for 
Search instead for 
Did you mean: 

STM32's SPI tries to receive 32 bits of data per 1 NSS.

YHAN.1
Associate II

STM32 and IC are connected by SPI.

Tx is connected to SPI2, Rx is connected to SPI3, and communication is successful.

However, since the IC outputs 1NSS per 32bits, the first 16bits can be received, but the latter 16bits are not.

After receiving the first 16bits, the contents of the later 16bits cannot be received because it has not entered the DR.

Is there any setting or way to get this?

STM32's Rx Signal is shown below.

The SPI of STM32 Rx is set as follows.

 hspi3.Instance = SPI3;

 hspi3.Init.Mode = SPI_MODE_SLAVE;

 hspi3.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;

 hspi3.Init.DataSize = SPI_DATASIZE_16BIT;

 hspi3.Init.CLKPolarity = SPI_POLARITY_HIGH;

 hspi3.Init.CLKPhase = SPI_PHASE_2EDGE;

 hspi3.Init.NSS = SPI_NSS_HARD_INPUT;

 hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;

 hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;

 hspi3.Init.TIMode = SPI_TIMODE_ENABLE;

 hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;

 hspi3.Init.CRCPolynomial = 10;

0693W000003OaCmQAK.png

Thank you for your help.

5 REPLIES 5
S.Ma
Principal

Who can answer without knowing which of the 300+ part numbers of the portfolio is used? SPI has no TX or RX. Master, slave, MISO, MOSI,....

TDK
Guru

There aren't 32 bits after the NSS toggle. There's only 28. You need to send 4 more bits to get a multiple of 16.

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

> hspi3.Init.TIMode = SPI_TIMODE_ENABLE;

Is this intentional?

JW

Communication is made by setting the SPI Direction to TxOnly and RxOnly.

If TI Mode is Disable, data before NSS Toggle is read. So I set it to Enable. In the current setting, the first 16 bits are read normally.