2021-09-26 10:35 AM
I am using the HAL SPI driver for the STM32F411 v 1.26.2.
I want to perform a FULL duplex transfer to a slave device using HAL_SPI_TransmitReceive() then do either a RX or TX half duplex transfer using HAL_SPI_Receive or HAL_SPI_Transmit. I currently have the code working but the receive performance is much slower than the tx performance. My logic analyzer shows vastly different byte to byte timing between the two half duplex calls. It appears that the HAL drivers have provisions for changing modes. Should I call HAL_SPI_INIT() between full duplex and half duplex functions? Or can I adjust the driver at a lower level?
2021-09-26 11:13 AM
The best solution is to use HAL_SPI_TransmitReceive for everything. Like it or not, there are signals on MOSI and MISO at all times even if you don't care about them.
The HAL driver can change modes if you deinit/reinit, but the hardware receive-only implementation is odd and can result in extra clocks and unexpected behavior, as it sounds like you've found out.
2021-09-26 12:02 PM
Always use full duplex. Turn miso as input pin to disable the output if needed. Some external spi slave sensors use 3 wire spi: short miso and mosi externally.
2021-09-27 05:15 AM
Is there an errata on this behavior?
2021-09-27 06:15 AM
Why would there be errata? It behaves as described in the RM.
2021-09-27 07:07 AM
you wrote " the hardware receive-only implementation is odd and can result in extra clocks and unexpected behavior, as it sounds like you've found out".
That sounds like a bug! I have checked the errata and there is no mention of this issue.
2021-09-27 07:17 AM