[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] UART transmitting problem
From: |
Bob Paddock |
Subject: |
Re: [avr-gcc-list] UART transmitting problem |
Date: |
Thu, 27 Nov 2003 16:45:29 -0500 |
User-agent: |
KMail/1.5.4 |
> #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/
Re: [avr-gcc-list] UART transmitting problem, Anderas Strodl, 2003/11/28