2014-09-21 11:06 PM
Aim: Read 4 byte from MAX31855 (SPI readonly compatible) using SPI2 1wire bidirectional (using DMA)
Code: (attached) Note: SPI_CR1_BIDIMODE bit set SO->MOSI DMA Channel4->RX Channel5->TX (though garbage -- mandatory?) Expected: everything goes well and no error should occur in read. Actual: SPI_SR_OVR bit is set and SPI_SR_BSY loop is causing infinite loop(at ''while (SPI2_SR & SPI_SR_BSY);'' in DMA ISR) Another Try: clear the SPI_CR1_BIDIMODE bit and connect SO->MISO, everything goes well. (ie read from the slave using 2 wire unidirectional works) (STM32F072RBT6) #stm32 #halfduplex #spi #dma2014-09-24 02:32 AM
Did you have a look at the reference manual ''Procedure for disabling the SPI''?
2014-10-09 02:04 AM
Hi,
I really can't help since your writing a register access based code, no STM32 StdPeriphLib, no STM32Cube HAL... Sorry !Regards,Heisenberg.2014-10-09 08:00 AM
It is likely that in half-duplex rxonly mode, the TX is not required. Clock is generated as soon as SPE is set, and stops when SPE is cleared. The RM state this behaviour when SPI is configured in simplex communication (SO on MISO and RXONLY=1). I bet it behave similarly in your case (SO on MOSI and BIDIMODE set).
Reading the 'Procedure for disabling SPI' can help. As soon as the DMA filled its buffer, you can set SPE to 0. Note that at this moment the SPI will certainly be busy receiving an extra byte. When this extra byte is not desirable, set you DMA with 1 byte less in transfer length and receive the last byte manually.