Merge pull request #3130 from pewpew-game/brownout-level

SAMD: make the brownout detection level configurable per board
This commit is contained in:
Dan Halbert 2020-07-13 16:26:11 -04:00 committed by GitHub
commit 3fcd999130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 6 deletions

View File

@ -43,3 +43,5 @@
#define DEFAULT_UART_BUS_RX (&pin_PA01)
#define DEFAULT_UART_BUS_TX (&pin_PA00)
#define SAMD21_BOD33_LEVEL (6)

View File

@ -40,3 +40,5 @@
#define IGNORE_PIN_PB09 1
#define IGNORE_PIN_PB10 1
#define IGNORE_PIN_PB11 1
#define SAMD5x_E5x_BOD33_LEVEL (100)

View File

@ -112,6 +112,14 @@
#define CIRCUITPY_DEFAULT_STACK_SIZE 4096
#endif
#ifndef SAMD21_BOD33_LEVEL
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
// which is too low for proper operation of external SPI flash chips
// (they are 2.7-3.6V).
#define SAMD21_BOD33_LEVEL (39)
// 2.77V with hysteresis off. Table 37.20 in datasheet.
#endif
// Smallest unit of flash that can be erased.
#define FLASH_ERASE_SIZE NVMCTRL_ROW_SIZE
@ -129,6 +137,14 @@
#define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024)
#endif
#ifndef SAMD5x_E5x_BOD33_LEVEL
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
// which is too low for proper operation of external SPI flash chips
// (they are 2.7-3.6V).
#define SAMD5x_E5x_BOD33_LEVEL (200)
// 2.7V: 1.5V + LEVEL * 6mV.
#endif
// Smallest unit of flash that can be erased.
#define FLASH_ERASE_SIZE NVMCTRL_BLOCK_SIZE

View File

@ -206,11 +206,10 @@ static void rtc_init(void) {
safe_mode_t port_init(void) {
#if defined(SAMD21)
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
// which is too low for proper operation of external SPI flash chips (they are 2.7-3.6V).
// Set brownout detection.
// Disable while changing level.
SYSCTRL->BOD33.bit.ENABLE = 0;
SYSCTRL->BOD33.bit.LEVEL = 39; // 2.77V with hysteresis off. Table 37.20 in datasheet.
SYSCTRL->BOD33.bit.LEVEL = SAMD21_BOD33_LEVEL;
SYSCTRL->BOD33.bit.ENABLE = 1;
#ifdef ENABLE_MICRO_TRACE_BUFFER
@ -225,11 +224,10 @@ safe_mode_t port_init(void) {
#endif
#if defined(SAM_D5X_E5X)
// Set brownout detection to ~2.7V. Default from factory is 1.7V,
// which is too low for proper operation of external SPI flash chips (they are 2.7-3.6V).
// Set brownout detection.
// Disable while changing level.
SUPC->BOD33.bit.ENABLE = 0;
SUPC->BOD33.bit.LEVEL = 200; // 2.7V: 1.5V + LEVEL * 6mV.
SUPC->BOD33.bit.LEVEL = SAMD5x_E5x_BOD33_LEVEL;
SUPC->BOD33.bit.ENABLE = 1;
// MPU (Memory Protection Unit) setup.