Firstly, I have tried to set the bootloader to be 8MHz internal oscillator.
I have tried the board setup from here - https://github.com/oshlab/Breadboard-Arduino.
And also the breadboard-1-6-x.zip
setup from here - http://www.arduino.cc/en/Tutorial/ArduinoToBreadboard.
Burning the bootloader in both cases seems to work, with fuse settings of -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xE2:m
(using Arduino IDE 1.6.7):
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: 1 bytes of efuse verified
...
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDA:
avrdude: load data hfuse data from input file 0xDA:
avrdude: 1 bytes of hfuse verified
...
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xE2:
avrdude: load data lfuse data from input file 0xE2:
avrdude: 1 bytes of lfuse verified
When I try and run the test sketch (below) at these voltages:
- 3.3V it fails (tried multiple 3.3V sources, all fail).
- 4.23V (3xAA rechargeable batteries) it works.
- 4.8V (3xAA alkaline batteries) it works.
- 5V it works.
To try and determine if it was my power sources or the bootloader that was the problem I uploaded this test sketch on my ATmega328P, an Arduino Nano (all Nanos are 16MHz?) and a 16MHz Arduino Pro to see if the red LED (with 100 Ohm resistor for ATmega328P) lights up in about the same time. This test sketch also does not work at 3.3V, and must be run at 5V to work.
(edit) When running this test sketch at 3.3V I see no 3.3V logic level on any output pin with my multimeter. When running at 4.23, 4.28, 5V I see this logic level on all output pins.
(update) When connecting the +ve of the LED directly to 3.3V, the LED lights up. So the 3.3V source has enough power to light the LED directly.
So I assumed that because my ATmega328P circuit has no crystal in it (and the Nano and Pro Mini are 16MHz), these loops would execute in different amounts of time? But no, the loops do execute at the same speed (3 and a bit seconds) - so is my Nano/Pro Mini underclocked, or my ATmega still running at 16MHz but without a crystal?? Rather confused.
Thanks.
(update) I tried a second ATmega328P, same problem.
(code edited to use 14 output pins)
void setup() {
for (int p=0; p<14; p++) pinMode(p, OUTPUT);
}
void loop() {
// waste some time.
int y = 0;
for (int i = 0; i < 11; i++) {
for (int j = 0; j < 11; j++) {
for (int k = 0; k < 101; k++) {
y+=analogRead(A0);
}
}
}
for (int p=0; p<14; p++) digitalWrite(p, y % 2);
for (int p=0; p<14; p++) digitalWrite(p, HIGH);
delay(1000);
for (int p=0; p<14; p++) digitalWrite(p, !(y % 2));
for (int p=0; p<14; p++) digitalWrite(p, LOW);
delay(1000);
}