xukangmin / TinyCore

TinyCore boards / attiny 1 series Core, Arduino IDE Core, targets ATtiny 417 / 814 / 816 / 817 / 1614 / 1616 / 1617 / 3217 and similar MCUs
https://tinycore.dev
MIT License
37 stars 10 forks source link

NeoPixels won't compile. #3

Closed PatchBOTS closed 3 years ago

PatchBOTS commented 4 years ago

Sketch won't compile with NeoPixels.

error "CPU SPEED NOT SUPPORTED"

loweb412 commented 4 years ago

I was able to get around this error. From what I could find, the problem is that ATTiny chips run at 20Mhz and the neopixels won't run at that frequency. You have to set it to 16Mhz to avoid that error. What I did was open the "Boards.txt" file for TinyCore (ArduinoData\packages\TinyCore\hardware\0.0.6). Copy the info on the boards and paste it at the bottom of the file. Change prefix to add "_16", so tiny16 ->tiny16_16. Then add 16Mhz to the name. So "TinyCore 16" to "TinyCore 16 16Mhz". After saving the boards.txt file, restart Arduino IDE. In the list of available boards, you will see the new listings with 16Mhz in the name. Select one of those when you have a project that uses NeoPixels. If you use this method, it in impact the serial baud rate. You have to adjust the baud rate that you want by multiplying it by 4/5.

Another way to fix this error is to change the Neopixel library to accept 20Mhz. https://forums.adafruit.com/viewtopic.php?f=47&t=51030

This won't impact the baud rate, but every time you update the Neopixel library, you have to remember to make the change again.

SpenceKonde commented 4 years ago

FYI, my megaTinyCore ( https://github.com/SpenceKonde/megaTinyCore ) provides a working neopixel library for all the tinyAVR 0-series and 1-series parts: tinyNeoPixel (it's directly compatible with neopixel library - just change the constructor call, see the examples); the core includes two versions of the library, one for 100% compatibility, and the other, that, with a few minor modifications, uses less flash, and lets you see the memory used for the frame buffer in the compile output (both because it eliminates the dynamic allocation of the memory for the frame buffer)