ATtiny85 clock multiplier in Arduinio IDE

I tacked two ws2812b "Neopixels" onto a homemade ATtiny85 programming shield and burned Adafruit's neopixel library and test program onto it.   It made a neat little holiday decoration.   And it ran on two NiMH AAA cells or a L-ion cell.   I decided to make a PCB.   It was a Covid project.

I hand wired a prototype to test my component choices.   Works great, except I forgot to wire one of the pushbuttons and the charger indications don't work as expected.

The PCB version was supposed to be identical.   The one difference, the ATtiny chip is in a surface mount package.   It's been months since I set up the prototype, so I tried burning a new program in it and everything still works the same.

The PCP version accepts an "upload" from the Arduino IDE and the sketch runs.  Reads its buttons and blinks its bright white LED.   But when it sends a message to the Neopixels, they turn bright white.   No matter what colors in the message.   

What could be going on?   The oscilloscope tells the answer.   On the prototype, ATtiny has been given 16MHz internal clock.   When it sends a string of 1's, I get a HIGH for about 260 ns and a LOW for about 990 ns.   That's within range of the nominal "800 KHz" ws2812b Neopixel.    But the PCB version puts out a  2000 ns HIGH and a 7920 ns LOW.   Eight times slower.   The clock multiplier in the surface mount ATtiny85 is wrong.

How to fix.   In the Arduino IDE, the clock multiplier fuses are programmed when you "burn bootloader"   To get the ATtiny85 running at the right speed, choose the clock option you want, burn a bootloader, and upload your sketch through an ISP programmer.

I have used Arduino as ISP and USBASP.   Fewer avrdude sync problems with the USBASP and they are very cheap.


Comments

Popular posts from this blog

RAID1 array for our home theater. LVM + md + ZFS or XFS

Software product web sites suck.