From aaba4af46cbfa14ae064ae73d5aacb4ac1fa03c7 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 3 Mar 2017 18:48:13 +0100 Subject: [PATCH] Use Supply Controller to avoid running SAM3 on voltages lower than 3.0V Sometimes there is some leakage current via some I/O that's sufficient to power up the SAM3S. Use the supply monitor to make sure the CPU will be reset (and kept in reset) if the supply voltage is below 3.0V. --- firmware/libboard/common/source/board_lowlevel.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/firmware/libboard/common/source/board_lowlevel.c b/firmware/libboard/common/source/board_lowlevel.c index 42a679f1..5865d1dd 100644 --- a/firmware/libboard/common/source/board_lowlevel.c +++ b/firmware/libboard/common/source/board_lowlevel.c @@ -119,6 +119,13 @@ extern WEAK void LowLevelInit( void ) { uint32_t timeout = 0; + /* Configure the Supply Monitor to reset the CPU in case VDDIO is + * lower than 3.0V. As we run the board on 3.3V, any lower voltage + * might be some kind of leakage that creeps in some way, but is not + * the "official" power supply */ + SUPC->SUPC_SMMR = SUPC_SMMR_SMTH_3_0V | SUPC_SMMR_SMSMPL_CSM | + SUPC_SMMR_SMRSTEN_ENABLE; + /* enable both LED and green LED */ PIOA->PIO_PER |= LED_RED | LED_GREEN; PIOA->PIO_OER |= LED_RED | LED_GREEN;