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

Last modified by Microchip on 2023/11/09 09:09

Configure TIME System Service, I2C, USB, and ADC

Configure TIME System Service

Information
  • When you launch MCC for the first time, it displays a prompt asking for the mode in which you would like to use MCC.
    • Standalone mode (as a separate window)
    • Native mode (as an embedded window in MPLAB X IDE)
  • Standalone mode is the default mode.
  • MCC will launch in the operating mode selected the first time, every time you launch MCC.

For this lab, MCC is configured to operate in Standalone mode.

Switch to the MCC window and look for the TIME System Service module. You can add this by double clicking the module name under Resource Management [MCC] > Device Resources > Harmony > System Services > TIME.

Add TIME system service Component

Accept the Core module auto-activation prompt by clicking Yes. 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.

Accept core module auto-activation

Defer FreeRTOS auto-activation

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.​

Information

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.

Add TC0 peripheral library

Project graph with time system service successfully configured

Back to Top


Configure I²C Driver

Add the I²C Driver module. You can add this by double clicking the module name under Resource Management [MCC] > Device Resources > Harmony > Drivers > I2C.

Add I²C Driver Component

Project Graph after adding I²C Driver

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

Information

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.

Add TWIHS0 Peripheral Library

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.

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).

Add Client

Back to Top


Configure USB Device Stack Middleware

Add the USB CDC Function Driver module. You can add this by double clicking the module name under Resource Management [MCC] > Device Resources > Libraries > Harmony > USB > Device Stack > CDC Function Driver.

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.

Allow the auto-activation of USB Device Layer

Allow the auto-activation of USB High Speed Driver

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.

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.

Information

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

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.

Verify CDC Instance 0 Parameters

Back to Top


Configure ADC Peripheral Library

Add the AFEC1 Peripheral Library module. You can add this by double clicking the module name under Resource Management [MCC] > Device Resources > Harmony > Peripherals > AFEC > AFEC1.

Information

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

Add AFEC1 Peripheral Library

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.

Configure AFEC1 Peripheral Library

Back to Top