# Questions with AVR UART tutorial

**URL:** <https://community.sparkfun.com/t/questions-with-avr-uart-tutorial/9275>\
**Category:** MicroMod\
**Tags:** avr-atmel\
**Created:** [December 4, 2008, 9:30pm UTC](https://community.sparkfun.com/t/questions-with-avr-uart-tutorial/9275 "2008-12-04T21:30:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baixue](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@Baixue](https://community.sparkfun.com/u/Baixue)\
**Post date:** [December 4, 2008, 9:30pm UTC](https://community.sparkfun.com/t/questions-with-avr-uart-tutorial/9275/1 "2008-12-04T21:30:28Z")

</div>

I’ve been reading the AVR tutorial:[http://www.sparkfun.com/commerce/tutori … als\_id=105](http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_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!

Baixue

---

<div class="post-metadata">

**Author:** ![Baixue](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@Baixue](https://community.sparkfun.com/u/Baixue)\
**Post date:** [December 4, 2008, 9:46pm UTC](https://community.sparkfun.com/t/questions-with-avr-uart-tutorial/9275/2 "2008-12-04T21:46:24Z")

</div>

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

Baixue

---

<div class="post-metadata">

**Author:** ![stevech](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@stevech](https://community.sparkfun.com/u/stevech)\
**Post date:** [December 5, 2008, 1:46am UTC](https://community.sparkfun.com/t/questions-with-avr-uart-tutorial/9275/3 "2008-12-05T01:46:29Z")

</div>

I think you’re OK.

Download “Avrcalc” ([avrfreaks.net](http://avrfreaks.net))

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.

---

<div class="post-metadata">

**Author:** ![Baixue](https://avatars.discourse-cdn.com/v4/letter/b/b5e925/32.png) [@Baixue](https://community.sparkfun.com/u/Baixue)\
**Post date:** [December 5, 2008, 11:28pm UTC](https://community.sparkfun.com/t/questions-with-avr-uart-tutorial/9275/4 "2008-12-05T23:28:43Z")

</div>

Thank you so much for the help!! After I changed all those above, the UART wroks!!! Thank you again!

Cheers,

Baixue
