I have an issue with using HAL + SPI in Receive-only Master mode on F429 Discovery.
CubeMX Version is 4.15.0, Cube Lib Version is 1.12.0.
Toolchain is Atollic TrueSTUDIO v. 5.5.1 with GNU compiler.
I'm working with a fresh CubeMX project which just configures the SPI as follow for RX-only master operation:
After SPI initialization, a single call to
causes a read of 2 bytes (16 clock edges) instead of only one (see attached picture).
If you change the SPI Direction to "SPI_DIRECTION_2LINES" the same call works as expected (only 8 clock edges).
The same problem exists if I use the interrupt based receive function like:
HAL_SPI_Receive_IT(&hspi1, buf, 1);
This still transfers 2 bytes in SPI_DIRECTION_2LINES_RXONLY, and 1 byte in SPI_DIRECTION_2LINES.
But there seems to be another problem with using the interrupt based function together with SPI_DIRECTION_2LINES_RXONLY:
If you initiate a single transmission and put a breakpoint somewhere after that call, the SPI generates endless clock transactions and
keeps firing off OVERFLOW error interrupts:
(see second picture)
Even if you leave the debug mode and let the MCU running free, this won't stop. (Interrupts are handled by default HAL handler so the overflow flag will be cleared every time).
Same here: If you simply change the direction to SPI_DIRECTION_2LINES, everything works as expected.
So is this a HW bug or just a issue with the HAL? As a simple workaround, I configure SPI for RX/TX operation with SPI_DIRECTION_2LINES and don't use the MOSI line.