Go Down

Topic: Arduino Mega 1280 delay() turbocharged (Read 13 times) previous topic - next topic

Curtman

#25
Feb 06, 2011, 01:23 am Last Edit: Feb 06, 2011, 03:12 am by Curtman Reason: 1

Yes, it sounds like an Arch specific problem at the moment. Maintaining a cross compiler is probably one of the harder jobs, they are a pain to compile and bug reports are hard to replicate.

A potential solution has been posted in another thread by dsh1. This involves downgrading to GCC 4.3.5 and applying Debian patches:

http://arduino.cc/forum/index.php/topic,51000.msg363998.html#msg363998

Can people try this and see if it works?


I just thought I would mention that I'm having this problem with Gentoo as well.  I'm using:

Code: [Select]
$ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: /var/tmp/portage/cross-avr/gcc-4.3.3-r2/work/gcc-4.3.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/avr/gcc-bin/4.3.3 --includedir=/usr/lib/gcc/avr/4.3.3/include --datadir=/usr/share/gcc-data/avr/4.3.3 --mandir=/usr/share/gcc-data/avr/4.3.3/man --infodir=/usr/share/gcc-data/avr/4.3.3/info --with-gxx-include-dir=/usr/lib/gcc/avr/4.3.3/include/g++-v4 --host=i686-pc-linux-gnu --target=avr --build=i686-pc-linux-gnu --disable-altivec --disable-fixed-point --enable-nls --without-included-gettext --with-system-zlib --disable-werror --enable-secureplt --disable-libmudflap --disable-libssp --enable-cld --enable-checking=release --disable-libgcj --enable-languages=c,c++ --enable-shared --disable-threads --disable-bootstrap --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.3-r2 p1.2, pie-10.1.5'
Thread model: single
gcc version 4.3.3 (Gentoo 4.3.3-r2 p1.2, pie-10.1.5)


I've been discussing this in #arduino, and we're working around this issue so far like this:  (with a 0022 ide)

Code: [Select]
$ diff -u5 hardware/arduino/cores/arduino/wiring.{c_orig,c}
--- hardware/arduino/cores/arduino/wiring.c_orig 2011-02-05 18:17:40.058000066 -0600
+++ hardware/arduino/cores/arduino/wiring.c 2011-02-05 18:19:32.907000066 -0600
@@ -21,10 +21,11 @@

  $Id$
*/

#include "wiring_private.h"
+#include <avr/delay.h>

// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
// the overflow handler is called every 256 ticks.
#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256))

@@ -102,18 +103,21 @@
return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
}

void delay(unsigned long ms)
{
+/*
uint16_t start = (uint16_t)micros();

while (ms > 0) {
if (((uint16_t)micros() - start) >= 1000) {
ms--;
start += 1000;
}
}
+*/
+ _delay_ms(ms);
}

/* Delay for the given number of microseconds.  Assumes a 8 or 16 MHz clock. */
void delayMicroseconds(unsigned int us)
{


I have also found that using the 0018 IDE, the delay() works properly.

I'll have a look at the Debian patches you listed, and report back when I know more.

Curtman

On further investigation, it seems that using binutils-2.20.1-r1 instead of binutils-2.21 solves this for me on Gentoo.

jhubbs

I have this issue with the Uno and Fedora14 i686.  The software is avr-gcc-4.5.1 and avr-binutils 2.21.

John Bailey

#28
Feb 21, 2011, 05:42 pm Last Edit: Feb 22, 2011, 12:55 pm by John Bailey Reason: 1
Same here with Fedora 14. (using a Duemilanove)

avr-gcc -v result.

Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/avr/4.5.1/lto-wrapper
Target: avr
Configured with: ../gcc-4.5.1/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-system-zlib --enable-version-specific-runtime-libs --with-pkgversion='Fedora 4.5.1-2.fc14.1' --with-bugurl=https://bugzilla.redhat.com/
Thread model: single
gcc version 4.5.1 (Fedora 4.5.1-2.fc14.1)

Hadn't used it for a while on my Fedora box. Works fine so far on Mint though, so not completely duinoless.
I also get an error when uploading

"avrdude: stk500_recv(): programmer is not responding"

But none with the blink without delay sketch. 

Using avrdude 5.10



newbee234

Ditto for Fedora 14, with Arduino Duemilanove.
See topic
  http://arduino.cc/forum/index.php/topic,68512.0.html

However the 'blink' example that comes with the arduino v22 software, initializes a LEDPin global variable and that, as has been said fixes the problem.

I am a newbe to using the arduino, and the fact that it fails like this with a very basic example has been a worry for me.   Any idea when the real problem will be fixed?

Go Up