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

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

Generate Code

By default, the Autosave MPLAB® Code Configuration (MCC) configuration file option is enabled. That means MCC automatically saves your MCC configurations.

Set up autosave

Figure 1: Auto save option


Now, generate the code by using MCC. From the left side tab, Resource Management (MCC), go to Project Resources and click on the Generate button.

Generate Code

Figure 2: Generate Code


Navigate to the Projects tab in MPLAB X IDE to view the project tree structure.

Once this process completes, switch to the MPLAB X IDE window. You may now examine the generated code through the Projects tab. MCC will include all the requisite MPLAB Harmony v3 Framework files and generate the configuration code dynamically based on your MCC selections. MCC will then automatically organize and add the generated code as files and folders to your 32-bit MPLAB Harmony 3 Project.

MCC generates a default template main file main.c and application files app_sensor.c/.h app_eeprom.c/.h app_usb.c/.h based on your MCC configuration. These will be used for the Sensor, EEPROM and USB Task state machines.

View of generated files

Figure 3: Generated Application Files

You will also notice that the Peripheral Library (PLIB) files are generated for the TC, TWIHS, AFEC, and PIO peripherals. The files for the USB Device Stack Middleware, I²C Drivers, and the Timer System Service are generated as well.

Expanded view of generated files

Figure 4: Generated Harmony v3 Framework Files


Build the code by clicking on the Clean and Build Main Project in the MPLAB X IDE and verify that the project builds successfully.

Clean and build icon

Figure 5: Clean and Build option

At this point, you are ready to start implementing your application code.

Back to Top