FastLed bitbang not working (while on SPI HW pins)

Status
Not open for further replies.

MolsonB

Active member
I'm having troubles with FastLed using bit bang. The lights go haywire on software SPI flag.
Code:
#define FASTLED_FORCE_SOFTWARE_SPI    //Ethernet gets the hardware pins
#define FASTLED_INTERNAL              //Removes compiler pragma msgs
#include <FastLED.h>

I designed my board with the LEDs (APA102) on pin 11 & 13. Since being made, I now want to add an Ethernet W5500. I couldn't find a way for the Ethernet library to use SPI1 instead of SPI0, so the LEDs need to be switched to software bitbang and use the alternative hardware SPI0 pins for the Ethernet.

The LEDs still looks like they are getting the clock speeds & data from the Ethernet spi as the LEDs are going nuts, while the Ethernet connects fine to host. I remove the flag, and LEDs work normal, but the Ethernet can't connect.

Can Ethernet use SPI1, SPI2??
When using alternate hardware SPI0 pins, does that free up the default ones?

-Matt
 
Teensyduino is 1.41 and FastLed is 3.1.8
Ethernet works great, so I removed it from the equation.

It has to do with clock speeds. Hardware SPI works at any speeds, but when you force it to use software, it doesn't like Teensy @ 168MHz & 180MHz. To work at those speeds, I had to slow down the LEDs to 4MHz @ 168MHz and 1MHz @ 180MHz. (I believe the default is 24MHz for Leds)


Code:
FastLED.addLeds<SK9822, DATA, CLOCK, BGR, DATA_RATE_MHZ(4)>(leds, NUM_LEDS);
 
Last edited:
Any chance you could post a short but complete program? I have only limited time to put into FastLED, and honestly I don't use FastLED much so I'm not familiar with its syntax. Just a short program which sends the same data repeatedly to a dozen LEDs would be fine. Something I quickly can copy and paste into Arduino and upload here onto a Teensy 3.6 and measure with my oscilloscope would really help me to dig into this problem sooner...
 
When Teensy 3.6 is set to (180MHz or 168MHz) and FastLED is on software SPI, I have to drop the FastLed datarate down to 4Mhz. If the Teensy is set to lower MHz, then the FastLed datarate doesn't need to be set. When on hardware SPI, everything works at any speed.

I'm not sure it's a bug, I just had to learn about changing the FastLed datarate's down, when the Teensy is blazingly fast.

Code:
#define FASTLED_FORCE_SOFTWARE_SPI
#include "FastLED.h"

#define NUM_LEDS 52
#define DATA_PIN 11
#define CLOCK_PIN 13

CRGB leds[NUM_LEDS];

void setup() { 
// FastLED.addLeds<SK9822, DATA_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS);      
  FastLED.addLeds<SK9822, DATA_PIN, CLOCK_PIN, BGR, DATA_RATE_MHZ(4)>(leds, NUM_LEDS);
  FastLED.setBrightness(128);
}

void loop() { 
  static uint8_t i = 0;
 
  leds[i] = CRGB::Blue;
  FastLED.show();
  delay(25);

  leds[i] = CRGB::Black;
  FastLED.show();

  i = (i+1) % NUM_LEDS;  
}
 
Status
Not open for further replies.
Back
Top