[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] 163 avr-gcc program problem - resend
From: |
Gines Martinez \(Terra\) |
Subject: |
Re: [avr-gcc-list] 163 avr-gcc program problem - resend |
Date: |
Sat, 18 May 2002 12:46:54 +0200 |
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