Getting Started with USB on SAM MCUs Using MPLAB® Harmony v3: Step 2
Configure TIME System Service, I2C, USB, and ADC
Configure TIME System Service
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.
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.
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.
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 the TWIHS0 Peripheral Library to satisfy the I²C Driver's direct dependency.
Verify the TWIHS0 clock settings by clicking on the module in the Project Graph. It should be set to 400 kHz.
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).
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.
Allow the auto-activation of USB Device Layer and USB High Speed Driver. These are required by the CDC Function Driver.
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.
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.
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.
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.
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.