2
\$\begingroup\$

I recently bought arduino uno r3 and started with simple program which blinks embedded led:

#define LED_PIN 13

void setup()
{
    pinMode(LED_PIN, OUTPUT);
}

void loop()
{
    digitalWrite(LED_PIN, HIGH);
    delay(500);
    digitalWrite(LED_PIN, LOW);
    delay(500);
}

A problem is that this program isn't working. After uploading it seems got stuck in some state (led is constantly on or constantly off).

But in case program is using serial module -- arduino works as expected.

#define LED_PIN 13

void setup()
{
    pinMode(LED_PIN, OUTPUT);
    Serial.begin(9600);
}

void loop()
{
    digitalWrite(LED_PIN, HIGH);
    delay(500);
    digitalWrite(LED_PIN, LOW);
    delay(500);
}

Where is the problem? Or it is by design and should work this way?

About toolchain:

  • avr-g++-4.4.6-r1 p1.0, pie-0.4.5
  • arduino-1.0.5
  • avrdude-6.0.1
  • avr-libc-1.8.0
\$\endgroup\$
  • \$\begingroup\$ I don't see a problem with arduino nano that uses the same mcu (mega328) so I don't understand why this would not work for arduino UNO. \$\endgroup\$ – alexan_e Feb 22 '14 at 11:31
  • \$\begingroup\$ it may be firmware bug or something, so I asked question. But same problem is present when I uploaded this code to arduino ethernet via serial converter. \$\endgroup\$ – Alexander Sergeev Feb 22 '14 at 11:50
  • \$\begingroup\$ Which IDE version do you have? Did you try to update it (just in case). Can you upload your .hex file in a server and post the link, I would like to try it and see if it creates a problem. You can also try my hex , its from arduino 1.0.5 in linux. You can load it to mcu using X-loader \$\endgroup\$ – alexan_e Feb 22 '14 at 11:59
  • \$\begingroup\$ arduino-1.0.5 with ino tools (github.com/amperka/ino) under linux. But behavior doesn't change when I use arduino ide directly. Generated hex files: segv.ru/arduino/without_serial.hex segv.ru/arduino/with_serial.hex \$\endgroup\$ – Alexander Sergeev Feb 22 '14 at 12:16
  • 1
    \$\begingroup\$ I have tried yours, it is working. BTW I found source of problems in binutils package. Thanks for taking part in :) \$\endgroup\$ – Alexander Sergeev Feb 22 '14 at 13:11
1
\$\begingroup\$

Turns out that problem was in binutils toolchain part. I have used 2.19 and apparently it's broken with arduino, so I rollback to 2.18.50.0.9 and now all things works as supposed to.

So it's quite strange that arduino actually works with serial.begin().

For gentoo users next actions should resolve the issue:

crossdev -C avr
USE="multilib -cxx" crossdev --b 2.19.1-r1 -S -s1 --target avr
USE="multilib cxx" crossdev --b 2.19.1-r1 -S -s4 --target avr
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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