Teensy 4.1 with FastLed, No Hardware SPI

AntiDysentery

New member
Hi there,

I'm running a teensy 4.1 with APA102 addressable LEDs, FastLed Library, and level shifters.
The problem is I cannot get FastLed to recognize pins 26 and 27 as Hardware SPI. Is this a PJRC issue or a FastLed issue??

300fps on pins 11 and 13 (MOSI, CLK) 15Mhz updates
90 fps on pins 26 and 27 (MOSI1, CLK1) bitbanged speeds

Thanks, I really need the speeds to be equal as they are running two sides of the same LED strip.
 
Here is my code:
Code:
#include "FastLED.h"

#define COLOR_ORDER GRB
#define NUM_LEDS 600
#define mhzz 10

void loop();
void setup();
void DrawTrace();

CRGB drawleds[NUM_LEDS];

void setup(){
  delay(500); // power-up safety delay
  Serial.begin(115200);
  while (!Serial){}
  Serial.println(F("\nTeensey 4.1 Activated"));
  
  //FastLED.addLeds<APA102, 11, 13, BGR, DATA_RATE_MHZ(mhzz)>(drawleds, 0, NUM_LEDS);
  FastLED.addLeds<APA102, 26, 27, BGR, DATA_RATE_MHZ(mhzz)>(drawleds, 0, NUM_LEDS);

  FastLED.setBrightness(30);
}

void loop()
{
  static uint32_t lastRandom;
  if ((millis() - lastRandom) > (10 * 1000))
  {
    Serial.println(FastLED.getFPS());
    lastRandom = millis();
  }
  DrawTrace();
  FastLED.show();
  FastLED.clear();
}

void DrawTrace()
{
  static int traceValue;
  static int traceNum;
  static bool reverse;

  (reverse) ? traceValue-- : traceValue++;
  //Serial.println(traceValue);
  if ((traceValue < 1) | (traceValue >= NUM_LEDS))
  {
    reverse = !reverse;
    (reverse) ? traceValue-- : traceValue++;
    traceNum = (traceNum + 1) % NUM_LEDS;
  }
  if (traceValue > NUM_LEDS) traceValue = NUM_LEDS;
  (reverse) ? drawleds[traceValue] = CRGB::Blue : drawleds[traceValue] = CRGB::Red;
  drawleds[traceNum].setHue((traceValue % 255));
}
 
Sorry, my C++ coding never really used a lot of templates and the like, and the FastLED library is using templates upon templates...

But my Quick look through it looked like it should support 26, 27 as SPI1... but hopefully someone else will see something...

in fastSPI.h
Code:
#elif defined(FASTLED_TEENSY4) && defined(ARM_HARDWARE_SPI)

template<uint32_t SPI_SPEED>
class SPIOutput<SPI_DATA, SPI_CLOCK, SPI_SPEED> : public Teesy4HardwareSPIOutput<SPI_DATA, SPI_CLOCK, SPI_SPEED, SPI, 0> {};

template<uint32_t SPI_SPEED>
class SPIOutput<SPI1_DATA, SPI_CLOCK, SPI_SPEED> : public Teesy4HardwareSPIOutput<SPI1_DATA, SPI1_CLOCK, SPI_SPEED, SPI1, 1> {};

template<uint32_t SPI_SPEED>
class SPIOutput<SPI2_DATA, SPI2_CLOCK, SPI_SPEED> : public Teesy4HardwareSPIOutput<SPI2_DATA, SPI2_CLOCK, SPI_SPEED, SPI2, 2> {};

and in fastpin_arm_mixrt1062.h we have:
Code:
#define HAS_HARDWARE_PIN_SUPPORT

#define ARM_HARDWARE_SPI
#define SPI_DATA 11
#define SPI_CLOCK 13

#define SPI1_DATA 26
#define SPI1_CLOCK 27

#define SPI2_DATA 35
#define SPI2_CLOCK 37
Note: the SPI2 pins are valid for T4, not T4.1... T4.1 does have SPI2 pins on (SD adapter and on bottom Memory chips pads).

Sorry not much help.

The only other thing I would check is what version of the library and Teensyduino/Arduino are you running.
 
SOLVED!!

line 87 in fastspi.h is definitly wrong. I'm not good with Git, but this worked for me.

Code:
template<uint32_t SPI_SPEED>
//class SPIOutput<SPI1_DATA, SPI_CLOCK, SPI_SPEED> : public Teensy4HardwareSPIOutput<SPI1_DATA, SPI1_CLOCK, SPI_SPEED, SPI1, 1> {};
class SPIOutput<SPI1_DATA, SPI1_CLOCK, SPI_SPEED> : public Teensy4HardwareSPIOutput<SPI1_DATA, SPI1_CLOCK, SPI_SPEED, SPI1, 1> {};
 
Thanks, I missed that in my quick check.

I will try to get a PR to FastLED... (or it PaulStoffregen) not sure which Fork is currently being included in the Teensyduino releases.

I did this as PR back to Paul: https://github.com/PaulStoffregen/FastLED/pull/1

As I believe that your Fork/Branch is the one in TD 1.57B3, at least it matches with WinDiff...

Note: the main fork FastLED is 60+ changes ahead of your fork.
 
Back
Top