Skip to content

stm32g0b1: spi: MOSI signal goes high before and after transmitting data #38683

@simonguinot

Description

@simonguinot

I noticed this issue while using the ws2812_spi LED strip driver on a nucleo_g0b1re board.

The led_ws2812 sample can be used to reproduce the issue. This patch is needed to add support for the nucleo_g0b1re board to the led_ws2812 sample.

When running this sample, then the MOSI signal goes high for 80 microseconds before and after transmitting data:

stm32g0b1-spi1-mosi-high-before-after-transmission

stm32g0b1-spi1-mosi-high-zoom

The issue is that this high "preamble" state is interpreted as a high bit by the first WS2812 LED of the strip. And then the signal of all the LEDs is shifted by one bit, which results in visual glitches.

Note that from a SPI protocol standpoint, the MOSI signal is correct because the clock signal is off during this extra "high" states. Thus, this won't affect a real SPI device. But the WS2812 strip LED controller is not a SPI device. It doesn't use the clock signal. SPI is used here as a hack on a single wire (MOSI) to generate a control signal for the LEDs.

In addition, the issue is not systematic. It depends on the last data sent over MOSI. If the last 4 bytes are zero, then there are no high "preamble" state when sending the next buffer of data.

I also tried disabling DMA and interrupts but this doesn't affect the issue.

Metadata

Metadata

Assignees

Labels

EnhancementChanges/Updates/Additions to existing featuresarea: APIChanges to public APIsarea: LEDLabel to identify LED subsystemarea: SPISPI bus

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions