Getting Started with USB on SAM MCUs Using MPLAB® Harmony v3: Step 2

Step 2.1 - Configure TIME System Service

This training module uses MPLAB Harmony Configurator (MHC) in Standalone window mode.

Ensure that MHC is in this mode by navigating to
Tools > Options > Plugins > MPLAB Harmony Configurator 3, then use the Window Manager dropbox to set the window mode to Standalone and click Apply


Switch to the MHC window and look for the TIME System Service module. You can add this by double clicking the module name under Available Components > Harmony > System Services > TIME.

Figure 1: Add TIME System Service Component


Accept the Core module auto-activation prompt. Since we will not use FreeRTOS for our application, defer enabling this component for now. Once you are done, the module should be visible in the Project Graph pane.

Figure 2: Accept Core module auto-activation
Figure 3: Defer FreeRTOS auto-activation
Figure 4: Project Graph after adding TIME System Service


Add the TC0 Peripheral Library as the timekeeper for the TIME System Service, which will set itself up automatically once this dependency is added. No further configuration is required for our use case of generating a periodic interrupt every second. You can add this by right-clicking on the dependency icon on the module.

The dependency icon on the module is highlighted in red when a direct dependency (i.e., required for a module to function) is not satisfied. Harmony 3 provides you the freedom to pick a module of your choice from a list of compatible modules to satisfy this dependency.

TC stands for Timer Counter and is a peripheral is available in the SAM and UC3 family of devices.

Figure 5: Add TC0 Peripheral Library
Figure 6: Project Graph with TIME System Service successfully configured.

Step 2.2 - Configure I²C Driver


Add the I²C Driver module. You can add this by double clicking the module name under Available Components > Harmony > Drivers > I2C.

Figure 7: Add I²C Driver Component
Figure 8: Project Graph after adding I²C Driver


Add the TWIHS0 Peripheral Library to satisfy the I²C Driver's direct dependency.

TWIHS stands for Two Wire Interface High Speed and it's the I²C peripheral available in the SAME70/S70/V70/V71 family of devices.

Figure 9: Add TWIHS0 Peripheral Library
Figure 10: Project Graph after adding Peripheral Library


Verify the TWIHS0 clock settings by clicking on the module in the Project Graph. It should be set to 400 kHz.

Figure 11: Verify I²C clock settings


Add an additional client to the existing I²C Driver Instance 0 by clicking on it in the Project Graph. Set the number of clients to 2 (one for the temperature sensor, another for the EEPROM).

Figure 12: Add Client

Step 2.3 - Configure USB Device Stack Middleware


Add the USB CDC Function Driver module. You can add this by double clicking the module name under Available Components > Libraries > USB > Device Stack > CDC Function Driver.

Figure 13: Add CDC Function Driver Component


Allow the auto-activation of USB Device Layer and USB High Speed Driver. These are required by the CDC Function Driver.

Figure 14: Allow the auto-activation of USB Device Layer
Figure 15: Allow the auto-activation of USB High Speed Driver
Figure 16: Project Graph after adding USB Middleware


Configure the USB High Speed Driver module by clicking it in the Project Graph. Since the E70 Xplained Evaluation Kit is bus-powered, we can uncheck the VBUS sense option.

Figure 17: Uncheck Enable VBUS Sense


Configure the USB Device Layer module by clicking on it in the Project Graph. Under Product ID Selection, select cdc_com_port_single_demo from the list.

The drivers for this USB device are already installed alongside MPLAB X IDE.

Figure 18: Select USB Product ID


This application uses a single USB CDC Instance. Click on Instance 0 under the CDC Function Driver module in the Project Graph to view its parameters. No further configuration is required.

Figure 19: Verify CDC Instance 0 Parameters

Step 2.4 - Configure ADC Peripheral Library


Add the AFEC1 Peripheral Library module. You can add this by double clicking the module name under Available Components > Peripherals > AFEC > AFEC1.

AFEC stands for Analog Front End Controller and it's the ADC peripheral available in the SAME70/S70/V70/V71 family of devices.

Figure 20: Add AFEC1 Peripheral Library
Figure 21: Project Graph after adding AFEC1 Peripheral Library


Configure the AFEC1 Peripheral Library module by clicking on it in the Project Graph. Under AFEC1 > ADC Configuration, set the Prescaler spinbox to 24 and the Conversion Mode selection to Software Trigger. The TEMT6000 Ambient Light Sensor is connected to the pin PC31, which is connected internally to AFEC1 Channel 6. Enable channel 6 using the checkbox as shown in Figure 22 under AFEC1 > Channel Configuration > Channel 6 > Enable Channel 6.

Figure 22: Configure AFEC1 Peripheral Library

Next Step >

© 2021 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.