I'm trying to use SPI to control some DotStar light strips and SPI does not seem to be working correctly. I'm running the example straight from the library in the Bela IDE. I get a good clock signal but the MOSI data line looks like a weak bad connection. Here's a scope picture.

I get the same result with two different Bela Minis's so I don't think this is a bad or damaged Bela. I tried adding a pinMode for that pin which is also a Bela Digital line #10. But setting it to Output completely eliminated the signal. Setting it to Input gives the same result as shown. (I think it's the default). Any ideas?

I just looked more carefully and I the MOSI line is not even showing the data. It is just a poor copy of the clock signal. The first two bytes are supposed to be 0xff and 0x22 but they just look like the clock. So the line is probably not getting any driving from the Bela and is just picking up the clock by stray capacitance. So the question still is, why no MOSI signal?

are you positive you are picking the correct pin? BelaMini Multichannel Audio has the silkscreen wrong for D10, in case you were using that as a reference.

Did you run these lines or at least the first and third ones?

config-pin P2.25 spi;
config-pin P2.27 spi;
config-pin P2.29 spi_sclk;
config-pin P2.31 spi_cs;

I suspect the first one was not run (or you are using the wrong pin) because setting pinMode in Bela shouldn't affect the pin's behaviour at all if the pin has been muxed to SPI.

Btw, once you get some signal on the MOSI line, you may want to try my attempt at DotStar here, which was not properly tested.

Thanks Giulio! You were right. I had run the config-pin lines earlier but in the meantime I had cycled the power and these config settings evidently are not saved. And thanks for your code, I'll take a look at it.

Is there a way to do this or a place to put commands like these that will get executed automatically on startup or when a particular program is run? I was hoping to have the programs I'm writing run automatically on startup but this issue will require a few commands to be run every time.

Thanks again for your great help.

    That looks like what I want, but where is PinmuxUtil defined? The compiler does not recognize it. I've tried including everything you did in that code and it still does not recognise the function. Is this a recent addition to one of the libraries?

    That solved it. Got a good SPI signal coming out. DotStar is not successfully reading it but I think that's because I am trying without level shifters. I'll get some and then maybe all will be well. Thanks again for your excellent help.