Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SAM Brown Out Detector (BOD) Driver

This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the device's Brown Out Detector (BOD) modules, to detect and respond to under-voltage events and take an appropriate action.

The following peripherals are used by this module:

The following devices can use this module:

The outline of this documentation is as follows:

Prerequisites

There are no prerequisites for this module.

Module Overview

The SAM devices contain a number of Brown Out Detector (BOD) modules. Each BOD monitors the supply voltage for any dips that go below the set threshold for the module. In case of a BOD detection the BOD will either reset the system or raise a hardware interrupt so that a safe power-down sequence can be attempted.

Special Considerations

The time between a BOD interrupt being raised and a failure of the processor to continue executing (in the case of a core power failure) is system specific; care must be taken that all critical BOD detection events can complete within the amount of time available.

Extra Information

For extra information, see Extra Information for BOD Driver. This includes:

Examples

For a list of examples related to this driver, see Examples for BOD Driver.

API Overview

Data Structures

struct  bodvdd_config
 Configuration structure for a BODVDD module. More...
 

Enumerations

enum  bodvdd_action {
  BODVDD_ACTION_NONE = SUPC_BODVDD_ACTION(0),
  BODVDD_ACTION_RESET = SUPC_BODVDD_ACTION(1),
  BODVDD_ACTION_INTERRUPT = SUPC_BODVDD_ACTION(2),
  BODVDD_ACTION_BACKUP = SUPC_BODVDD_ACTION(3)
}
 Brown Out Detector detection actions. More...
 
enum  bodvdd_mode_in_active {
  BODVDD_ACTCFG_CONTINUOUS = 0,
  BODVDD_ACTCFG_SAMPLED = SUPC_BODVDD_ACTCFG
}
 Brown Out Detector sampling modes in active sleep mode. More...
 
enum  bodvdd_mode_in_standby {
  BODVDD_STDBYCFG_CONTINUOUS = 0,
  BODVDD_STDBYCFG_SAMPLED = SUPC_BODVDD_STDBYCFG
}
 Brown Out Detector sampling modes in standby sleep mode. More...
 
enum  bodvdd_prescale {
  BODVDD_PRESCALE_DIV_2 = SUPC_BODVDD_PSEL(0),
  BODVDD_PRESCALE_DIV_4 = SUPC_BODVDD_PSEL(1),
  BODVDD_PRESCALE_DIV_8 = SUPC_BODVDD_PSEL(2),
  BODVDD_PRESCALE_DIV_16 = SUPC_BODVDD_PSEL(3),
  BODVDD_PRESCALE_DIV_32 = SUPC_BODVDD_PSEL(4),
  BODVDD_PRESCALE_DIV_64 = SUPC_BODVDD_PSEL(5),
  BODVDD_PRESCALE_DIV_128 = SUPC_BODVDD_PSEL(6),
  BODVDD_PRESCALE_DIV_256 = SUPC_BODVDD_PSEL(7),
  BODVDD_PRESCALE_DIV_512 = SUPC_BODVDD_PSEL(8),
  BODVDD_PRESCALE_DIV_1024 = SUPC_BODVDD_PSEL(9),
  BODVDD_PRESCALE_DIV_2048 = SUPC_BODVDD_PSEL(10),
  BODVDD_PRESCALE_DIV_4096 = SUPC_BODVDD_PSEL(11),
  BODVDD_PRESCALE_DIV_8192 = SUPC_BODVDD_PSEL(12),
  BODVDD_PRESCALE_DIV_16384 = SUPC_BODVDD_PSEL(13),
  BODVDD_PRESCALE_DIV_32768 = SUPC_BODVDD_PSEL(14),
  BODVDD_PRESCALE_DIV_65536 = SUPC_BODVDD_PSEL(15)
}
 Brown Out Detector input clock prescale values. More...
 

Configuration and Initialization

static void bodvdd_get_config_defaults (struct bodvdd_config *const conf)
 Get default BODVDD configuration. More...
 
enum status_code bodvdd_set_config (struct bodvdd_config *const conf)
 Configure a Brown Out Detector module. More...
 
static enum status_code bodvdd_enable (void)
 Enables a configured BODVDD module. More...
 
static enum status_code bodvdd_disable (void)
 Disables an enabled BODVDD module. More...
 
static bool bodvdd_is_detected (void)
 Checks if the BODVDD low voltage detection has occurred. More...
 
static void bodvdd_clear_detected (void)
 Clears the low voltage detection state of the BODVDD. More...
 

Brown Out Detector detection actions.

List of possible BODVDD actions when a BODVDD module detects a brown-out condition.

Enumerator
BODVDD_ACTION_NONE 

A BODVDD detect will do nothing, and the BODVDD state must be polled.

BODVDD_ACTION_RESET 

A BODVDD detect will reset the device.

BODVDD_ACTION_INTERRUPT 

A BODVDD detect will fire an interrupt.

BODVDD_ACTION_BACKUP 

A BODVDD detect will put the device in backup sleep mode.

Brown Out Detector sampling modes in active sleep mode.

List of possible BODVDD module voltage sampling modes in active sleep mode.

Enumerator
BODVDD_ACTCFG_CONTINUOUS 

BODVDD will sample the supply line continuously.

BODVDD_ACTCFG_SAMPLED 

BODVDD will use the BODVDD sampling clock (1kHz) to sample the supply line.

Brown Out Detector sampling modes in standby sleep mode.

List of possible BODVDD module voltage sampling modes in standby sleep mode.

Enumerator
BODVDD_STDBYCFG_CONTINUOUS 

BODVDD will sample the supply line continuously.

BODVDD_STDBYCFG_SAMPLED 

BODVDD will use the BODVDD sampling clock (1kHz) to sample the supply line.

Brown Out Detector input clock prescale values.

List of possible BODVDD controller prescaler values, to reduce the sampling speed of a BODVDD to lower the power consumption.

Enumerator
BODVDD_PRESCALE_DIV_2 

Divide input prescaler clock by 2.

BODVDD_PRESCALE_DIV_4 

Divide input prescaler clock by 4.

BODVDD_PRESCALE_DIV_8 

Divide input prescaler clock by 8.

BODVDD_PRESCALE_DIV_16 

Divide input prescaler clock by 16.

BODVDD_PRESCALE_DIV_32 

Divide input prescaler clock by 32.

BODVDD_PRESCALE_DIV_64 

Divide input prescaler clock by 64.

BODVDD_PRESCALE_DIV_128 

Divide input prescaler clock by 128.

BODVDD_PRESCALE_DIV_256 

Divide input prescaler clock by 256.

BODVDD_PRESCALE_DIV_512 

Divide input prescaler clock by 512.

BODVDD_PRESCALE_DIV_1024 

Divide input prescaler clock by 1024.

BODVDD_PRESCALE_DIV_2048 

Divide input prescaler clock by 2048.

BODVDD_PRESCALE_DIV_4096 

Divide input prescaler clock by 4096.

BODVDD_PRESCALE_DIV_8192 

Divide input prescaler clock by 8192.

BODVDD_PRESCALE_DIV_16384 

Divide input prescaler clock by 16384.

BODVDD_PRESCALE_DIV_32768 

Divide input prescaler clock by 32768.

BODVDD_PRESCALE_DIV_65536 

Divide input prescaler clock by 65536.

static void bodvdd_clear_detected ( void  )
inlinestatic

Clears the low voltage detection state of the BODVDD.

Clears the low voltage condition of the BODVDD module, so that new low voltage conditions can be detected.

static enum status_code bodvdd_disable ( void  )
inlinestatic

Disables an enabled BODVDD module.

Disables the BODVDD module that was previously enabled.

Returns
Error code indicating the status of the disable operation.
Return values
STATUS_OKIf the BODVDD was successfully disabled

References STATUS_OK.

static enum status_code bodvdd_enable ( void  )
inlinestatic

Enables a configured BODVDD module.

Enables the BODVDD module that has been previously configured.

Returns
Error code indicating the status of the enable operation.
Return values
STATUS_OKIf the BODVDD was successfully enabled

References STATUS_OK.

static void bodvdd_get_config_defaults ( struct bodvdd_config *const  conf)
inlinestatic

Get default BODVDD configuration.

The default BODVDD configuration is:

  • Clock prescaler set to divide the input clock by two
  • Continuous in active mode
  • Continuous in standby mode
  • Reset on BODVDD detect
  • Hysteresis enabled
  • BODVDD level 42 on VDD
  • BODVDD kept enabled during standby
Parameters
[out]confBODVDD configuration struct to set to default settings

References bodvdd_config::action, Assert, BODVDD_ACTCFG_CONTINUOUS, BODVDD_ACTION_RESET, BODVDD_PRESCALE_DIV_2, BODVDD_STDBYCFG_CONTINUOUS, bodvdd_config::hysteresis, bodvdd_config::level, bodvdd_config::mode_in_active, bodvdd_config::mode_in_standby, bodvdd_config::prescaler, and bodvdd_config::run_in_standby.

static bool bodvdd_is_detected ( void  )
inlinestatic

Checks if the BODVDD low voltage detection has occurred.

Determines if the BODVDD has detected a voltage lower than its configured threshold.

Returns
Detection status of the BODVDD.
Return values
trueIf the BODVDD has detected a low voltage condition
falseIf the BODVDD has not detected a low voltage condition
enum status_code bodvdd_set_config ( struct bodvdd_config *const  conf)

Configure a Brown Out Detector module.

Configures a given BOD module with the settings stored in the given configuration structure.

Parameters
[in]confConfiguration settings to use for the specified BODVDD
Return values
STATUS_OKOperation completed successfully
STATUS_ERR_INVALID_ARGAn invalid BOD was supplied
STATUS_ERR_INVALID_OPTIONThe requested BOD level was outside the acceptable range

References bodvdd_config::action, Assert, bodvdd_config::hysteresis, bodvdd_config::level, bodvdd_config::mode_in_active, bodvdd_config::mode_in_standby, bodvdd_config::prescaler, bodvdd_config::run_in_standby, STATUS_ERR_INVALID_ARG, and STATUS_OK.