-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STM32 SPI Driver - Transmit (MOSI) Only - Infinite Loop on Tranceive #33169
Comments
@heinwessels in item 3 of the bug description : where do you intend to "Add this line LL_SPI_SetRxFIFOThreshold(spi, LL_SPI_RX_FIFO_TH_QUARTER);" |
@FRASTM for debugging purposes I think simply added it to |
This use case is like a SPI simplex mode: Actually, the drivers/spi/spi_ll_stm32.c is setting the full duplex by default. A possible solution could be to include the simplex mode there. |
I have tested SPI in transmit only. And I have not observed any issue on as mentioned. For the reference an commenting the test codes and my changes and target below. Target Used: NUCLEO_F767ZI Other file Modification I made as per the recommendation:
SPI:
Driver Code( spi_ll_stm32.c ):
Test app: (Code snip)
|
It confirms that without any valid Rx buffer, there is no need to loop on the RXNE : Tx-only mode. |
Fixed by #34731 |
@heinwessels, Here is my setup: I add nucleo_l476 overlay and conf file to the sample (see attached zip) Note : I did not add line It works even if I restrict dts spi to keep only sck and mosi.
Maybe your problem comes from the fact you remove SCK from DTS, is it what you did ? |
@ABOSTM thanks for the testing on your side. Yes, I did remove the What I did notice is that that it works fine with the DMA. I had the infinite loop issue when I wasn't using the DMA. It's then when I had to add the Later I moved to using the DMA for SPI and this solved my problems. I could remove the |
Thanks for your feedback.
It is not a problem with Zephyr but rather a problem of hardware : SPI is not supposed to work with only MOSI signal. |
I am trying to run the WS2812 LED Strip driver on an STM32L431 using the SPI mode. The SPI is used as
Transmit Only
, and only theMOSI
pin is connected and defined in the DTS. When the LED driver is writing to the LED's the SPI driver gets stuck in an infinite loop waiting for theRXNE
flag to be raised here.To Reproduce
Steps to reproduce the behavior:
MOSI
pin in the DTS.LL_SPI_SetRxFIFOThreshold(spi, LL_SPI_RX_FIFO_TH_QUARTER);
Or,
MOSI
pin in the DTS.LL_SPI_SetRxFIFOThreshold(spi, LL_SPI_RX_FIFO_TH_QUARTER);
west debug
RXNE
flag here.Expected behavior
I expect that if I use the SPI in transmit-only mode that it will not care about what happened on the MISO line (or lack thereof).
Possibly, instead of waiting for the
RXNE
flag when norx buffer
is supplied it could wait for!TXE
, like this:I tested this example and it works in this use case. It's not very invasive and shouldn't interfere in normal use cases either.
Another way around this would be to allow the STM32 SPI driver to have a simple
SPI_write
function that would only check for the!TXE
.It also works if I add the clock pin to the DTS, but this pin will be used for the debugger which means this is not a viable solution since it breaks the debugging connection.
Impact
Currently, an ugly hack is required to circumvent this problem which cannot remain in the final product.
Environment (please complete the following information):
Additional context
This is how the SPI is setup in the device tree:
The text was updated successfully, but these errors were encountered: