[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] stumped by my ATmega48 (again)

From: David Kelly
Subject: Re: [avr-gcc-list] stumped by my ATmega48 (again)
Date: Fri, 5 Oct 2007 07:14:43 -0500

On Oct 4, 2007, at 11:25 PM, address@hidden wrote:

Hi all,

I thought I was getting the hang of this Atmel programming, but after
dusting things off a bit, I'm stumped again.  I have a demo program
from Matthew MacClary at Oregon State that toggles all output pins
every three seconds.  Pin 15 is hooked up to an LED on my breadboard,
and when I install his prebuilt .hex file, the LED lights right up and
does its thing.

But when I build the same source and then install my hex file, the LED
never lights up.

To try to isolate the problem, I reduced the main program to just this:

        DDRB = 0xff;
        DDRC = 0x7f; /* PORTC has only 7 pins */
        DDRD = 0xff;

        PORTB = 0xff;
        PORTC = 0x7f;
        PORTD = 0xff;
        return 0;               /* PATCH for testing!  */

I believe this should set all output pins high.  But again, when I
build and install this, nothing; the LED doesn't light up.  Then I
tried setting all ports to 0x00, but that didn't work either.

When you return the CPU goes thru a crash reset, or something like that, I haven't traced the code.

Do something like this:

        PORTB = 0xff;
        PORTC = 0x7f;
        PORTD = 0xff;
        for( ;; )
        return 0

Then again we've discussed the removal of empty loops to death. Make sure the compiler doesn't optimize out that empty loop. Possibly it recognizes it as infinite and leaves it alone.

David Kelly N4HHE, address@hidden
Whom computers would destroy, they must first drive mad.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]