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: Joerg Wunsch
Subject: Re: [avr-gcc-list] UART transmitting problem
Date: Fri, 28 Nov 2003 00:11:38 +0100 (MET)

As Bob Paddock <address@hidden> wrote:

>
>> #define F_CPU            4000000      /* 4Mhz */
>> #define UART_BAUD_RATE      9600      /* 9600 baud */
>> #define UART_BAUD_SELECT (F_CPU/(UART_BAUD_RATE*16l)-1)
>
>Always check to see what is really being generated by that type of formula.
>
>I've run into some combinations of crystals and baud rates give a answer that
>is off by one due to the integer truncation of the math.
>
>>      while ( ( c = *(buf++) ) != '\0' ) {
>>              loop_until_bit_is_set( USR, UDRE );
>>              outp( c, UDR );
>
>Are you sure that UDRE will be set BEFORE you send the first char?
>I've been bitten by a problem like that recently.   The UART Shift Register 
>empty bit comes up zero from reset, not set like you would want.
>
>
>-- 
>                    http://www.softwaresafety.net/
>       http://www.unusualresearch.com/ http://www.bpaddock.com/
>
>
>_______________________________________________
>avr-gcc-list mailing list
>address@hidden
>http://www.avr1.org/mailman/listinfo/avr-gcc-list
>

-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/


reply via email to

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