spi_mcux_lpspi - How can I ensure that the Chip Select line remains asserted for the entire transaction #81264
-
Hi, I've rebased my Zephyr codebase to include the latest fix by @decsny for the LPSPI driver (drivers: spi_mcux_lpspi: Fix DMA path on RT). However, I’m observing similar symptoms in both DMA and non-DMA modes, even when using the
SPI configured mode: Apart from an issue with the component on the MISO line (which I'm troubleshooting separately), I notice that the CS line does not remain asserted until the device completes its response. This issue occurs in both DMA and non-DMA modes, while I would expect CS to stay asserted for the entire transaction. Best Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 24 replies
-
Yes, the PR you linked was a hotfix so that the lpspi dma worked at all on RT, it effectively reverted the previous fix of the CS. Now that fix only applies to the MCXN, since that's actually the platform I was developing on when I made that fix. It turns out the lpspi on RT and MCX work significantly differently in regards to when the receiver writes to the RX fifo |
Beta Was this translation helpful? Give feedback.
-
Hi @ofirshe , As for workarounds, you have shared in the past that you had the LPSPI functional. Does reverting the driver back to that previous version work for you? Or, you are currently using a GPIO pin to control the chip select. Could you control that GPIO pin from your application instead of from the driver, and keep it asserted through the whole transfer? Best regards |
Beta Was this translation helpful? Give feedback.
-
Hi @ofirshe , Best regards |
Beta Was this translation helpful? Give feedback.
-
Using GPIO as @DerekSnell will solve the issue. |
Beta Was this translation helpful? Give feedback.
-
Hi @ofirshe and @tbursztyka , However, I get different results when testing this. With I tested with the attached project LPSPI_cs-gpio.zip, which uses your buffer configuration. I tested this with the latest Zephyr release v4.0.0, on the board When I remove And if I enable DMA with the hardware CS, CS gets an additional pulse. So my captures seem consistent with the known issues in the LPSPI driver, which NXP resolved on the MCX N platform, and is working to resolve on the RT platforms. @ofirshe , can you share captures showing the difference between |
Beta Was this translation helpful? Give feedback.
-
Hey @DerekSnell, My Zephyr is aligned with commit hash c50777a, which includes the most recent change to this driver (92d0287). I’m currently running in non-DMA mode (only Here’s what I’ve observed: When the buffer sizes are not equal, using the same code as in your example, the Chip Select (CS) is deasserted during the transaction. However, when the buffer sizes are equal, as in this example: GitHub Discussion Link, I get the expected behavior, with the CS remaining asserted. Let me know if you need further details or clarification. |
Beta Was this translation helpful? Give feedback.
-
Yes, @ofirshe But my request was for you to provide captures with and without using Cheers |
Beta Was this translation helpful? Give feedback.
-
@ofirshe , the To help clarify, here are details based on the LPSPI_cs-gpio.zip example I attached above. This example was written for the MIMXRT1170-EVK board using LPSPI1. Below is the overlay file to configure LPSPI1 to use the GPIO signal as the chip select with the
Next I modify the overlay to use the LPSPI hardware CS signal. Remove the
Next I replicate the setting I believe you were using, which is not configured properly for GPIO CS. The
|
Beta Was this translation helpful? Give feedback.
-
Hi @ofirshe , As you already know, the LPSPI driver has a known issue keeping the hardware chip select asserted through some transfers, which is tracked at spi_mcux_lpspi: inconsistent chip select behaviour. You can subscribe to that Issue to get updates on the progress. And in the meantime, you can move on using these workarounds. Best regards |
Beta Was this translation helpful? Give feedback.
@ofirshe , the
cs-gpios
property is not meaningless. That property configures the Zephyr SPI driver to drive a GPIO signal as the chip select, and also specifies which GPIO signal to drive. But you also need to configure the pinmux setting in the pinctrl node. In your case, the MIMXRT1060-EVK board configures theiomuxc_gpio_sd_b0_01_lpspi1_pcs0
pinmux option for that pin. You are trying to use that same pin, but configure it as GPIO signal instead of the SPI hardware CS signal.To help clarify, here are details based on the LPSPI_cs-gpio.zip example I attached above. This example was written for the MIMXRT1170-EVK board using LPSPI1. Below is the overlay file to configure LPSPI1 to use t…