avr-gcc-list
[Top][All Lists]
Advanced

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

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


From: Greg Barsdorf
Subject: RE: [avr-gcc-list] stumped by my ATmega48 (again)
Date: Fri, 5 Oct 2007 15:03:45 +0200

Try the following order

PORTB = 0xff;
PORTC = 0x7f;
PORTD = 0xff;

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

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
David Kelly
Sent: 05 October 2007 02:15 PM
To: address@hidden
Cc: avr-gcc List
Subject: Re: [avr-gcc-list] stumped by my ATmega48 (again)


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.



_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.14.1/1050 - Release Date: 04/10/2007
05:03 PM
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.488 / Virus Database: 269.14.1/1050 - Release Date: 04/10/2007
05:03 PM
 






reply via email to

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