I would like to use printf with my UART. Below I have some code that I'm working on.
#include#include int main(void) { float F_CPU = 1000000; float UART_BAUD_RATE = 4800; float UART_BAUD_REGISTERS = (((F_CPU / (UART_BAUD_RATE * 16UL))) - 1); UCSRB |= (1 << RXEN) | (1 << TXEN); UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1); UBRRL = UART_BAUD_REGISTERS; printf("Hello World"); return 1; }
When I run this code I nothing happens.
How is printf expected to work? Don't I need to initialize the printf so that it knows to communicate with the UDR.
I can replace the printf line with:
while ((UCSRA & (1 << UDRE)) == 0) {}; UDR = 'x';
and the character will print. So I have confidence that the UART is setup to print.
Any help would be appreciated, thanks.
========================
ATmega16
AVR Studio 4.14
STK500
Windows 2000
HyperTerminal