Low-Power Application on SAM D21 Using MPLAB® Harmony v3 Peripheral Libraries: Step 4

Last modified by Microchip on 2024/09/13 14:19

Configure Power Manager (PM) Peripheral Library

Under the bottom left Device Resources tab, expand Harmony > Peripherals > PM.

Double-click or drag and drop PM to add the PM peripheral library to the project graph.

PM to the PM peripheral library to the project graph

Figure 1

 

Select the PM Peripheral Library in the Project Graph window and configure it as shown in Figure 2.

PM peripheral library in Project Graph

Figure 2

This completes the configuration of the PM peripheral library. In Standby mode, the CPU as well as the peripherals (except those which are configured to run in Standby mode) are stopped. The Standby Sleep mode provides very low power consumption with little overhead on wake-up time. CPU enters Standby mode by executing the Wait for Interrupt (WFI) instruction and exits from the Standby mode when an interrupt is generated. 

Back to Top


Configure NVMCTRL Peripheral Library

The Non-volatile Memory Controller (NVMCTRL) is added by default to the project graph. Select the NVMCTRL Peripheral Library and configure it as shown in Figure 3.

  • Verify that Wait States is configured as 1 to read the non-volatile memory. When the device is put in performance level 0, the device clock frequency cannot exceed 12 MHz, and one wait state is required.
  • Set the Power Reduction Mode During Sleep to WAKEUP INSTANT. This bit configures the NVMCTRL to wake up the Flash memory when the CPU wakes up from Standby mode, which allows it to reduce device wake-up time.
  • Disable the Instruction Cache to reduce the device's wake-up time. When the cache is enabled, the device will look for an instruction to fetch upon interrupt in the cache at first. If the instruction is found, the device wakes up quicker, but if not, a cache miss occurs and the wake-up time is longer. This option is good to enable when the instruction to fetch upon an interrupt is always stored in the cache memory, which is not the case here, as we have different interrupt sources.
NVMCTRL Peripheral Library Configuration Options

Figure 3

This completes the configuration of the NVMCTRL peripheral library. The NVMCTRL is set to optimize the performance for waking the device up while keeping the power consumption as low as possible.

Back to Top


Configure LED and Wake-up Test Pins

Open the Pin Configuration tab by clicking Tools > Pin Configuration.

Project Graph tab Plugins drop-down

Figure 4

 

Once the Pin Settings window is opened, scroll down to pin numbers PA27 and PB30, and then configure these pins as shown in Figure 5:

  • Set the Pin Number #51 as GPIO:
    • Pin ID = PA27
    • Custom Name = WAKEUP_TEST
    • Function = GPIO
    • Direction = Out
    • Latch = High
  • Set the Pin Number #59 as GPIO:
    • Pin ID = PB30
    • Custom Name = LED0
    • Function = GPIO
    • Direction = Out
    • Latch = High
Pin Settings window

Figure 5

In the previous step, the user LED is configured as per the following USER_LED design schematic on the SAM D21 Xplained Pro Evaluation Kit.
USER_LED design schematic

Back to Top