6

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);
}

4 Answers 4

4

If you are using an LED to indicate that your sketch is running, then that may be the problem.

For example, if you have a fairly average red LED, it might have a forward voltage of 2.0v @ 20ma (refer to your spec sheet for your particular LED). Putting these values into the LED calculator, it would tell you that you need a 150 ohm resistor. You might have tested this, and seen the LED light up.

Then, if you drop the voltage to 3.3v, your LED might be either very dim, or (more likely!) not light up at all. Putting 3.3v into the same web page, it shows you need a smaller resistor, 68 ohm, for the same LED.

P.S. - I just noticed your paragraph about the green LED - a "true green" LED might have a voltage drop of 3.3v, which means for 5v you would need a 100 ohm resistor (as described in your paragraph); for a 3.3v supply you would need a 1 ohm resistor instead. This is pretty certainly your problem

1
  • Thanks for your answer. I've swapped from green to red and see the same issue. I've also updated the sketch (qn edited) to use 14 digital pins (0..13) and don't see a 3.3V level on any of those pins, but I will see 5V.
    – Paul Grime
    Apr 18, 2016 at 6:42
4

It was a brownout fuse problem.

Changing boards.txt from:

atmega328bb.bootloader.extended_fuses=0x05

to

atmega328bb.bootloader.extended_fuses=0x02

solved it for me (*).

The chip and red LED now work at 3.01V (1xAA alkaline and 1xAA rechargeable) and 3.19V (2xAA alkaline).

(*) not sure why I had to invert the bits (0000 0010=0x02 versus 0000 0101=0x05) when compared to the tables below.


enter image description here enter image description here

3
  • Calculating those fuses by hand is error prone - I've already lost an AtMel chip to getting it wrong. engbedded.com/fusecalc will do the hard work for you. Apr 18, 2016 at 22:23
  • Yeah, thanks for the warning. Any idea why the default BOD value of 0x05 doesn't work for me and 0x02 does? Seems as though I have to flip the bits. If I set to 0x07 that also works (presumably BOD disabled, but bits not flipped!)
    – Paul Grime
    Apr 19, 2016 at 10:19
  • I don't know. This is for efuse? Can you read it back? Apr 19, 2016 at 22:38
2

If you are powering your circuit off a cell battery, you might find that your battery cannot supply enough current. To test this, use a multimeter to measure the voltage of the battery, while your circuit is connected (and possibly, or possibly not, running). If the voltage drops below 2.7v (as defined by your fuses - use the AtMel Fuse Calculator page to see what your fuses mean), your chip will shut down, causing the voltage to rise back, turning the chip back on, and round it goes.The battery may even take a while to recover (I think last time this happened to me, it took about 10 seconds -I thought I'd destroyed the battery).

This is fairly common issue with motors (which draw a lot of power), but depends on your exact battery, and the exact load.

If this happens, you might get away with using multiple batteries in parallel (connect all the + sides together, to the + side of your circuit; all the - sides together to the - side of your circuit). Most battery holders are in series, which means they boost the voltage instead; you will have to do your own wiring for this.

1
  • Thanks for your answer. Given what I am seeing (no 3.3V logic levels at all), I am wondering if it's brownout detection or something. The 328P seemingly won't get going at anything less than 4.8V (although I've not measured 3.3V-4.8V). Also, I have no idea why the 328P runs the test sketch at the same speed at the Nano and Pro Mini.
    – Paul Grime
    Apr 18, 2016 at 6:49
0

Hy all,

I´m facing the same issue. Had an ATMEGA328P-PU with 8Mhz Oscillator on a breadboard that did not work with 3.3V (stabilized) as a supply. At 5V things work as expected.

Finally I got things running with extended fuses set to xxxxx110, which sets BOD to 1.8V. I coud verify that my ATMEGA328P-PU does not run with fuses set to xxxxx101 = 2,7V (max. 2.9V). The supply is about 3.4V and has blocking condensators, so it cannot be a supply issue.

Best regards, Eckehard

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.