Getting Started With MPLAB® Harmony v3 Peripheral Libraries on PIC32CM JH (Arm® Cortex®-M0+) MCUs: Step 2
Configure RTC Peripheral Library
Configure RTC Peripheral Library
Under the bottom left Device Resources tab, expand Harmony > Peripherals > RTC.
Double-click or drag and drop RTC to add the RTC Peripheral Library (PLIB) to the Project Graph.
In the Clock Easy view, verify the RTC clock is set to run at 1 kHz internal ultra-low-power clock.
When a module is added to the Project Graph, MPLAB® Code Configurator (MCC) automatically enables the clock to the module. The default RTC clock source is an internal 1 kHz ultra-low-power clock (OSCULP1K).
Go back to the Project Graph and configure the RTC PLIB to generate a compare interrupt every 500 milliseconds.
Configure USART Peripheral Library and USART Pins
Under the tab Device Resources tab, expand Harmony > Peripheral > SERCOM.
Double-click on SERCOM1 to add the SERCOM instance 1 to the project.
Select the SERCOM1 Peripheral Library in the Project Graph and verify default SERCOM Operation Mode configuration is set as USART. Configure it as shown in the following figure. Verify that the default baud rate is set to 115200 Hz.
Open the Pin Configuration tabs by clicking MCC > Project Graph > Plugins > Pin Configuration. Sort the entries by Ports, as shown in the accompanying image.
Scroll down to the SERCOM1 module. Enable USART_TX (SERCOM_PAD0) on PA16 (Pin #35).
Configure DMA Peripheral Library
Configure DMA by selecting the System block in the Project Graph. In Configuration Options navigate to DMA.
Expand DMA . Enable DMA Channel 0.
Expand DMA Channel 0 and configure it to transmit the application buffer to the USART TX register. The DMA transfers one byte from the user buffer to the USART transmit buffer on each trigger.
Based on the trigger source, the DMA channel configuration is automatically set by MCC.
- Trigger Action is the action taken by the DMA when it receives a trigger.
- Cell Transfer refers to the number of bytes transferred when a DMA channel has a transfer initiated before waiting for another event. A cell transfer consists of one or more transactions. It is generally used during a memory-to-peripheral or peripheral-to-memory transfer.
- Block Transfer refers to the number of bytes transferred when a channel is enabled. The number of bytes is the larger of either the Source or Destination size. A block transfer consists of one or more cell transfers and is generally used during a memory-to-memory transfer that is initiated by a software trigger.
- The Source Address Mode and Destination Address Mode settings determine whether the Source or Destination Address is incremented after every transfer. The modes are automatically set by MCC based on the trigger type. For example, if the trigger source is a USART transmit, then the Source Address is incremented and the Destination Address remains fixed. Conversely, if the trigger source is a USART receive, then the Source Address remains fixed and the Destination Address is incremented.
Launch NVIC Configuration by selecting Project Graph > Plugins > NVIC Configuration.
Click on the NVIC settings tab. Verify DMA Channel 0 settings.