ATMEL AVR1510 User Manual

http://www.BDTIC.com/ATMEL
AVR1510: Xplain training - XMEGA USART

Prerequisites

Required knowledge
AVR1500: Xplain training – XMEGA™ Basics AVR1502: Xplain training – XMEGA Direct Memory Access Controller
Atmel WinAVR/GCC 20100110 or later
Hardware prerequisites
Xplain evaluation board JTAGICE mkII
Estimated completion time:
1.5 hours

1 Introduction

The USART (Universal Synchronous Asynchronous Receiver Transmitter) is the key element in serial communications between computers, terminals and other devices.
This training covers basic setup and use of the Atmel XMEGA USART and the three tasks will demonstrate how to use the USART I polling-mode, interrupt mode and how to use the DMAC (Direct Memory Access Controller) to transfer data without CPU interaction.
®
AVR® Studio® 4.18 or later
8-bit Microcontrollers
Application Note
Rev. 8319A-AVR-06/10

2 Overview

http://www.BDTIC.com/ATMEL
This training covers some of the Atmel XMEGA USART basic features:
Task 1: Polled mode
The first task shows how to set up the USART in polling mode. Some characters will be transferred in loop-back mode.
Task 2: Interrupt mode
This task shows how to use a driver to set up the USART. The driver has a ring buffer that makes life easier for the developer. Also the hardware buffer is shown in this task.
Task 3: DMAC
Atmel XMEGA introduces Direct Memory Access Controller (DMAC) for 8-bit processors. With the USART, DMAC is very useful allowing data to flow with nearly no CPU intervention. This task will show how to set up the USART with the DMAC.
2
AVR1510
8319A-AVR-06/10

3 Task 1: USART in polling mode

http://www.BDTIC.com/ATMEL
Using polling mode with the USART is especially useful when for example debugging the application or when steps in the program are expected to happen synchronously. In this task, we will set up the Xplain evaluation board to send data from USART to another USART. This is a good way to test the USART.
The goal for this task is that you know how to:
Set up the USART in polling mode
Send some characters in loop-back mode
Verify that the transmission was successful
1. Start Atmel AVR Studio and open the project file Polled_Usart.aps in the XMEGA­USART folder
2. On the Xplain evaluation board, connect a jumper or cable between pins PD2 and PD3
AVR1510

3.1 Baud rate

The Baud rate is calculated by using the peripheral frequency (f BSEL as parameters. The target frequency and peripheral frequency on the Atmel XMEGA is set to 2 MHz default. The BSEL bits are setting the baud rate, and the BSCALE is adding even more functionality, but is ignored at this stage. By setting BSCALE to 0, the BSEL can be found by Equation 3-1.
-
Equation 3
BSEL
3. Calculate and find the BSEL value for f
4. Verify that the calculated value is the same as in task1.c
5. Compile the project and verify that there are no errors or warnings
1. Equation for Calculating BSEL Value
f
BSCALE
PER
162
f
BAUD
=
1
BAUD
= 9600
), the BSCALE and
PER
8319A-AVR-06/10
3
Loading...
+ 7 hidden pages