Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

Human interface on STK600:


This example shows how to implement a USB Device CDC on Atmel MCU with USB module. The application note AVR4907 http://ww1.microchip.com/downloads/en/appnotes/doc8447.pdf provides more information about this implementation.

Description of the Communication Device Class (CDC)

The Communication Device Class (CDC) is a general-purpose way to enable all types of communications on the Universal Serial Bus (USB). This class makes it possible to connect communication devices such as digital telephones or analog modems, as well as networking devices like ADSL or Cable modems. While a CDC device enables the implementation of quite complex devices, it can also be used as a very simple method for communication on the USB. For example, a CDC device can appear as a virtual COM port, which greatly simplifies application development on the host side.


The example is a bridge between a USART from the main MCU and the USB CDC interface.

In this example, we will use a PC as a USB host: it connects to the USB and to the USART board connector.

  • Connect the USART peripheral to the USART interface of the board.
  • Connect the application to a USB host (e.g. a PC) with a mini-B (embedded side) to A (PC host side) cable. The application will behave as a virtual COM (see Windows Device Manager).
  • Open a HyperTerminal on both COM ports (RS232 and Virtual COM)
  • Select the same configuration for both COM ports up to 115200 baud.
  • Type a character in one HyperTerminal and it will echo in the other.
On the first connection of the board on the PC, the operating system will detect a new peripheral:
  • This will open a new hardware installation window.
  • Choose "No, not this time" to connect to Windows Update for this installation
  • click "Next"
  • When requested by Windows for a driver INF file, select the atmel_devices_cdc.inf file in the directory indicated in the Atmel Studio "Solution Explorer" window.
  • click "Next"
  • Led 0 is on when USB line is in IDLE mode, and off in SUSPEND mode
  • Led 1 blinks when USB host has checked and enabled CDC interface
  • Led 2 is on when CDC port is open
  • Led 4 is on during data transfer from CDC to UART
  • Led 5 is on during data transfer from UART to CDC
  • Led 6 signals an frame error on UART
  • Led 7 signals an overflow

Setup for STK600:

  • LEDS connector is connected to PORTA
  • SWITCHES are connected to PORTB
  • PC2 (RXC0) is connected to RS232 SPARE RXD
  • PC3 (TXC0) is connected to RS232 SPARE TXD
  • Warning! The AREF0 jumper must be removed because AREF0 connected on PORTA0 overrides led 0.
  • Warning! The AREF1 jumper must be removed because AREF1 connected on PORTB0 overrides switch 0.

About example

The example uses the following module groups:

  • Basic modules: Startup, board, clock, interrupt, power management
  • USB Device stack and CDC modules:
  • Specific implementation:
    • main.c,
      initializes clock
      initializes interrupt
      manages UI
    • uart_xmega.c,
      implementation of RS232 bridge for XMEGA parts
    • uart_uc3.c,
      implementation of RS232 bridge for UC3 parts
    • uart_sam.c,
      implementation of RS232 bridge for SAM parts
    • specific implementation for each target "./examples/product_board/":
      • conf_foo.h configuration of each module
      • ui.c implement of user's interface (leds,buttons...)