Adafruit_NeoPixel - works when compiled on one computer, not another

gatheround

Well-known member
I have a strange problem, my program that uses Adafruit_NeoPixel works when I compile it on one computer but not another. The target board is a Teensy LC.

Is there a difference between this library as found in the Arduino Libraries section and the one that comes shipped with the Teensyduino add-on maybe (if it's even part of that?). I checked that both versions are the same (1.5.0) on each computer, but maybe I'm missing something.

The one that doesn't work shows no data being sent out of the data pin on my scope, and no response from the neopixels.
 
Sorry sort of hard to know know what is going on.
The version I have installed through library manager shows: version of 1.8.2
The one in Teensyduino shows really old version: like 1.1.7...

So if it were me, I would update both computers to most recent Adafruit library either from github or Arduino library manager...

If you still have issues. More information might help, like which Arduino version, Which Teensyduini version...
And best yet source code that shows what is not working..

Good luck
 
Sorry sort of hard to know know what is going on.
The version I have installed through library manager shows: version of 1.8.2
The one in Teensyduino shows really old version: like 1.1.7...

So if it were me, I would update both computers to most recent Adafruit library either from github or Arduino library manager...

If you still have issues. More information might help, like which Arduino version, Which Teensyduini version...
And best yet source code that shows what is not working..

Good luck

Thanks KurtE,

I'm playing around on the "working" computer, and noticed that the neopixels work ONLY if the optimizing is set to:

Code:
Smallest Code
Smallest Code with LTO

I have a feeling that this was the issue, and I can verify tomorrow when I'm in front of my work computer. I guess the bigger question is why does the NeoPixel library only work on these optimizing settings?
 
Sorry I have not been doing much with the TLC for a long while... (
But if I were guessing, it would be that the build flags are messing up the embedded assembly language code
Code:
#elif defined(TEENSYDUINO) && defined(__MKL26Z64__) // Teensy-LC

#if F_CPU == 48000000
  uint8_t          *p   = pixels,
                    pix, count, dly,
                    bitmask = digitalPinToBitMask(pin);
  volatile uint8_t *reg = portSetRegister(pin);
  uint32_t          num = numBytes;
  asm volatile(
    "L%=_begin:"                      "\n\t"
     "ldrb  %[pix], [%[p], #0]"       "\n\t"
     "lsl   %[pix], #24"              "\n\t"
     "movs  %[count], #7"             "\n\t"
    "L%=_loop:"                       "\n\t"
     "lsl   %[pix], #1"               "\n\t"
     "bcs   L%=_loop_one"             "\n\t"
     "L%=_loop_zero:"                 "\n\t"
     "strb  %[bitmask], [%[reg], #0]" "\n\t"
     "movs  %[dly], #4"               "\n\t"
    "L%=_loop_delay_T0H:"             "\n\t"
     "sub   %[dly], #1"               "\n\t"
     "bne   L%=_loop_delay_T0H"       "\n\t"
     "strb  %[bitmask], [%[reg], #4]" "\n\t"
     "movs  %[dly], #13"              "\n\t"
    "L%=_loop_delay_T0L:"             "\n\t"
     "sub   %[dly], #1"               "\n\t"
     "bne   L%=_loop_delay_T0L"       "\n\t"
     "b     L%=_next"                 "\n\t"
    "L%=_loop_one:"                   "\n\t"
     "strb  %[bitmask], [%[reg], #0]" "\n\t"
     "movs  %[dly], #13"              "\n\t"
    "L%=_loop_delay_T1H:"             "\n\t"
     "sub   %[dly], #1"               "\n\t"
     "bne   L%=_loop_delay_T1H"       "\n\t"
     "strb  %[bitmask], [%[reg], #4]" "\n\t"
     "movs  %[dly], #4"               "\n\t"
    "L%=_loop_delay_T1L:"             "\n\t"
     "sub   %[dly], #1"               "\n\t"
     "bne   L%=_loop_delay_T1L"       "\n\t"
     "nop"                            "\n\t"
    "L%=_next:"                       "\n\t"
     "sub   %[count], #1"             "\n\t"
     "bne   L%=_loop"                 "\n\t"
     "lsl   %[pix], #1"               "\n\t"
     "bcs   L%=_last_one"             "\n\t"
    "L%=_last_zero:"                  "\n\t"
     "strb  %[bitmask], [%[reg], #0]" "\n\t"
     "movs  %[dly], #4"               "\n\t"
    "L%=_last_delay_T0H:"             "\n\t"
     "sub   %[dly], #1"               "\n\t"
     "bne   L%=_last_delay_T0H"       "\n\t"
     "strb  %[bitmask], [%[reg], #4]" "\n\t"
     "movs  %[dly], #10"              "\n\t"
    "L%=_last_delay_T0L:"             "\n\t"
     "sub   %[dly], #1"               "\n\t"
     "bne   L%=_last_delay_T0L"       "\n\t"
     "b     L%=_repeat"               "\n\t"
    "L%=_last_one:"                   "\n\t"
     "strb  %[bitmask], [%[reg], #0]" "\n\t"
     "movs  %[dly], #13"              "\n\t"
    "L%=_last_delay_T1H:"             "\n\t"
     "sub   %[dly], #1"               "\n\t"
     "bne   L%=_last_delay_T1H"       "\n\t"
     "strb  %[bitmask], [%[reg], #4]" "\n\t"
     "movs  %[dly], #1"               "\n\t"
    "L%=_last_delay_T1L:"             "\n\t"
     "sub   %[dly], #1"               "\n\t"
     "bne   L%=_last_delay_T1L"       "\n\t"
     "nop"                            "\n\t"
    "L%=_repeat:"                     "\n\t"
     "add   %[p], #1"                 "\n\t"
     "sub   %[num], #1"               "\n\t"
     "bne   L%=_begin"                "\n\t"
    "L%=_done:"                       "\n\t"
    : [p]       "+r"  (p),
      [pix]     "=&r" (pix),
      [count]   "=&r" (count),
      [dly]     "=&r" (dly),
      [num]     "+r"  (num)
    : [bitmask] "r"   (bitmask),
      [reg]     "r"   (reg)
  );
#else
#error "Sorry, only 48 MHz is supported, please set Tools > CPU Speed to 48 MHz"
#endif // F_CPU == 48000000
Looking up at github at the file in blame mode. Looks like most of this stuff was done by the github member PaintYourDragon
Not sure how much help I would be here...

Also note: In Paul's version of the library, this assembly code was done by him maybe 7 years ago... I have not compared the code to see if there any real differences in it:
https://github.com/PaulStoffregen/Adafruit_NeoPixel/blame/master/Adafruit_NeoPixel.cpp#L1118
 
Sorry I have not been doing much with the TLC for a long while... (
But if I were guessing, it would be that the build flags are messing up the embedded assembly language code
Looking up at github at the file in blame mode. Looks like most of this stuff was done by the github member PaintYourDragon
Not sure how much help I would be here...

Also note: In Paul's version of the library, this assembly code was done by him maybe 7 years ago... I have not compared the code to see if there any real differences in it:
https://github.com/PaulStoffregen/Adafruit_NeoPixel/blame/master/Adafruit_NeoPixel.cpp#L1118


Thanks for checking that KurtE, although I admit I really don't know what I'm looking at. Is this a potential error in the library itself? And is there any issues if I just keep compiling as "smallest code" so at least it works in the mean time?
 
Back
Top