Using the ACM Subclass Demo Application

Micrium provides a demo application that lets you test and evaluate the class implementation. Source template files are provided.

Note that the demo application provided by Micrium is only an example and is intended to be used as a starting point to develop your own application.

Configuring Device Application

The serial demo allows you to send and/or receive serial data to and/or from the device through a virtual COM port. The demo is implemented in the application file, app_usbd_cdc.c, provided for µC/OS-II and µC/OS-III. app_usbd_cdc.c is located in this folder:

  • \Micrium\Software\uC-USB-Device-V4\App\Device\

Table - Device Application Configuration Constants describes the constants usually defined in app_cfg.h or  app_usbd_cfg.h which allows you to use the serial demo.

Table - Device Application Configuration Constants
ConstantDescriptionFile
APP_CFG_USBD_CDC_ENGeneral constant to enable the CDC ACM demo application. Must be set to DEF_ENABLED. app_usbd_cfg.h
APP_CFG_USBD_CDC_SERIAL_TEST_ENConstant to enable the serial demo. Must be set to DEF_ENABLED. app_usbd_cfg.h
APP_CFG_USBD_CDC_SERIAL_TASK_PRIOPriority of the task used by the serial demo. app_cfg.h
APP_CFG_USBD_CDC_SERIAL_TASK_STK_SIZEStack size of the task used by the serial demo. A default value can be 256. app_cfg.h


Running the Demo Application

In this section, we will assume Windows as the host operating system. Upon connection of your CDC ACM device, Windows will enumerate your device and load the native driver usbser.sys to handle the device communication. The first time you connect your device to the host, you will have to indicate to Windows which driver to load using an INF file (refer to the About INF Files page for more details about INF). The INF file tells Windows to load the usbser.sys driver. Indicating the INF file to Windows has to be done only once. Windows will then automatically recognize the CDC ACM device and load the proper driver for any new connection. The process of indicating the INF file may vary according to the Windows operating system version:

  • Windows XP directly opens the Found New Hardware Wizard. Follow the different steps of the wizard until you reach the page where you can indicate the path of the INF file.
  • Windows Vista and later won’t open a “Found New Hardware Wizard”. It will just indicate that no driver was found for the vendor device. You have to manually open the wizard. When you open the Device Manager, your CDC ACM device should appear with a yellow icon. Right-click on your device and choose ‘Update Driver Software...’ to open the wizard. Follow the different steps of the wizard until the page where you can indicate the path of the INF file.

The INF file is located in:

\Micrium\Software\uC-USB-Device-V4\App\Host\OS\Windows\CDC\INF

Refer to the About INF Files page for more details about how to edit the INF file to match your Vendor ID (VID) and Product ID (PID). The provided INF files define, by default, 0xFFFE for VID and 0x1234 for PID. Once the driver is loaded, Windows creates a virtual COM port as shown in Figure - Windows Device Manager and Created Virtual COM Port.

Figure - Windows Device Manager and Created Virtual COM Port

Windows Device Manager and Created Virtual COM Port

CDC ACM INF File Issue under Windows 8 and Later

usbser.sys driver is already digitally signed by Windows. Micriµm provides only an INF file, usbser.inf, telling Windows that your device uses that driver. Under Windows 7, providing this INF file was sufficient to load the driver usbser.sys for managing the CDC device. Windows 7 would display a warning message saying that the publisher of the driver can’t be verified but it was possible to continue the driver loading. Since Windows 8.x, Microsoft has enforced by default the loading of digitally signed driver packages. This is call the Driver Signature Enforcement. Windows 8.x won’t let you load the CDC driver if the driver package is not fully signed. The Micriµm CDC driver package is composed of usbser.inf (unsigned) and usbser.sys (signed). Basically, Windows 8.x requires a digitally signed INF file.

For development purposes, it is possible to disable the Driver Signature Enforcement. You can follow the instructions described on this page and you will be able to load the CDC driver and communicate with your USB device.

For your USB product release, you will have to follow the official procedure from Microsoft to sign the driver package (INF file + usbser.sys). The procedure is called the Release-Signing and is described here.
Micriµm cannot provide an already signed CDC driver package that would avoid disabling the Driver Signature Enforcement feature because the INF file contains a Vendor and Product IDs specific to the USB device manufacturer. For your USB product, the INF file must contain an official Vendor ID assigned to your company by the USB Implementer Forum. Micriµm does not possess an official USB vendor ID. It is the customer’s responsibility to go through the official signing process as you are the USB device manufacturer.


Figure - Serial Demo presents the steps to follow to use the serial demo.

Figure - Serial Demo

Serial Demo

(1) Open a serial terminal (for instance, HyperTerminal). Open the COM port matching to your CDC ACM device with the serial settings (baud rate, stop bits, parity and data bits) you want. This operation will send a series of CDC ACM class-specific requests (GET_LINE_CODING, SET_LINE_CODING, SET_CONTROL_LINE_STATE) to your device. Note that Windows Vista and later don’t provide HyperTerminal anymore. You may use other free serial terminals such TeraTerm ( http://ttssh2.sourceforge.jp/), Hercules ( http://www.hw-group.com/products/hercules/index_en.html ), RealTerm ( http://realterm.sourceforge.net/ ), etc.

(2) In order to start the communication with the serial task on the device side, the Data Terminal Ready (DTR) signal must be set and sent to the device. The DTR signal prevents the serial task from sending characters if the terminal is not ready to receive data. Sending the DTR signal may vary depending on your serial terminal. For example, HyperTerminal sends a properly set DTR signal automatically upon opening of the COM port. Hercules terminal allows you to set and clear the DTR signal from the graphical user interface (GUI) with a checkbox. Other terminals do not permit to set/clear DTR or the DTR set/clear’s functionality is difficult to find and to use.

(3) Once the serial task receives the DTR signal, the task sends a menu to the serial terminal with two options as presented in Figure - CDC Serial Demo Menu in HyperTerminal.

(4) The menu option #1 is the Echo 1 demo. It allows you to send one unique character to the device. This character is received by the serial task and sent back to the host.

(5) The menu options #2 is the Echo N demo. It allows you to send several characters to the device. All the characters are received by the serial task and sent back to the host. The serial task can receive a maximum of 512 characters.

Figure - CDC Serial Demo Menu in HyperTerminal

CDC Serial Demo Menu in HyperTerminal


To support the two demos, the serial task implements a state machine as shown in Figure - Serial Demo State Machine. Basically, the state machine has two paths corresponding to the user choice in the serial terminal menu.

Figure - Serial Demo State Machine

Serial Demo State Machine

(1) Once the DTR signal has been received, the serial task is in the MENU state.

(2) If you choose the menu option #1, the serial task will echo back any single character sent by the serial terminal as long as “Ctrl+C” is not pressed.

(3) If you choose the menu option #2, the serial task will echo all the received characters sent by the serial terminal as long as “Ctrl+C” is not pressed.


Table - Serial Terminals and CDC Serial Demo shows four possible serial terminals which you may use to test the CDC ACM class.

Table - Serial Terminals and CDC Serial Demo
TerminalDTR set/clearMenu option(s) usable
HyperTerminalYes (properly set DTR signal automatically sent upon COM port opening)1 and 2
HerculesYes (a checkbox in the GUI allows you to set/clear DTR)1 and 2
RealTermYes (Set/Clear DTR buttons in the GUI)1 and 2
TeraTermYes (DTR can be set using a macro. GUI does NOT allows you to set/clear DTR easily)1 and 2