Re: Using STM32F103C8T6 PWM pin to drive ws2812b Neopixel Ring in arduino IDE
Posted: Mon Jun 15, 2020 12:11 pm
Exchange SPI1 with SPI2: connect NRF to SPI2 and WS to SPI1.
Everything relating to using STM32 boards with the Arduino IDE and alternatives
https://www.stm32duino.com/
Due to the unusual way SPI is used by the WS2812B library, the maximum speed would be 6MHz (and 12MHz on SPI1), but the LEDs are nowhere near as fast as that, and there is no problem using SPI2 provided the correct divisor is set.stevestrong wrote: Mon Jun 15, 2020 6:53 am As I mentioned above, on SP2 you can only get max 18MHz, that is why the pulses are twice as long.
I tried now using the ST core and the Adafruit library. I think that depending on exactly what LEDs you have, that also might not just work straight out of the box. Compared to the SPI method, I can see definite variation in the timing of the pulses generated by their bit-banging. In particular the timing of the "1" pulses could perhaps cause the opposite problem to what you got with the SPI technique originally - maybe all the bits could be interpreted as "0", resulting in none of the LEDs ever lighting up at all.Jakub_Szubzda wrote: Mon Jun 15, 2020 10:04 amI don't really know what's wrong with it, but no matter what i try to do it just doesn seem to light leds.ozcar wrote: Sat Jun 13, 2020 7:24 pm What problem did you have with the ST core and the Adafruit library? fpiSTM said it works, but I have not tried it.
Code: Select all
void setup()
{
SPI.setModule(2); //SPI2 uses PB15 instead of PA7 for MOSI
strip.begin();// Sets up the SPI
strip.show();// Clears the strip, as by default the strip data is set to all LED's off.
strip.setBrightness(128); // 0 to 255
SPI.setClockDivider(SPI_CLOCK_DIV16); //halve the reported clock speed to fix all-white issue.
}