Related with my old threads, I'm trying to set up ATMEGA328 at 8 MHz, in this way I could supply to ATMEGA328 with 3.3 V. I'm trying to make it by these lines:
CLKPR = (1 << CLKPCE); // Enable change of CLKPS bits
CLKPR = (1 << CLKPS0); // Set prescaler to 2, and system clock to 8 MHz
I'm using Arduino Uno board. Following ATMEGA328 datasheet, it should works fine, and if I try a simple code (blink) it works fine. But when I try a more complex WS2812B code, with these lines it doesn't work. My ATMEGA328 is assembled with 16 MHz crystal. I have tried Neopixel and FastLed libraries, the result is the same. Is to change the prescaler a good idea to get Arduino works at 8 MHz?
I have tried with 5 and 3.3 V (from Arduino Uno board).
I have tried too with clock_prescale_set(clock_div_2)
from <avr/power.h>
library. The result is the same.
When I say "it doesn't work" I mean I'm setting up with a red color and the LED color is white.
The test code I'm using:
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 6 // On Trinket or Gemma, suggest changing this to 1
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 1 // Popular NeoPixel ring size
// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#define DELAYVAL 500 // Time (in milliseconds) to pause between pixels
void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
clock_prescale_set(clock_div_2); //If I set clock_div_1 it works
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}
void loop() {
pixels.clear(); // Set all pixel colors to 'off'
pixels.setPixelColor(0, pixels.Color(200, 100, 0));
pixels.show(); // Send the updated pixel colors to the hardware.
delay(DELAYVAL); // Pause before next pass through loop
}