2025-01-27 07:06 AM
Hello,
we have now a bit peculiar problem. In our device, there is a main board and daughter boards connected by SPI bus. All MCUs are STM32F401. The main board works as SPI master, the daughter boards work as SPI slave, with DMA in both cases. The SPI is used in half-duplex-like mode, so when the masters transmits, the slave is silent and vice versa.
Transmitting from the master works fine. The slave receives also without errors, but when it start transmitting back to the master, it sends three erroneous bytes on the beginning. After this, the correct data are transmitted OK except the last three bytes which are left out. The first two bytes are always 0xFF, the third changes but with no discernible pattern. Moving buffers in memory does not help.
Note that we don't use HAL, all programming is directly to bare metal.
2025-01-27 12:18 PM
Either the peripheral isn't initialized yet or you're feeding it bad data to start. Note that the data needs to be sent to the SPI slave before the master starts clocking.
Send a dummy transfer on the master side to ensure pins are configured in SPI mode.
> half-duplex-like
Actual half-duplex mode or full-duplex mode and ignoring MOSI/MISO when not relevant. Using full duplex mode is generally more user friendly.