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

Step 3.1 - Configure Clocks

1

Launch Clock Easy View by going to Project Graph in MPLAB® X IDE and then select Plugins > Clock Configuration.

tools_clock_config.png
Figure 1: Open Clock Configuration

2

Switch MOSCSEL to Main Crystal.

Note: USB requires an accurate clock for operation and cannot run on the Main RC oscillator.

clock_config_window_1.png
Figure 2: Clock Configuration

Step 3.2 - Configure Pins

1

Launch Pin configuration by going to Project Graph in MPLAB X IDE and then select Plugins > Pin Configuration.

tools_pin_config.png
Figure 3: Open Pin Configuration

2

Order the pins by Ports for ease of use.

pin_config_window_1_1.png
Figure 4: Order by Ports

3

The LED on the I/O1 Xplained Pro is connected to pin PA0.

  • Set the function to GPIO.
  • Name this pin as "LED".
  • Set the direction to Out.
  • Set the latch to High.

TWIHS pins, PA3 and PA4, need to be set to the correct function.

  • For PA3, set function to TWIHS0_TWD0.
  • For PA4, set function to TWIHS0_TWCK0.
pin_config_window_2_1.png
Figure 5: LED and TWIHS Pin Config

4

The LED on the SAM E70 Xplained is connected to pin PC8.

user_leds.png
Figure 6: SAM E70 Xplained User LED Schematic
  • Set the function to GPIO.
  • Name this pin as "USB_LED".
  • Set the direction to Out.
  • Set the latch to High.
pin_config_window_3_1.png
Figure 7: User LED Config

Note: The LEDs on the SAM E70 Xplained and the I/O1 Xplained Pro are active low, so, they are turned off by default by configuring the latch value to logic High.

Step 3.3 - Add and Configure Application Tasks

1

Go to the Project Graph and click on the Core module.

2

Under Configuration Options, you will find that MPLAB Code Configurator (MCC) automatically generates a default application named app. Set the Number of Applications spinbox to 3 and configure each of them as follows:

  • Expand Application 0 Configuration and rename the default application name to "app_sensor".
  • Expand Application 1 Configuration and rename the default application name to "app_eeprom".
  • Expand Application 2 Configuration and rename the default application name to "app_usb".
app_tasks_config.png
Figure 8: Configure Application Tasks



Next Step >

© 2024 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.