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

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

Re: [avr-gcc-list] 163 avr-gcc program problem - resend


From: sue and clay wispell
Subject: Re: [avr-gcc-list] 163 avr-gcc program problem - resend
Date: Tue, 21 May 2002 01:46:39 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc2) Gecko/20020510

hi gines,

thanks for the suggestion. i have tried all the compiler options with no luck. i am looking through the assembly listing (avr-objdump -S) and nothing is jumping out. the main differences i see are that _real_init_ is loading the Z register (r30) with a different value (presumably for the copy_data_loop) and immediately after main() is called the stack pointer is set to different values. neither value is RAMEND (0x45f). any ideas.

thanks in advance,

clay


Gines Martinez (Terra) wrote:

Try to remove the compiler option -O2.


----- Original Message ----- From: "h c wispell ii" <address@hidden>
To: "avr-gcc-list" <address@hidden>
Sent: Friday, May 17, 2002 8:41 AM
Subject: [avr-gcc-list] 163 avr-gcc program problem - resend


hi all,

i am having trouble with a simple program running on an atmega163 that echoes any character received on the serial port. the problem is that if the rx/tx portion appears in a separate function, the 163 resets after a few (it varies from 1 to about 15) characters. it works fine if the rx/tx is inline. i am using avr-gcc 3.0.4, binutils-020423 and libc-20020203 on a linux system. the program is compiled with options "-std=gnu99 -Wall -O2 -mmcu=atmega163". to see the problem uncomment cmd() and comment out the inline rx/tx.various combinations of compilation options didn't help. any ideas?


thanks in advance for any help.


clay


#include <io.h>
#include <string.h>
#include <sig-avr.h>
#include <wdt.h>
#include <interrupt.h>


void avr_setup()
{
// disable the UART
outp(0x00, UCSRB);
outp(0x00, UCSRA);

// load the baudrate divisor register; 115200 at 9.216M
outp(4, UBRR);
outp(0, UBRRH);

// enable the UART0 transmitter & receiver
outp(BV(TXEN) + BV(RXEN), UCSRB);

// kill watch dog timer
wdt_disable();

// setup d:7 for led
outp(0x00,PORTD);
outp(0x80,DDRD);

// disable interrupts
cli();

}



void cmd(void);


int main(void)
{
unsigned int i,j;
char *buffer = "avr reset!\n\r";

avr_setup();


// send reset message
for(i=0;i<strlen(buffer);i++)
{
outp(buffer[i],UDR);
loop_until_bit_is_set(UCSRA,TXC);
sbi(UCSRA,TXC);
}


// cheesy led blink
outp(0x80,PORTD);
for(i=0;i<40000;i++)
j=i+1;
outp(0x00,PORTD);


// main loop
while(1)
{
//if(bit_is_set(UCSRA,RXC)) outp(inp(UDR),UDR); // read in character
cmd();
}


return 0; }




void cmd(void)
{
if(bit_is_set(UCSRA,RXC)) outp(inp(UDR),UDR); // read in character
}









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

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

.



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



reply via email to

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