[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:40:24 -0800 (PST) |
On Fri, 17 Jan 2003, Volkmar Dierkes wrote:
:) Josh,
:)
:) Josh Thompson <address@hidden> schrieb am 17.01.03 14:41:47:
:)
:) > 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;
:) > }
:) > -------------------------------
:)
:) You need always an endless loop in your embeded system. Otherwise the
:) mcu is running through its non used flash memory and you didn't know
:) whats happen. Therefore change it to this:
:) int main() {
:) DDRD = 0xff;
:) PORTD = 0X00;
:) for(;;);
:) }
Actually, with the latest avr-libc, you don't need that for loop since the
_exit() function is automatically called when you fall off the end of the
main() routine. The _exit() supplies an endless loop too. You save
yourself a redundant jmp or rjmp instruction depending on the target
micro.
I don't remember correctly if this was true for older versions of avr-libc
(pre 20030203).
Of course, it's usually not a bad thing to be explicit.
Ted Roth
avr-gcc-list at http://avr1.org
RE: [avr-gcc-list] Newbie - should this work?, Tom Harris, 2003/01/26
Re: [avr-gcc-list] Newbie - should this work?, Christoph Plattner, 2003/01/26