1.2 Adding and Configuring the MPLAB Harmony Components
To add and configure the MPLAB Harmony components using MCC, follow these steps:
- In the MCC window, click Project Graph.
- In the Plugins drop-down list (highlighted green in the Figure 1.5), select Clock Configuration .
- 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 - In MCC, under the Device Resources section, click and expand the list of options Harmony > Peripherals > SERCOM .
- 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.
- In the Project Graph window, in the left navigation bar, select SERCOM3 Peripheral Library.
- In the right Configuration Options
property page, configure it as follows to print the LED toggling rate on the Serial
Console.
- 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
- 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.
- From the Plugins item list, select DMA Configuration,
- 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 - 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 - Under the Device Resources section, click and expand Harmony > Peripherals > EIC.
- 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 -
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 - 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.
- 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. - Open NVIC Configuration from
Plugins list and make DMAC_0 Channel as Non-Secure.
Figure 1-15. NVIC Configuration (DMAC_0 as Non-Secure) - 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