1.1 Adding and Configuring the MPLAB Harmony Components

To add and configure MPLAB Harmony components using the MCC, follow these steps:

  1. In the MCC window, click Project Graph.
    Figure 1-6. MPLAB Code Configurator
  2. In the Plugins drop-down list, select Clock Configuration. The Clock Easy View window will be displayed, verify that the Main Clock is set to 48 MHz.
    Note: Make sure to make the following modification for the GCLK Generator 1.
    Figure 1-7. MPLAB Code Configurator - GCLK Generator One
  3. Under Device Resources, expand the list of options Harmony > Peripherals > SERCOM.
  4. Click SERCOM4 and observe that the SERCOM4 Peripheral Library block is added in the Project Graph window.
    Figure 1-8. MPLAB Code Configurator - Selection of Peripherals
    Note: Users can also select other peripherals under Device Resources, Harmony > Peripherals.
  5. In the Project Graph window, in the left Navigation bar, select SERCOM4 Peripheral Library. In the right Configuration Options property page, configure it as follows to print the data on the Serial Console at 115200 baud rate.
    Figure 1-9. MPLAB Code Configurator - SERCOM4 Configuration
  6. Under Device Resources expand the list of options Harmony > Peripherals > EIC. Click EIC and observe that the EIC Peripheral Library block is added in the Project Graph window.
  7. In the right Configuration Options property page, select the Enable Interrupt check box and the Enable EIC Channel3 check box for the switch press event.
    Figure 1-10. MPLAB Code Configurator - EIC Configuration
  8. Under Device Resources expand the list of options Harmony > Peripherals > RTC. Click RTC and observe that the RTC Peripheral Library block is added in the Project Graph window to generate a compare interrupt every 500 milliseconds. Slect the Compate 0 Interrupt Enable check box.
    Note: The Compare Value is set as 0x200. This compare value generates an RTC compare interrupt every 500 milliseconds.

    RTC clock = 1024 Hz

    RTC Prescaler = 1

    Required Interrupt rate = 500 ms

    Hence, Compare Value = (500/1000) x 1024 = 512 (i.e., 0x200)

    Figure 1-11. MPLAB Code Configurator - RTC PLIB Configuration
  9. From the Plugins drop-down list, select Add Channel and then select DMA Configuration. Configure the DMA Channel 0 to transmit application buffer to the USART TX register. The DMA transfers one byte from the user buffer to the USART transmit buffer on each trigger.
    Figure 1-12. MPLAB Code Configurator - DMA Configuration
  10. From the Plugins drop-down list select Pin Configuration and then click Pin Settings.
  11. In the Order box, type or select Ports. Build configurations according to the application as indicated below. Change the Custom Name of the pin IDs, PC05 and PB19, as shown in the following figure.
    Figure 1-13. Pin Settings Window - SERCOM, EIC and LED Pin Configuration