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 peripheral is 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  bod12_config
 Configuration structure for a BOD12 module. More...
 
struct  bod33_config
 Configuration structure for a BOD33 module. More...
 

Enumerations

enum  bod12_action {
  BOD12_ACTION_NONE = SUPC_BOD12_ACTION(0),
  BOD12_ACTION_RESET = SUPC_BOD12_ACTION(1),
  BOD12_ACTION_INTERRUPT = SUPC_BOD12_ACTION(2)
}
 Brown Out Detector detection actions. More...
 
enum  bod12_mode_in_active {
  BOD12_ACTCFG_CONTINUOUS = 0,
  BOD12_ACTCFG_SAMPLED = SUPC_BOD12_ACTCFG
}
 Brown Out Detector sampling modes in active sleep mode. More...
 
enum  bod12_mode_in_standby {
  BOD12_STDBYCFG_CONTINUOUS = 0,
  BOD12_STDBYCFG_SAMPLED = SUPC_BOD12_STDBYCFG
}
 Brown Out Detector sampling modes in standby sleep mode. More...
 
enum  bod12_prescale {
  BOD12_PRESCALE_DIV_2 = SUPC_BOD12_PSEL(0),
  BOD12_PRESCALE_DIV_4 = SUPC_BOD12_PSEL(1),
  BOD12_PRESCALE_DIV_8 = SUPC_BOD12_PSEL(2),
  BOD12_PRESCALE_DIV_16 = SUPC_BOD12_PSEL(3),
  BOD12_PRESCALE_DIV_32 = SUPC_BOD12_PSEL(4),
  BOD12_PRESCALE_DIV_64 = SUPC_BOD12_PSEL(5),
  BOD12_PRESCALE_DIV_128 = SUPC_BOD12_PSEL(6),
  BOD12_PRESCALE_DIV_256 = SUPC_BOD12_PSEL(7),
  BOD12_PRESCALE_DIV_512 = SUPC_BOD12_PSEL(8),
  BOD12_PRESCALE_DIV_1024 = SUPC_BOD12_PSEL(9),
  BOD12_PRESCALE_DIV_2048 = SUPC_BOD12_PSEL(10),
  BOD12_PRESCALE_DIV_4096 = SUPC_BOD12_PSEL(11),
  BOD12_PRESCALE_DIV_8192 = SUPC_BOD12_PSEL(12),
  BOD12_PRESCALE_DIV_16384 = SUPC_BOD12_PSEL(13),
  BOD12_PRESCALE_DIV_32768 = SUPC_BOD12_PSEL(14),
  BOD12_PRESCALE_DIV_65536 = SUPC_BOD12_PSEL(15)
}
 Brown Out Detector input clock prescale values. More...
 
enum  bod33_action {
  BOD33_ACTION_NONE = SUPC_BOD33_ACTION(0),
  BOD33_ACTION_RESET = SUPC_BOD33_ACTION(1),
  BOD33_ACTION_INTERRUPT = SUPC_BOD33_ACTION(2),
  BOD33_ACTION_BACKUP = SUPC_BOD33_ACTION(3)
}
 Brown Out Detector detection actions. More...
 
enum  bod33_mode_in_active {
  BOD33_ACTCFG_CONTINUOUS = 0,
  BOD33_ACTCFG_SAMPLED = SUPC_BOD33_ACTCFG
}
 Brown Out Detector sampling modes in active sleep mode. More...
 
enum  bod33_mode_in_standby {
  BOD33_STDBYCFG_CONTINUOUS = 0,
  BOD33_STDBYCFG_SAMPLED = SUPC_BOD33_STDBYCFG
}
 Brown Out Detector sampling modes in standby sleep mode. More...
 
enum  bod33_prescale {
  BOD33_PRESCALE_DIV_2 = SUPC_BOD33_PSEL(0),
  BOD33_PRESCALE_DIV_4 = SUPC_BOD33_PSEL(1),
  BOD33_PRESCALE_DIV_8 = SUPC_BOD33_PSEL(2),
  BOD33_PRESCALE_DIV_16 = SUPC_BOD33_PSEL(3),
  BOD33_PRESCALE_DIV_32 = SUPC_BOD33_PSEL(4),
  BOD33_PRESCALE_DIV_64 = SUPC_BOD33_PSEL(5),
  BOD33_PRESCALE_DIV_128 = SUPC_BOD33_PSEL(6),
  BOD33_PRESCALE_DIV_256 = SUPC_BOD33_PSEL(7),
  BOD33_PRESCALE_DIV_512 = SUPC_BOD33_PSEL(8),
  BOD33_PRESCALE_DIV_1024 = SUPC_BOD33_PSEL(9),
  BOD33_PRESCALE_DIV_2048 = SUPC_BOD33_PSEL(10),
  BOD33_PRESCALE_DIV_4096 = SUPC_BOD33_PSEL(11),
  BOD33_PRESCALE_DIV_8192 = SUPC_BOD33_PSEL(12),
  BOD33_PRESCALE_DIV_16384 = SUPC_BOD33_PSEL(13),
  BOD33_PRESCALE_DIV_32768 = SUPC_BOD33_PSEL(14),
  BOD33_PRESCALE_DIV_65536 = SUPC_BOD33_PSEL(15)
}
 Brown Out Detector input clock prescale values. More...
 
enum  bod33_vol_monitor {
  BOD33_VMON_VDD = 0,
  BOD33_VMON_VBAT = SUPC_BOD33_VMON
}
 Brown Out Detector voltage monitors. More...
 

Configuration and Initialization

static void bod33_get_config_defaults (struct bod33_config *const conf)
 Get default BOD33 configuration. More...
 
enum status_code bod33_set_config (struct bod33_config *const conf)
 Configure a Brown Out Detector module. More...
 
static enum status_code bod33_enable (void)
 Enables a configured BOD33 module. More...
 
static enum status_code bod33_disable (void)
 Disables an enabled BOD33 module. More...
 
static bool bod33_is_detected (void)
 Checks if the BOD33 low voltage detection has occurred. More...
 
static void bod33_clear_detected (void)
 Clears the low voltage detection state of the BOD33. More...
 
static void bod12_get_config_defaults (struct bod12_config *const conf)
 Get default BOD12 configuration. More...
 
enum status_code bod12_set_config (struct bod12_config *const conf)
 Configure a Brown Out Detector module. More...
 
static enum status_code bod12_enable (void)
 Enables a configured BOD12 module. More...
 
static enum status_code bod12_disable (void)
 Disables an enabled BOD12 module. More...
 
static bool bod12_is_detected (void)
 Checks if the BOD12 low voltage detection has occurred. More...
 
static void bod12_clear_detected (void)
 Clears the low voltage detection state of the BOD12. More...
 

Brown Out Detector detection actions.

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

Enumerator
BOD12_ACTION_NONE 

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

BOD12_ACTION_RESET 

A BOD12 detect will reset the device.

BOD12_ACTION_INTERRUPT 

A BOD12 detect will fire an interrupt.

Brown Out Detector sampling modes in active sleep mode.

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

Enumerator
BOD12_ACTCFG_CONTINUOUS 

BOD12 will sample the supply line continuously.

BOD12_ACTCFG_SAMPLED 

BOD12 will use the BOD12 sampling clock (1KHz) to sample the supply line.

Brown Out Detector sampling modes in standby sleep mode.

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

Enumerator
BOD12_STDBYCFG_CONTINUOUS 

BOD12 will sample the supply line continuously.

BOD12_STDBYCFG_SAMPLED 

BOD12 will use the BOD12 sampling clock (1KHz) to sample the supply line.

Brown Out Detector input clock prescale values.

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

Enumerator
BOD12_PRESCALE_DIV_2 

Divide input prescaler clock by 2.

BOD12_PRESCALE_DIV_4 

Divide input prescaler clock by 4.

BOD12_PRESCALE_DIV_8 

Divide input prescaler clock by 8.

BOD12_PRESCALE_DIV_16 

Divide input prescaler clock by 16.

BOD12_PRESCALE_DIV_32 

Divide input prescaler clock by 32.

BOD12_PRESCALE_DIV_64 

Divide input prescaler clock by 64.

BOD12_PRESCALE_DIV_128 

Divide input prescaler clock by 128.

BOD12_PRESCALE_DIV_256 

Divide input prescaler clock by 256.

BOD12_PRESCALE_DIV_512 

Divide input prescaler clock by 512.

BOD12_PRESCALE_DIV_1024 

Divide input prescaler clock by 1024.

BOD12_PRESCALE_DIV_2048 

Divide input prescaler clock by 2048.

BOD12_PRESCALE_DIV_4096 

Divide input prescaler clock by 4096.

BOD12_PRESCALE_DIV_8192 

Divide input prescaler clock by 8192.

BOD12_PRESCALE_DIV_16384 

Divide input prescaler clock by 16384.

BOD12_PRESCALE_DIV_32768 

Divide input prescaler clock by 32768.

BOD12_PRESCALE_DIV_65536 

Divide input prescaler clock by 65536.

Brown Out Detector detection actions.

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

Enumerator
BOD33_ACTION_NONE 

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

BOD33_ACTION_RESET 

A BOD33 detect will reset the device.

BOD33_ACTION_INTERRUPT 

A BOD33 detect will fire an interrupt.

BOD33_ACTION_BACKUP 

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

Brown Out Detector sampling modes in active sleep mode.

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

Enumerator
BOD33_ACTCFG_CONTINUOUS 

BOD33 will sample the supply line continuously.

BOD33_ACTCFG_SAMPLED 

BOD33 will use the BOD33 sampling clock (1KHz) to sample the supply line.

Brown Out Detector sampling modes in standby sleep mode.

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

Enumerator
BOD33_STDBYCFG_CONTINUOUS 

BOD33 will sample the supply line continuously.

BOD33_STDBYCFG_SAMPLED 

BOD33 will use the BOD33 sampling clock (1KHz) to sample the supply line.

Brown Out Detector input clock prescale values.

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

Enumerator
BOD33_PRESCALE_DIV_2 

Divide input prescaler clock by 2.

BOD33_PRESCALE_DIV_4 

Divide input prescaler clock by 4.

BOD33_PRESCALE_DIV_8 

Divide input prescaler clock by 8.

BOD33_PRESCALE_DIV_16 

Divide input prescaler clock by 16.

BOD33_PRESCALE_DIV_32 

Divide input prescaler clock by 32.

BOD33_PRESCALE_DIV_64 

Divide input prescaler clock by 64.

BOD33_PRESCALE_DIV_128 

Divide input prescaler clock by 128.

BOD33_PRESCALE_DIV_256 

Divide input prescaler clock by 256.

BOD33_PRESCALE_DIV_512 

Divide input prescaler clock by 512.

BOD33_PRESCALE_DIV_1024 

Divide input prescaler clock by 1024.

BOD33_PRESCALE_DIV_2048 

Divide input prescaler clock by 2048.

BOD33_PRESCALE_DIV_4096 

Divide input prescaler clock by 4096.

BOD33_PRESCALE_DIV_8192 

Divide input prescaler clock by 8192.

BOD33_PRESCALE_DIV_16384 

Divide input prescaler clock by 16384.

BOD33_PRESCALE_DIV_32768 

Divide input prescaler clock by 32768.

BOD33_PRESCALE_DIV_65536 

Divide input prescaler clock by 65536.

Brown Out Detector voltage monitors.

List of possible BOD33 module voltage monitored in active and standby mode.

Enumerator
BOD33_VMON_VDD 

The BOD33 monitors the VDD power pin in active and standby mode.

BOD33_VMON_VBAT 

The BOD33 monitors the VBAT power pin in active and standby mode.

static void bod12_clear_detected ( void  )
inlinestatic

Clears the low voltage detection state of the BOD12.

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

static enum status_code bod12_disable ( void  )
inlinestatic

Disables an enabled BOD12 module.

Disables the BOD12 module that was previously enabled.

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

References STATUS_OK.

static enum status_code bod12_enable ( void  )
inlinestatic

Enables a configured BOD12 module.

Enables the BOD12 module that has been previously configured.

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

References STATUS_OK.

static void bod12_get_config_defaults ( struct bod12_config *const  conf)
inlinestatic

Get default BOD12 configuration.

The default BOD12 configuration is:

  • Clock prescaler set to divide the input clock by two
  • Continuous in active mode
  • Continuous in standby mode
  • Reset on BOD12 detect
  • Hysteresis enabled
  • BOD12 level 0x12
  • BOD12 kept enabled during device sleep
Parameters
[out]confBOD12 configuration struct to set to default settings

References bod12_config::action, Assert, BOD12_ACTCFG_CONTINUOUS, BOD12_ACTION_RESET, BOD12_PRESCALE_DIV_2, BOD12_STDBYCFG_CONTINUOUS, bod12_config::hysteresis, bod12_config::level, bod12_config::mode_in_active, bod12_config::mode_in_standby, bod12_config::prescaler, and bod12_config::run_in_standby.

static bool bod12_is_detected ( void  )
inlinestatic

Checks if the BOD12 low voltage detection has occurred.

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

Returns
Detection status of the BOD12.
Return values
trueIf the BOD12 has detected a low voltage condition
falseIf the BOD12 has not detected a low voltage condition
enum status_code bod12_set_config ( struct bod12_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 BOD12
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 bod12_config::action, Assert, bod12_config::hysteresis, bod12_config::level, bod12_config::mode_in_active, bod12_config::mode_in_standby, bod12_config::prescaler, bod12_config::run_in_standby, STATUS_ERR_INVALID_ARG, and STATUS_OK.

static void bod33_clear_detected ( void  )
inlinestatic

Clears the low voltage detection state of the BOD33.

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

static enum status_code bod33_disable ( void  )
inlinestatic

Disables an enabled BOD33 module.

Disables the BOD33 module that was previously enabled.

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

References STATUS_OK.

static enum status_code bod33_enable ( void  )
inlinestatic

Enables a configured BOD33 module.

Enables the BOD33 module that has been previously configured.

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

References STATUS_OK.

static void bod33_get_config_defaults ( struct bod33_config *const  conf)
inlinestatic

Get default BOD33 configuration.

The default BOD33 configuration is:

  • Clock prescaler set to divide the input clock by two
  • Continuous in active mode
  • Continuous in standby mode
  • Monitor the VDD power pin
  • No action on BOD33 detect
  • Hysteresis enabled
  • BOD33 level 0x7 on VDD
  • BOD33 level 0x7 on VBAT
  • BOD33 kept enabled during device sleep
  • BOD33 kept enabled during standby
Parameters
[out]confBOD33 configuration struct to set to default settings

References bod33_config::action, Assert, bod33_config::backuplevel, BOD33_ACTCFG_CONTINUOUS, BOD33_ACTION_NONE, BOD33_PRESCALE_DIV_2, BOD33_STDBYCFG_CONTINUOUS, BOD33_VMON_VDD, bod33_config::hysteresis, bod33_config::level, bod33_config::mode_in_active, bod33_config::mode_in_standby, bod33_config::monitor, bod33_config::prescaler, bod33_config::run_in_backup, and bod33_config::run_in_standby.

static bool bod33_is_detected ( void  )
inlinestatic

Checks if the BOD33 low voltage detection has occurred.

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

Returns
Detection status of the BOD33.
Return values
trueIf the BOD33 has detected a low voltage condition
falseIf the BOD33 has not detected a low voltage condition
enum status_code bod33_set_config ( struct bod33_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 BOD33
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 bod33_config::action, Assert, bod33_config::backuplevel, bod33_config::hysteresis, bod33_config::level, bod33_config::mode_in_active, bod33_config::mode_in_standby, bod33_config::monitor, bod33_config::prescaler, bod33_config::run_in_backup, bod33_config::run_in_standby, STATUS_ERR_INVALID_ARG, and STATUS_OK.