I'm currently trying to integrate FastLED into my AVR project.

I’m currently trying to integrate FastLED into my AVR project. The project uses an ATmega328P running at 8 Mhz @ 5v. It has a strand of 10 NeoPixels connected to PB7 along with a switch that’s connected to PB6. I’ve mapped PB6 and PB7 to Arduino pins 20 and 21.

I’ve modified fastpin_avr.h in FastLED with this mapping which allows the project to compile with pin 21 specified as the data pin. However, the NeoPixels act sporadically when I try to light them up. Only, the first 3 LEDs come up consistently. A 4th LED sometimes comes on and when it does it sometimes gets stuck on when I turn off the LEDs. The rest of the LEDs never turn on at all.

I’ve tested hardware setup and the LEDs with the Adafruit NeoPixel library and everything works as expected. The linked gist has the relevant source code modifications and test code.
https://gist.github.com/emed795/53ee4cf5000726c7b008#file-fastpin_avr-h-L77

What are you using to build? The asm code that FastLED uses is wildly more complex than the neopixel library, and as such is more sensitive to compilers screwing things up. I also have not done a whole lot of testing of the 328 at 8mhz.

Also, for laughs - what happens if you try on other pins?

FWIW, I think the Flora is 8MHz and we have at least one known case of that working correctly with FastLED (2.x).

Currently, I’m using the toolchain in Arduino 1.5.8 to build and upload to the ATmega328P using an Arduino ISP programmer. I’ll give trying the signal on different pin a shot though I’ll have to pull the signal line from the board and test using a spare ATmega328P on a bread board as the custom board I hacked together is currently hardwired to use PB7 as the data signal line.

1.5.8 on what OS - and any chance you know what version of avr-gcc is being used? (Linux often has a different version of GCC than the Windows/OS X versions)

I’m running on Windows 8.1 with Arduino 1.5.8. Looks the avr-gcc version that the Arduino uses is 4.8.3. I’ve done some more testing using the ATmega328P on a breadboard and it looks like the speed the chip is running at is the issue. Running the code on pin 6 at 8 Mhz causes the same issue but the same code running at 16 Mhz works fine.

Ok, sounds like I may have messed something up with the 8mhz code at some point then :confused: - I’ll try to take a look soon. (really hoping $DAYJOB gives me some free time soon, I’ve got multiple things I need to look at).

Sounds good. Guess I can start working on other aspects of my project. I’ve been putting off learning how to read sheet music… Anyway, do you want the issue logged on GitHub?

Sure - good way to track it, thank you!

Also, do you want a pull request for the PB6 and PB7 mappings for Arduino pins 20 and 21? They seem to be common mappings used when using those pins from the Arduino.