SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By Baixue
I've been reading the AVR tutorial: ... als_id=105

My questions are: what does F_CPU = 8000000 means in Makefile? If I want to run my uC at the default 1Mhz and TX/RX at 2400bps, should I change the define to:
#define FOSC 1000000
#define BAUD 2400
and then also change F_CPU = 1000000 ?

In the comments under this tutorial, people say they have to use 16Mhz external crystal to make it work. But I really want to use the 1Mhz default internal oscillator to make the UART work.
Thank you so much!
By Baixue
I mean should I change the following in *.c:
#define FOSC 1000000
#define BAUD 2400

and change the following in Makefile:
F_CPU = 1000000

By the way, the sample code define FOSC as 16Mhz in *.c and define F_CPU = 1000000 in Makefile, that really confuse me

By stevech
I think you're OK.
Download "Avrcalc" (

it calculates an acceptably small baud rate error.
The UBR would be set to 0x0019; this is calculated based on the crystal frequency.

If you use the internal oscillator, rather than a crystal, you'll get larger errors in the baud rate. Normally these errors are important as you use 19,200 and up.
By Baixue
Thank you so much for the help!! After I changed all those above, the UART wroks!!! Thank you again!