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

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

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

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

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

AT89C5131A Starter Kit... Software User Guide

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

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

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

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

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

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

General Porting Considerations. Memory EEPROM XRAM

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Tag Tuning/RFID. Application Note. Tag Tuning. Introduction. Antenna Equivalent Circuit

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

8-bit Microcontroller. Application Note. AVR314: DTMF Generator

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

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

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

8-bit Microcontroller. Application. Note. AVR204: BCD Arithmetics. Features. Introduction. 16-bit Binary to 5-digit BCD Conversion bin2bcd16

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

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

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

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

AVR241: Direct driving of LCD display using general IO. 8-bit Microcontrollers. Application Note. Features. Introduction AVR

AVR442: PC Fan Control using ATtiny13. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

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.

AVR033: Getting Started with the CodeVisionAVR C Compiler. 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

AVR1318: Using the XMEGA built-in AES accelerator. 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

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

AT88CK490 Evaluation Kit

AVR120: Characterization and Calibration of the ADC on an AVR. 8-bit Microcontrollers. Application Note. Features. Introduction

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

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

AT91SAM ARM-based Flash MCU. Application Note

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

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

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

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

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

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

USB Test Environment ATUSBTEST- SS7400. Summary

Two-wire Automotive Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 (1) AT24C16 (2)

AVR1301: Using the XMEGA DAC. 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.

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

Table of Contents. Section 1 Introduction Section 2 Getting Started Section 3 Hardware Description

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

USER GUIDE. ZigBit USB Stick User Guide. Introduction

Two-wire Serial EEPROM AT24C1024 (1)

Application Note. 8-bit Microcontrollers. AVR091: Replacing AT90S2313 by ATtiny2313. Features. Introduction

USER GUIDE EDBG. Description

AT91 ARM Thumb Microcontrollers. Application Note. GNU-Based Software Development on AT91SAM Microcontrollers. 1. Introduction. 2.

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

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

AVR444: Sensorless control of 3-phase brushless DC motors. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

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

How To Prevent Power Supply Corruption On An 8Bit Microcontroller From Overheating

2-wire Serial EEPROM AT24C1024. Advance Information

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

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

Application Note. 8-bit Microcontrollers. AVR307: Half Duplex UART Using the USI Module

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

DIP Top View VCC A16 A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 I/O0 I/O1 I/O2 GND A17 A14 A13 A8 A9 A11 A10 I/O7 I/O6 I/O5 I/O4 I/O3. PLCC Top View VCC A17

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

MODFLEX MINI GATEWAY ETHERNET USER S GUIDE

8-bit Microcontroller. Application Note. AVR410: RC5 IR Remote Control Receiver

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

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

2-Wire Serial EEPROM AT24C32 AT24C64. 2-Wire, 32K Serial E 2 PROM. Features. Description. Pin Configurations. 32K (4096 x 8) 64K (8192 x 8)

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

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

Programming Flash Microcontrollers through the Controller Area Network (CAN) Interface

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

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

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

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 adavantages: 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 firmware architecture (Doc 7603, 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 3. Software Requirements 4. STK525 Default Settings The USB CDC application requires the following hardware: 1. AT90USB Evaluation Board (STK525) 2. AT90USB microcontroller with default factory configuration (including USB bootloader) 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: Another STK 525 and USB port are required if the PC has no RS232 interface. The software needed for this application: 1. FLIP software (Device Firmware Upgrade tool) 2. usb_cdc.a90 (included in USB CD-ROM ) 3. Hyperterminal application or similar The STK525 board must be configured as below: Figure 4-1. STK525 Board 2

All the jumpers should be opened, only the Vcc Source jumper VBUS5 should be set as below: Figure 4-2. Vcc Jumpers Vcc Source Reg 5 Reg3.3 VBUS5 STK 5V The microcontroller must be properly placed on its socket. Please refer to STK525 Hardware User s Guide. 5. Device Firmware Upgrade The first thing to do before starting the demo is to load the HEX file into the on-chip Flash memory of the microcontroller. The Flip software is the tool used to upgrade the firmware (available freely from the USB CD-ROM or Atmel website). The following steps should be completed to allow the device starting DFU (Device Firmware Upgrade )mode and load the HEX file: 1. Install Flip software (Flip version 3.0 or above is required). 2. Connect the STK525 board to the PC using the USB cable (Standard A to Mini B). 3. Push the HWB (Hardware Bootloader) button 4. Push the RST (Reset) button 5. Release the RST button 6. Release the HWB button 7. If your hardware conditions explained above are correct, a new device detection wizard will be displayed. Please follow the instructions (the INF file is located in the USB subdirectory from Flip installation: install path:\atmel\flip\flipx.x.x\usb ). 3

Figure 5-1. New Device Detection Wizard Figure 5-2. Driver s Location 8. Check the Device Manager, and you should see the same icon (Jungo icon) as shown in the figure below. If not start again from the step 2. 4

Figure 5-3. Device Manager 5

Once your device is connected in DFU mode with Jungo driver loaded, launch the FLIP software and follow the instructions explained below: 1. Select AT90USB device Figure 5-4. Device Selection 6

2. Select the USB as communication mode Figure 5-5. USB Communication Mode 7

3. Open the communication Figure 5-6. Open the USB Communication 8

4. Choose the HEX file to load (the HEX file is included in the USB CD-ROM: usb_cdc.a90) Figure 5-7. HEX File to Load 9

5. Load the HEX file (Check Erase, Program and Verify, then Push Run button) Figure 5-8. HEX File Loading 10

6. Start the application. Figure 5-9. Start Application Note: The AT90USB bootloader will detach and jump into the user application when Start Application button is pressed. 11

6. 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 6-1), then you can use the STK525 as a Virtual Com Port or USB to UART bridge. Figure 6-1. CDC enumeration 12

The figure below shows the Hardware used by the demo: Figure 6-2. Hardware used RS232 Connector USB Connector Joystick 6.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: 13

1. Lauch the HyperTerminal application and select the right Com port as indicated in the device manager. Figure 6-3. Com Port selection 2. Press the joystick and you will see the selection or the direction status written on the HyperTerminal window. Figure 6-4. Virtual Com Port Demo 6.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 has not an RS232 interface. 14

Follow the instruction 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 an USB port of 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 6-5. USB to UART Bridge 15

7. Application Overview The CDC application allows the user to simulate a RS232 port using the USB hardware. The device shows as a Com port instead of USB device which allows the user to use whithout 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 7-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 16

8. Firmware As explained in the USB Firmware Architecture document (Doc 7603, included in the USB CD- ROM ) all USB firmware packages are based on the same architecture (please refer to this document for more details). Figure 8-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. 17

8.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 8-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 18

8.1.1 cdc_task_init 8.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). 8.2 uart_usb_lib 8.2.1 uart_usb_test_hit This function checks if at least one character has been received on the USB. 8.2.2 uart_usb_getchar This function returns the byte received in the OUT endpoint FIFO. 8.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. 8.2.4 uart_usb_tx_ready This function checks if a byte can be written in the IN endpoint FIFO. 8.2.5 uart_usb_flush This function sends data stored in the IN endpoint. 8.3 stk_525.c. 9. PC Software 10. 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. 11. Related Documentation AVR USB Datasheet USB Firmware Architecture USB CDC class specification 19

Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 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 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 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 providedotherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel satmel s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. Atmel Corporation 2006. All rights reserved. Atmel, logo and combinations thereof, are registered trademarks, and Everywhere You Are are the trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. Printed on recycled paper.