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
JYelton
35.7k34 gold badges149 silver badges282 bronze badges
asked Feb 22, 2014 at 11:17
\$\endgroup\$
6
  • \$\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\$ Commented Feb 22, 2014 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\$ Commented Feb 22, 2014 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\$ Commented Feb 22, 2014 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\$ Commented Feb 22, 2014 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\$ Commented Feb 22, 2014 at 13:11

1 Answer 1

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
answered Feb 22, 2014 at 13:13
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.