Microchip® Advanced Software Framework

Quick start guide for the SAM BPM module

This is the quick start guide for the BPM Module, with step-by-step instructions on how to configure and use the driver in a selection of use cases.

The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.

BPM use cases

Basic use case - Entering Sleep Modes

In this use case, the BPM module can put system into different power saving modes. Check the current of the system to see consumptions.

Setup

Prerequisites

Sleep mode itself does not require any IO input, but to wakeup an interrupt is needed.

  1. Common IOPORT (for GPIO)
  2. External Interrupt Controller (EIC)

Code

#define EIC_INT5_ENABLE

The following code needs to be added to the user application, to wakeup system and switch to next power mode.

static void push_button_eic_handler()
{
eic_line_clear_interrupt(EIC, GPIO_PUSH_BUTTON_EIC_LINE);
}
my_eic_init()
{
struct eic_line_config eic_opt={
EIC_MODE_EDGE_TRIGGERED,
EIC_EDGE_FALLING_EDGE,
EIC_LEVEL_LOW_LEVEL,
EIC_FILTER_DISABLED,
EIC_ASYNCH_MODE
};
eic_enable(EIC);
eic_line_set_config(EIC, GPIO_PUSH_BUTTON_EIC_LINE, &eic_opt);
eic_line_set_callback(EIC, GPIO_PUSH_BUTTON_EIC_LINE,
push_button_eic_handler, EIC_5_IRQn, 1);
eic_line_enable(EIC, GPIO_PUSH_BUTTON_EIC_LINE);
}

Workflow

  1. Ensure that ioport and eic driver is available.
  2. Ensure that push button is configured as external interrupt in conf_board.h:
    #define CONF_BOARD_EIC
  3. Add EIC initialize to application C-file:
    my_eic_init();

Use case

Example code

Add to application C-file:

// Enable wakeup by EIC
bpm_enable_wakeup_source(BPM, 1 << BPM_BKUPWEN_EIC);
// Enable backup wakeup by Push button EIC line
// Retain I/O lines after wakeup from backup mode
// Enable fast wakeup
// Enter wait mode
// critical section when going to sleep
// Enter retention mode
// Enter backup mode
while(1);

Workflow

  1. Enable wakeup by EIC:
  2. Setup IO retention:
  3. Setup fast wakeup:
  4. Enter sleep/wait/backup mode:
    // critical section when going to sleep