Download FreeRTOS
 

Quality RTOS & Embedded Software

COMMUNITY
WHAT'S NEW
Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.

LPCOpen Virtual COM / CDC Example
Using the USB Drivers that are Built Into the LPC ROM


LPCOpen includes an interface to the USB drivers that are built into the LPC1800 hardware itself. This excellent hardware feature allows you to make use of pre-tested and pre-integrated USB drivers without even needing to allocate any valuable Flash memory space to their implementation.

The instructions on this page describe how to import and use LPCOpen's usbd_rom_cdc_vcom project to show how easy it is to create a USB virtual COM / CDC port on an LPC1800 microcontroller. It is assumed that all preceding steps have already been completed, so the necessary tools have already been installed, and the chip support and board support library projects have already been imported.

The usbd_rom_cdc_vcom project does not use FreeRTOS. Following pages demonstrate both how to incorporate the same virtual COM port functionality into a FreeRTOS application, and how FreeRTOS can be used to make the USB virtual COM / CDC port event driven to massively improve its run time efficiency.

The video on the introductory page shows the Virtual COM / CDC driver being used to provide input and output to the FreeRTOS-Plus-CLI command line interface.


Workflow steps:
  1. The LPC1800 chip support and LPC1800 Xplorder board support projects should have already been imported into the LPCXpresso workspace. Open the LPCOpen zip file in the LPCXpresso Eclipse import window again, and this time select and import the usbd_rom_cdc_vcom project.


    Importing the virtual COM / CDC port project that uses the hardware USB drivers


  2. The workspace should now include three projects. Right click on the usbd_rom_cdc_vcom project, then select 'Build Project' from the pop up menu. The LPC1800 chip and board support packages are dependencies of the usbd_rom_cdc_vcom project, so all three projects will get built.


    Building the usbd_rom_cdc_vcom project


  3. Ensure that ...
    1. usbd_rom_cdc_vcom is highlighted in the Eclipse project explorer window.
    2. The LPC18xx Xplorer microcontroller evaluation board is connected to your host computer though an appropriate debug adaptor (for example an LPC Link2).
    3. The LPC18xx Xplorer microcontroller evaluation board is powered using the USB connector that is at the opposite end of the board to the Ethernet connector.

    ... then click the 'Debug usbd_rom_cdc_vcom' button visible in the 'Start Here' window (see the image below). The microcontroller's flash memory will be programmed and the debugger will break at the start of the main() function.


    The 'Debug usbd_rom_cdc_vcom' button in the Start Here window


  4. Select 'Resume' from LPCXpresso's 'Run' menu to run the application. The host computer will detect the connection of a new USB device and attempt to install a virtual COM port USB driver. A link to an appropriate driver is provided on the same LPCOpen web page from which the LPCOpen .zip file was downloaded - search for "USB Drivers" on the appropriate download page to locate the link.

  5. A quick inspection of the source code shows that the example sends "Hello World!!" to the USB port when it first connects, then simply echos back any characters that are received. To test this, open a dumb terminal program such as Hyperterminal or Tera Term, selecting to connect to which ever COM port has enumerated as "LPC USB VCom Port (COMx)", then start to type text into the terminal window.


    Selecting the virtual COM port in Tera Term



    Typing text into a Tera Term window that is connected to the virtual COM/CDC port



Next: Experimenting with the LPCOpen FreeRTOS TCP echo example (with FreeRTOS)




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.