zephyr icon indicating copy to clipboard operation
zephyr copied to clipboard

led_strip: ws2812: led strip does misinterpret the logic level that was set during boot as data bits

Open IVandeVeire opened this issue 2 years ago • 7 comments

I was asked to create an issue regarding this pr: https://github.com/zephyrproject-rtos/zephyr/pull/66311

I'm developing an application that uses the ws2812 spi driver to control SK6812-EC3210F addressable leds. I'm using a custom mimx-rt1064 board.

I experienced some weird boot behavior of the leds. When the device boots, the bus level of the mosi line get to logic high for certain amout of time before sending the first data on the bus. Because the data bits are directly sent after the boot sequence, the leds do misinterpret the logic level that was set during boot as data bits.

From my understanding, the mosi line keeps the last level that was assigned on the bus when the spi block gets idle. I'm aware that this may be soc specific behaviour.

To prevent the led strip from misinterpreting the logic level that was set during boot as data bits, I added a reset after the initialization of the ws2812 driver (as in https://github.com/zephyrproject-rtos/zephyr/pull/66311 ). I made some captures (of the mosi line) using a logic analyzer to clarify the issue.

Device boot without fix: not_fixed

Device boot without fix (detailled): not_fixed_detail

Device boot without delay and reset at init: fixed

IVandeVeire avatar Dec 11 '23 09:12 IVandeVeire

@IVandeVeire IIUC the MOSI signal on your mimx-rt1064 board is idle hiigh at reset and becomes (and stays) idle low after setting it low ?

simonguinot avatar Dec 11 '23 10:12 simonguinot

@IVandeVeire IIUC the MOSI signal on your mimx-rt1064 board is idle hiigh at reset and becomes (and stays) idle low after setting it low ?

Indeed

IVandeVeire avatar Dec 11 '23 10:12 IVandeVeire

@IVandeVeire did you look at the pinmux configuration on the i.MX RT1064 MCU ? Maybe it is possible to configure the initial state of the MOSI pin ?

simonguinot avatar Dec 11 '23 10:12 simonguinot

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

github-actions[bot] avatar Feb 11 '24 00:02 github-actions[bot]

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

github-actions[bot] avatar Apr 13 '24 00:04 github-actions[bot]

I think this is probably an LPSPI related issue, maybe it needs some kind of command word in initialization, I don't know a reason why miso would be high after reset, is it doing some spi transfers during reset? It could be that the transfer stalled, because by default we stall the transfer during a frame if it is not complete instead of giving a fifo underrun error. If there is some transfers happening during reset for the LEDs, maybe the data frame size was set incorrectly.

decsny avatar Jun 25 '24 16:06 decsny

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

github-actions[bot] avatar Aug 25 '24 00:08 github-actions[bot]

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

github-actions[bot] avatar Oct 28 '24 00:10 github-actions[bot]

@IVandeVeire , can you try this with the latest main

mmahadevan108 avatar Oct 28 '24 16:10 mmahadevan108

@IVandeVeire , can you try this with the latest main

Just checked, the issue is still present on afce5329f772a4306af699c7a06efddf93cadca0 (latest main)

IVandeVeire avatar Oct 29 '24 09:10 IVandeVeire

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

github-actions[bot] avatar Jan 08 '25 00:01 github-actions[bot]

@IVandeVeire There is a configuration on the LPSPI IP to either have the output retain the last value when PCS negated or to have it tristated. The default is the retained (not tristated). I'm not sure why is the value high at first on the mosi line, but maybe having it tristated will have a different effect for this use case. I can make a PR to add a DT property to change this configuration to see if it helps.

decsny avatar Jan 16 '25 17:01 decsny

aforementioned PR for tristate configuration is here: #84109

decsny avatar Jan 16 '25 17:01 decsny

@decsny I am a colleague of @IVandeVeire and tested your suggested solution. It seems to fix the issue we had.

allemanm avatar Jan 17 '25 12:01 allemanm

@decsny I am a colleague of @IVandeVeire and tested your suggested solution. It seems to fix the issue we had.

That's great! I'll work on getting that PR merged. Sorry this issue took so long to figure out, I was not familiar with lpspi until having the opportunity to be working on it recently

decsny avatar Jan 17 '25 12:01 decsny