Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge



Similar documents
Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

Application Note. 8-bit Microcontrollers. AVR293: USB Composite Device

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

AT89C5131A Starter Kit... Software User Guide

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. Migrating from RS-232 to USB Bridge Specification USB Microcontrollers. Doc Control. References. Abbreviations

AVR ONE!... Quick-start Guide. EVK Windows 32104B AVR ONE! 02/10

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

8-bit. Application Note. Microcontrollers. AVR273: USB Mass Storage Implementation. Features. 1. Introduction

Application Note. 8-bit Microcontrollers. AVR280: USB Host CDC Demonstration. 1. Introduction

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91SAM ARM-based Flash MCU. Application Note

AVR2004: LC-Balun for AT86RF230. Application Note. Features. 1 Introduction

AT88CK490 Evaluation Kit

USER GUIDE. ZigBit USB Stick User Guide. Introduction

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

Application Note. USB Microcontrollers. USB PC Drivers Based on Generic HID Class. 1. Introduction

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

USER GUIDE EDBG. Description

General Porting Considerations. Memory EEPROM XRAM

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Atmel AT02985: User s Guide for USB-CAN Demo on SAM4E-EK. Atmel AVR 32-bit Microcontroller. Features. Description.

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

Application Note. Atmel ATSHA204 Authentication Modes. Prerequisites. Overview. Introduction

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

Application Note. USB Mass Storage Device Implementation. USB Microcontrollers. References. Abbreviations. Supported Controllers

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

APPLICATION NOTE. Atmel AT01095: Joystick Game Controller Reference Design. 8-/16-bit Atmel Microcontrollers. Features.

8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

AVR1003: Using the XMEGA Clock System. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

8-bit Microcontroller. Application Note. AVR461: Quick Start Guide for the Embedded Internet Toolkit. Introduction. System Requirements

Atmel AVR4905: ASF - USB Device HID Generic. 8-/32-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Secure Personalization with Transport Key Authentication. ATSHA204A, ATECC108A, and ATECC508A. Introduction.

256K (32K x 8) Battery-Voltage Parallel EEPROMs AT28BV256

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

Introducing a platform to facilitate reliable and highly productive embedded developments

Software Prerequisites Linux Ubuntu LTS. Estimated completion time: 15min. The goal of this hands-on is to:

Application Note. Atmel CryptoAuthentication Product Uses. Atmel ATSHA204. Abstract. Overview

Atmel AT32UC3A3256 microcontroller 64MBit SDRAM Analog input (to ADC) Temperature sensor RC filter

AT91 ARM Thumb Microcontrollers. Application Note. AT91 USB CDC Driver Implementation. 1. Introduction. 2. Related Documents

Atmel AVR ATxmega384C3 microcontroller OLED display with pixels resolution Analog sensors. Ambient light sensor Temperature sensor

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Quick Start Guide. CAN Microcontrollers. ATADAPCAN01 - STK501 CAN Extension. Requirements

New Features and Enhancements

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

APPLICATION NOTE. Authentication Counting. Atmel CryptoAuthentication. Features. Introduction

AT86RF230 (2450 MHz band) Radio Transceiver... User Guide

APPLICATION NOTE. AT16268: JD Smart Cloud Based Smart Plug Getting. Started Guide ATSAMW25. Introduction. Features

Two mechanical buttons Two user LEDs Four expansion headers. Board controller with USB interface. One power LED and one status LED

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

USB 2.0 Full-Speed Host/Function Processor AT43USB370. Summary. Features. Overview

8-bit Microcontroller. Application Note. AVR286: LIN Firmware Base for LIN/UART Controller. LIN Features. 1. Atmel LIN/UART Controller

AVR32737: AVR32 AP7 Linux Getting Started. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

CryptoAuth Xplained Pro

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

AN10866 LPC1700 secondary USB bootloader

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

Transcription:

AVR272: USB CDC Demonstration UART to USB Bridge Features Supported by Windows 2000 or later No driver installation Virtual COM Port Enumeration USB to RS232 Bridge with dynamic baudrate Bus powered 8-bit Microcontrollers Application Note 1. Introduction The RS232 interface has disappeared from the new generation of PCs replaced by the USB interface. To follow this change, applications based on UART interface have to migrate to USB. Migration to USB can mean heavy development both on the PC and on the device side. To avoid this development, Atmel offers you a solution based on the CDC class (Communication Device Class) with the following advantages: No need to change the PC application Few modifications from the device side The aim of this document is to describe how to start and implement a CDC (Virtual COM Port and UART to USB bridge) application using the STK525 starter kit and FLIP in-system programming software. A familiarity with USB Software Library for AT90USBxxx Microcontrollers (Doc 7675, Included in the CD-ROM & Atmel website) and the CDC specification (http://www.usb.org) is assumed. Figure 1-1. Virtual COM Port Application Software based on RS232 Library USB interface

2. Hardware Requirements The USB CDC application requires the following hardware: 1. AVR USB evaluation board (STK525, AT90USBKey, STK526...or your own board) 2. AVR USB microcontroller 3. USB cable (Standard A to Mini B) 4. RS232 crossed Cable (DB9 male to DB9 female) 5. PC running on Windows (2000, XP) with USB 1.1 or 2.0 host Note: An additional STK 52x and USB port are required if the PC has no RS232 interface. 3. In system programming and Device Firmware Upgrade To program the device you can use the following methods: The JTAG interface using the JTAGICE MKII The SPI interface using the AVRISP MKII The USB interface thanks to the factory DFU bootloader and Flip software The parallel programming using the STK500 or the STK600 Please refer to the hardware user guide of the board you are using (if you are using Atmel starter kit) to see how to program the device using these different methods. Please refer to Flip (1) help content to see how to install the USB driver and program the device through the USB interface. Note: 1. Flip is a software provided by atmel to allow the user to program the AVR USB devices through the USB interface (No external hardware required) thanks to the factory DFU bootloader. 2 AVR272

AVR272 4. Quick Start Once your device is programmed with usb_cdc.a90 file, click on Start Application button on FLIP or push the reset button from the STK525 board to start the CDC demonstration. A new device detection wizard will appear, point the wizard to the inf folder included in the CDC package. Check that your device is enumerated as COM port (see Figure 4-1), then you can use the STK525 as a Virtual COM Port or USB to UART bridge. Figure 4-1. CDC enumeration 3

The figure below shows the STK525 used by the demo (you may use another kit: AT90USBKey, STK526, depending on the AVR USB product you are working with): Figure 4-2. STK525 R S 2 3 2 C o n n e c to r U S B C o n n e c to r J o y s tic k 4 AVR272

AVR272 4.1 Virtual COM Port Demo The purpose of the Virtual COM Port demonstration is to communicate with a RS232 PC application without any software modification. Follow the instructions below to start the demo: 1. Lauch the HyperTerminal application and select the correct COM port as indicated in the device manager. Figure 4-3. COM Port selection 2. Press the joystick and you will see the selection or the direction status written on the HyperTerminal window. Figure 4-4. Virtual COM Port Demo 5

4.2 USB to UART Bridge The aim of the USB to UART bridge is to transfer data in full duplex mode between UART and USB interface. This application can be used to connect any RS232 device to a PC which does not have an RS232 interface. Follow the instructions hereunder to start the demo: 1. Connect the RS232 port of the STK 525 to The PC RS232 port. Note: If the PC has no RS232 interface you can use another STK525: Connect the two boards with a RS232 crossed cable and connect each board to a USB port on the PC. 2. Lauch two HyperTerminal applications (one with the RS232 port and the second with the Virtual COM port) with the same configuration (Baudrate, Data bits, Parity, Stop bits, Flow control). 3. Write something in one HyperTerminal, it will be displayed in the other. Figure 4-5. USB to UART Bridge 6 AVR272

AVR272 5. Application Overview The CDC application allows the user to simulate an RS232 port using the USB hardware. The device appears as a COM port instead of USB device in the device manager. This allows the user to use his RS232 application without changing his PC application. From the embedded side, the UART driver is replaced by the UART-USB Driver. The user has to use the UART-USB functions instead of the UART functions to communicate with the PC. Once the device has enumerated, the application ensures a full duplex data transfer between the PC and the peripheral. The figure below shows the structure: Figure 5-1. USB to UART migration PC Application PC Application UART API UART hardware UART API CDC Drivers USB hardware RS232 USB UART hardware USB hardware UART Driver UART- USB Driver Embedded Application Embedded Application 7

6. Firmware As explained in the USB Software Library for AT90USBxxx Microcontrollers, all USB firmware packages are based on the same architecture (please refer to this document for more details). Figure 6-1. USB CDC Firmware Architecture Start up Enumeration management main.c scheduler.c config.h conf_scheduler.h CDC application management HID application usb_task.h usb_task.c cdc_task.c cdc_task.h API usb_standard_ request.c usb_standard_request.h usb_specific_ request.c usb_specific_request.h usb_descriptors.c usb_descriptors.h conf_usb.h uart_usb_lib.c uart_usb_lib.h Drivers usb_drv.c usb_drv.h stk_525.c stk_525.h Hardware USB hardware interface Should not be modified by user Can be modified by user Added by user This section is dedicated to the CDC module only. The customization of the files described hereafter allow the user to build his own CDC Application. 8 AVR272

AVR272 6.1 cdc_task.c This file contains the functions to initialize the hardware which will be used by the application, collect data and transfer it. Figure 6-2. CDC Application Virtual Com Port Joystic pressed?? Send data trough USB Initialization Data received on Data received on USB?? UART = Fifo endpoint size?? Send data trough UART Send data trough USB USB<->UART UART<->USB Data received on UART!=0 &&!timeout?? USB-UART Bridge 9

6.1.1 cdc_task_init 6.1.2 cdc_task This function performs the initialization of the CDC parameters and hardware resources (joystick...). This function manages the data transfer for the two demonstrations (Virtual COM Port and UART to USB Bridge). 6.2 uart_usb_lib 6.2.1 uart_usb_test_hit This function checks if at least one character has been received on the USB. 6.2.2 uart_usb_getchar This function returns the byte received in the OUT endpoint FIFO. 6.2.3 uart_usb_putchar This function writes the byte put in parameter into the USB IN endpoint FIFO. It also replaces the putchar function of the UART library. For example the printf will be based on uart_usb_putchar fuction instead of putchar. 6.2.4 uart_usb_tx_ready This function checks if a byte can be written in the IN endpoint FIFO. 6.2.5 uart_usb_flush This function sends data stored in the IN endpoint. 6.3 stk_525.c. 7. PC Software 8. Limitations This file contains all the routines to manage the STK 525 board resources (joystick, potentiometer, temperature sensor, LEDs...). The CDC application uses the native Windows drivers. It requires only an INF file located in the inf folder from the CDC package. This application does not work with Windows 98 and ME (no native driver of CDC device). This application can work with Linux OS, but support depends on configuration. 9. Related Documentation AVR USB Datasheet USB Software Library for AT90USBxxx Microcontrollers USB CDC class specification 10 AVR272

Headquarters International Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Atmel Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Atmel Europe Le Krebs 8, Rue Jean-Pierre Timbaud BP 309 78054 Saint-Quentin-en- Yvelines Cedex France Tel: (33) 1-30-60-70-00 Fax: (33) 1-30-60-71-11 Atmel Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Product Contact Web Site www.atmel.com Technical Support avr@atmel.com Sales Contact www.atmel.com/contacts Literature Requests www.atmel.com/literature Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL S TERMS AND CONDI- TIONS OF SALE LOCATED ON ATMEL S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDEN- TAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. 2008 Atmel Corporation. All rights reserved. Atmel, logo and combinations thereof, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.