Skip to content

microchip-pic-avr-solutions/avr_du_cnano_tinyusb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

MCHP

TinyUSB Integration Project With AVR® DU Microcontroller

This project uses the Microchip MPLAB® X IDE or MPLAB Extensions for Microsoft® Visual Studio Code® (VS Code®) and demonstrates the TinyUSB stack with integrated USB device examples running on top of the AVR DU. Within the project, there are different configurations for various USB device class functions. For example, the device_cdc_msc configuration is a USB CDC + MSC composite device. The device_hid_composite configuration is a USB Human Interface Device (HID) composite device. The default configuration without a USB stack involved is used only for adding or removing necessary driver components from MPLAB® X MPLAB® Code Configurator (MCC), which can be used by other configurations inside this same project.

About TinyUSB

TinyUSB is an open-source cross-platform USB Host/Device stack for embedded systems, designed to be memory-safe with no dynamic allocation. It is thread-safe with all interrupt events deferred then handled in the non-ISR (Interrupt Service Routine) task function. For details, please refer to the following links:

Related Documentation

Software Used

Hardware Used

Setup

Physical Setup

The AVR DU Curiosity Pro Development board has two USB ports: one debugger port for programming the device via the on-board debugger, and one target port directly connected to the AVR DU. This example uses the Debugger port for programming. After the device is programmed, the Debugger port can be disconnected. The target port must be connected to the host for the TinyUSB demonstration.

The Curiosity Nano has an Adjustable Target Regulator that regulates voltage to 3.3V by default. Since the USB peripheral in the AVR64DU32 needs to run at 3.3V, it either needs a 3.3V supply connected on the VUSB pin or a 5.0V supply on VDD with the internal USB Voltage Regulator active. With the Curiosity Nano's default settings, the VBUS pinheader on the board must be connected with the included jumper to supply 3.3V directly to VUSB. This project uses the default settings, requiring the jumper to be connected as shown in the following figure.

MCC Project Setup

This section shows how to set up the example in MPLAB using the MCC. The following figure presents an overview of the complete MCC setup.

Note: The MCC code generation has been manually tested only with the MPLAB® X MCC plug-in. The MCC within the MPLAB extension has not been tested. However, building and debugging processes have been manually tested and function properly.

Download the AVR® DU TinyUSB Project

Programming and Running the TinyUSB Application

This project has two configurations with a USB function, where each configuration demonstrates a class example: one is the MSC + CDC USB device demonstration, the other is the HID composite USB device demonstration.

The following steps will demonstrate how to use MPLAB® X to program and run the board.

Note: This project can be opened, programmed and debugged from the VS Code with MPLAB Extensions. The VS Code project is under the .X folder: pic32cm_gc_cpro_tinyusb.X. For more details on how to use the MPLAB Extensions with VS Code, refer to the MPLAB® Tools for VS Code®.

Running the MSC_CDC Device Demonstration

  1. Connect the board to the PC through the J203: DEBUG USB.

  2. Open the MPLAB® X project. Select the device_cdc_msc configuration in the project.

  3. Build the project and program the board by clicking the icon.

    Programming/Verify complete will appear after correctly programming.

  4. Connect the board's USB target port (J112) to the host PC.

  5. Check the disk from the PC, TinyUSB MSC and README.txt will be displayed.

  6. Open the Device Manager to check the COM port device.

  7. Open a serial terminal to test the CDC port. Any typed characters will be echoed back to the terminal, as shown in the following figure.

Running the HID Composite Device Demonstration

  1. Connect the board to the PC through the J203: DEBUG USB.

  2. Open the MPLAB® X project and select the device_hid_composite configuration in the project.

  3. Build the project and program the board by clicking the icon.

    Programming/Verify complete will appear after correctly programming.

  4. Connect the board's USB target port (J112) to the host PC.

  5. Open the Device Manager to check if HID Keyboard Device and HID-Compliant mouse are present or not.

  6. Open an editor from the host PC and push the on-board SW0 button. The a will be typed in after every button press, while the cursor will move right and down by one step, respectively.

Limitations:

  1. The current release (v1.0.0) is well tested with a bus powered device. The self-powered mechanism will be covered in a future release.
  2. Currently, the VS Code project does not include the AVR GCC configuration, as the latest version (AVR GCC v15.1.0) does not yet provide adequate support for long file paths.

About

TinyUSB integration with Microchip platform for AVR DU

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published