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

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

RE: [avr-gcc-list] UART transmitting problem


From: Rune Christensen
Subject: RE: [avr-gcc-list] UART transmitting problem
Date: Fri, 28 Nov 2003 19:35:59 +0100

Hi

I have performed some tests on a Picoweb with an at90s8515.

The following code works on the Picoweb :-)

#include <avr/io.h>

char *message = "Testing, testing, 1-2-3";

int main(void)
{
        char c, *buf = message;

        // -- Enable transmitting, 115200bps (clock is 7.3728Mhz)
      // Always initialize UBRR before UCR
        UBRR = 3;
        UCR = _BV(TXEN); // same as UCR = 1 << TXEN;

        while ( ( c = *buf++ ) != '\0' ) {
                // check to see if the UDR is ready before
                // you use it. Then you don't have to wait when
                // you have transmitted the last character.
                // Maybe use interrupts instead of polling.
                loop_until_bit_is_set( USR, UDRE );
                UDR = c;
        }

        return 0;
}

I hope that you can use this.

Rune Christensen

-----Original Message-----
From: address@hidden
[mailto:address@hidden Behalf Of Laurence Anderson
Sent: Friday, November 28, 2003 1:21 PM
To: address@hidden
Subject: Re: [avr-gcc-list] UART transmitting problem


Hi Guys,

I've updated the program, and used the latest winavr distro, and its still
see
nothing in hyperterminal. Just to give more background, I have receiving
working fine. Also the origional code seems to transmit ok, so I gradually
removed parts of the code & re-tested, gradually it got more unreliable
(only
sending a message every 3 times it was turned on), then just sent one space
instead of the message, until it did nothing, and this was just by removing
code not relevant to transmitting! In one case removing an unsued global int
stopped it working! What could cause something like this?

Thanks for all the help,

Laurence

#include <avr/io.h>

char *message = "Testing, testing, 1-2-3";

int main()
{
        char c, *buf = message;

        // Enable transmitting, 9600bps (clock is 4Mhz)
        UCR = _BV(TXEN);
        UBRR = 25;

        while ( ( c = *buf++ ) != '\0' ) {
                UDR = c;
                loop_until_bit_is_set( USR, UDRE );
        }

        return 0;
}


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list



reply via email to

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