SPI pin floating

Is it intentional to leave MOSI pin floating when no data is transmitted?

I was playing with WS2812Bs, but could not figure out why I was getting random colors and random flashes in the very well defined lighting sequences. A floating MOSI pin in-between transmissions could very well explain it. Are there any other workarounds to this issue beside: [initialize SPI] -> [send data] -> [dispose SPI] -> [initialize OutputPort] -> [pull MOSI pin low] -> [dispose OutputPort] -> [initialize SPI] -> [send data] … Does not look elegant or efficient at all.

scope trace to confirm it? But in real terms, unless there’s an active SPI transaction (ie some chip’s CS pin is active) then stuff on the bus shouldn’t matter. WS2811/12 are really using SPI only as a clock generator so it’s not really a SPI problem, its a WS2811 problem…

Any chance that this could cause varying results between using USB power vs. wall-wart with the USB Client DP Module?

My Gadgeteer Christmas star decoration, which uses WS2811 strips, works just grand when I run it using the mini USB jack on the client DP module, but when I use the barrel jack with a 5v power brick, I get flashes of the wrong color (for example, in a pattern where the LEDs are supposed to be red and green, the colors flip to purple and gold).

I was wondering if it was a bad client DP module (a possibility, because testing with a different USB client DP module didn’t have the same problem, or at least had it much less frequently), or perhaps something in my code or wiring. Hard to get the wiring too far wrong with ground, 5v, and data in, though.

I can confirm that during transmissions MOSI pin works as push-pull and when transmission is over it becomes floating. At least on my G120 board.

I understand that WS2811/12 was not designed to be controlled by SPI and that we are using SPI just as a workaround. Unfortunately, we cannot explicitly specify MOSI pin state during non-transmission periods in NETMF :frowning:

Similar behavior was driving me crazy. You can do a small test: power your WS2811 strip from an USB port and while your code executing try touching 3V3 volts with one hand and MOSI pin with another. Report back the results :slight_smile:

If I power from USB, the color-changing issue never happens. Only happens for me when I try to power from the barrel jack.

With floating pins, everything is possible. Even touching the circuit will give a different outcome.

Shouldn’t a pull up/down resistor take care of the problem?

1 Like

It looks like it does. I have used 2K2 to the ground, just for reference.

I have had a fought about using a pull up resistor, but for some unknown reasons I have not tried it :-[

@ iamin - Just to clarify, are your strips 3-wire, or 4? My strips are 3 wire, 5v, GND, and data, so there isn’t a MOSI/MISO on the strip itself.

So is the floating pin on the mCu side?

@ devhammer - Yes, my strip also has 3 wires. If you use Nicolas’ lib to control your strip, you are using SPI to control it (MOSI pin only to be exact). When NETMF board is in the idle state (no data is transmitted over the SPI), it makes MOSI pin floating which in some cases causes your strip to receive pseudo commands that you have not actually sent. That’s why you get unexpected behavior.

@ iamin - OK, good to know. I’ll see if I can add a pull-down on the MOSI side and see if that fixes the color-changing issue I’m seeing.