Author Topic: Arduino Pro Micro + FastLED only works once after flash  (Read 951 times)

0 Members and 1 Guest are viewing this topic.

Offline NiHaoMikeTopic starter

  • Super Contributor
  • ***
  • Posts: 9018
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Arduino Pro Micro + FastLED only works once after flash
« on: December 11, 2018, 02:17:44 am »
I have a WS2812 strip controlled by an Arduino Pro Micro running the FastLED library, and I'm having a strange problem with it. Flash the Arduino and it works great. But power cycle it and it no longer works, with the output signal being lower in frequency by a factor of 8 or so. I tried another Arduino to make sure I didn't have a flaky one with defective Flash memory. I'm guessing some register is inadvertently left uninitialized and the bootloader, during flashing, sets it to a value that works, but the power on default doesn't.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline cv007

  • Frequent Contributor
  • **
  • Posts: 826
Re: Arduino Pro Micro + FastLED only works once after flash
« Reply #1 on: December 11, 2018, 03:10:40 am »
Quote
by a factor of 8
when you see this phrase with an atmel 8bit, think clock prescale. They typically ship with CKDIV8 fuse on, which means the clock prescale is set to 8 on powerup/reset. The bootloader (factory built-in or otherwise) will most certainly set the clock prescale to 1, and in this case it appears the bootloader just 'jumps' to the app when done programming as opposed to some some form of reset (leaving CLKPR as it was set in the bootloader- I'm not a big fan of when they just jump to apps after mucking up a bunch of registers).

in your code, clear the clock prescale to get 1:1
CLKPR = 0x80; //enable change
CLKPR = 0; //1:1

I would assume Arduino is supposed to do all this stuff for you, so there is probably some setting somewhere for this.

Anyway, that's one possibility.
 
The following users thanked this post: NiHaoMike

Offline NiHaoMikeTopic starter

  • Super Contributor
  • ***
  • Posts: 9018
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: Arduino Pro Micro + FastLED only works once after flash
« Reply #2 on: December 11, 2018, 04:12:57 am »
That fixed it. Maybe that's why the Arduinos were only $5 each (actually a bit less - forgot exactly how much) from Amazon?
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline Kilrah

  • Supporter
  • ****
  • Posts: 1852
  • Country: ch
Re: Arduino Pro Micro + FastLED only works once after flash
« Reply #3 on: December 11, 2018, 09:47:38 am »
No, has nothing to do with the hardware.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf