1.2 Adding and Configuring the MPLAB Harmony Components

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

  1. In the MCC window, click Project Graph.
  2. In the Plugins drop-down list (highlighted green in the Figure 1.5), select Clock Configuration .
  3. This opens the Clock Easy View window, which embedded within MCC. Verify that the Main Clock is set to 48 MHz.
    Figure 1-6. Clock Easy View Window
  4. In MCC, under the Device Resources section, click and expand the list of options Harmony > Peripherals > SERCOM .
  5. Click SERCOM3 to add. Observe that the SERCOM3 Peripheral Library block is added in the Project Graph window.
    Note: Similarly users can select and add all peripherals, available under Device Resources > Harmony > Peripherals.
  6. In the Project Graph window, in the left navigation bar, select SERCOM3 Peripheral Library.
  7. In the right Configuration Options property page, configure it as follows to print the LED toggling rate on the Serial Console.
    1. For Receive Pinout, from the drop-down list, select SERCOM PAD[1] and leave the remaining parameters with the default setting as shown in the figure below.
      Figure 1-7. MPLAB Code Configurator – SERCOM3 Configuration Window
  8. From the Plugins item list, select DMA Configuration,
  9. In the DMA Configuratin dialogue box, click Add Channel and configure 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-8.  DMA Configuration
  10. Under Device Resources, click and expand Harmony > Peripherals > RTC. Click on the RTC to add, and then observe that the RTC Peripheral Library block is added in the Project Graph window to generate a compare interrupt every 500 milliseconds.
    Figure 1-9.  RTC PLIB Configuration
  11. Under the Device Resources section, click and expand Harmony > Peripherals > EIC.
  12. Click on the EIC to add, and then observe that the EIC Peripheral Library block is added in the Project Graph window.
    Figure 1-10. Enable EIC Channel 12
  13. Click on the EIC Peripheral Library, and then expand Enable EIC Channel 12 and configure by selecting the options as shown below.

    Figure 1-11. MPLAB Code Configurator – EIC PLIB Configuration
  14. Select Arm TrustZone for Armv8-M from the Plugins list, and then check Memory Configuration for Secure and Non-Secure regions of the application.
    Figure 1-12. Arm TrustZone Memory Configuration Window
    Note: The markers can be used to configure the memory if there are any changes needed in the memory configuration. It is recommended not to change the default configuration for this application.
    The memory can be configured using a Tree view interface by selecting System and following the highlighted options in the below screenshot.
    Figure 1-13. Memory Configuration using System

    The Application Non-Secure Callable (ANSC) memory size has been increased to accommodate memory space if users required to add code in future.

  15. Under plugin list select Arm TrustZone for Armv8-M, and then open Peripheral Configuration and select SERCOM3 and DMAC boxes as Non-Secure peripherals. Upon selection the box color will change from green to orange.
    Figure 1-14. SERCOM3 and DMAC Peripheral Configuration
    Note: The SERCOM3 and DMA peripheral libraries are configured as Non-Secure peripherals. These libraries obtain the LED toggling rate from the Secure application through NSCs (Non-Secure Callable) APIs to print the LED toggling rate on a Serial Console running on a PC.
  16. Open NVIC Configuration from Plugins list and make DMAC_0 Channel as Non-Secure.
    Figure 1-15. NVIC Configuration (DMAC_0 as Non-Secure)
  17. Open the Pin Configuration window from the Plugins list and configure the required pins as shown below:
    Figure 1-16. SERCOM3 Pin Configuration
    Figure 1-17. Switch and LED Pin Configuration