ATxmega source code
(Last updated 3 Apr 2011)
I am starting out with the Atmel AVR Xplained development board.
I just couldn't pass up an 8-bit MCU with 128 kB of flash and eight
USARTs, all for just $30. :-)
My first coding project involved enabling all eight USARTs and
connecting them to the standard I/O streams, so I can use printf,
fprintf, and others in my projects. The source code below
implements all of this and provides a sample implementation for you to
play with. I tried to make the source code suitable for use as an
USART library module, but have not yet (Apr 2011) done that.
The code was developed and tested on an Xplained '128a1 board.
This code will connect stdin, stdout, and stderr to USARTD0, which is
header J3 on the Xplained dev board. You can hook up a serial
cable to your PC, open TeraTerm, set it for 38400, 8N1, and exchange
text with your dev board.
This module provides interrupt support for receiving characters, polled
transmit, and the ability to change USARTs assigned to any of the
standard streams on-the-fly. This last feature was important,
because a future project will require my code to sample character I/O
from various serial devices and I want the methods for doing that as
simple as possible.
Enjoy! If you have suggestions or comments, drop me an email.
usartx.zip Source code
for the ATxmega USART library, with test program