Microchip® Advanced Software Framework

Advanced use case - Switch Power Scaling Modes

In this use case, the BPM module can switch the power scaling modes of the system.

Check the current of the system to see consumptions.

Setup

Prerequisites

Some power scaling modes only work on limited system clock frequency (The maximum CPU frequency under PS1 is 12MHz, other peripherals also have speed limitations), please refer to the electrical characteristics for more details.

  1. Clock management

Code

Content of conf_clock.h

#define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RCFAST // Uses Fast RC
#define CONFIG_RCFAST_FRANGE 2 // Fast RC is 12MHz

Workflow

  1. Ensure that conf_clock.h is available and contains the following parameters which configure system clock to 12MHz fast RC:
    #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RCFAST // Uses Fast RC
    #define CONFIG_RCFAST_FRANGE 2 // Fast RC is 12MHz
  2. Initialize system clock with sysclk_init().

Use case

Example code

Add to application C-file:

bpm_power_scaling_cpu(BPM, BPM_PMCON_PS(BPM_PS_1));
while((bpm_get_status(BPM) & BPM_SR_PSOK) == 0);
while(1);

Workflow

  1. Switch the power scaling mode:
    bpm_power_scaling_cpu(BPM, BPM_PMCON_PS(BPM_PS_1));
  2. Wait power scaling done:
    while((bpm_get_status(BPM) & BPM_SR_PSOK) == 0);