[Top][All Lists]

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

Re: [avr-gcc-list] Newbie - should this work?

From: Theodore A. Roth
Subject: Re: [avr-gcc-list] Newbie - should this work?
Date: Fri, 17 Jan 2003 09:57:36 -0800 (PST)

On Fri, 17 Jan 2003, Josh Thompson wrote:

:) Hi,
:) I'm new at using working with embedded systems.  I am fairly familiar
:) with using gcc under Linux.  I am using an ATmega128, avr-gcc, and usip
:) with a ByteBlaster programmer.  uisp says it detects the chip and then
:) loads the code into flash.  I can dump the code and get the same thing
:) that I uploaded; so, I think this part is working okay.  Here is my code:
:) main.c:-------------------------
:) #include <io.h>
:) int main() {
:)    DDRD = 0xff;
:)    PORTD = 0X00;
:) }
:) -------------------------------
:) Makefile:----------------------
:) all: main
:) main: main.c
:)    avr-gcc -D__AVR_ATmega128__ main.c -o main
:)    avr-objcopy --output-target=srec main main.srec
:) -------------------------------

I would change this to look like this:

main: main.c
        avr-gcc -mmcu=atmega128 -o main main.c
        avr-objcopy --output-target=srec main main.srec

You need to use the -mmcu option to tell gcc which target to use. the -D
is not enough because the linker will then default to using startup code
for a 8515 target which is wrong. Using -mmcu=atmega128 allows gcc to pass
all the correct information down down to the various backends.

:) These are the steps I am taking:
:) ./uisp -dprog=abb -dlpt=/dev/parport0 --upload if=main.srec
:) after this, I disconnect the programmer cable
:) disconnect power
:) reconnect power
:) At this point, I would expect to read 0 volts on the PORTD pins, but I
:) am reading 1.5 volts.
:) Should this work?  Am I following the right steps?
:) I have also tried it with 'PORTD = 0xff;' and still get 1.5 volts.

These steps look correct to me. I tried your program and measured the
expected values.

A few questions:

  Which version of avr-gcc/avr-libc are you using?

  How is your mega128 mounted/powered?

  Are you sure you are measuring the correct pins?

1.5 volts looks like something is floating.

Ted Roth

avr-gcc-list at http://avr1.org

reply via email to

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