The Imp API doc says that hardware.configure(const) should not be needed:
This was removed in release-5. Configuring a peripheral now configures the pins, there is no need to use hardware.configure() first.
But this seems not to be true, without it my setup doesn’t work. This is how I configure:
hardware.spi257.configure(SIMPLEX_TX, 15000); // Datasheet says max 25MHz hardware.pin5.configure(DIGITAL_OUT); hardware.configure(SPI_257); // <-- Doesn't work without this line
Am I doing things wrong or is the documentation to blame?
And… ew, how to you attach code to this forum so it looks nice?
You are configuring pin5 multiple times and changing your SPI port.
The first call - hardware.spi257.configure(SIMPLEX_TX, 15000) - configures pin5 as SCLK for SPI.
Your next call - hardware.pin5.configure(DIGITAL_OUT); - configures pin5 as a digital out and effectively breaks the SPI clock.
The last call is depricated, but still works. hardware.configure(SPI_257); reconfigures the SPI port and all is right with the world again.
if you stick to the single line of code - hardware.spi257.configure(SIMPLEX_TX, 15000); - then everything should work as expected for SPI.
Dang, shouldn’t copy-paste when programming. Changed to your recommendation but it still didn’t work. Turns out that the 15 MHz clock was too fast for the LED Strip even though WS2810 should handle up to 25 MHz. I adjusted to 5 MHz and then everything runs smoothly with only one line of configuration.
Thank’s for pointing in the right direction, the hardware.config() call wasn’t necessary, but it reconfigured to a lower speed that the strip handled.
Would be interesting to know what the default clock speed is.
Without a clock specified it configures the lowest possible rate, which I believe is about 250kHz?