0

Code reset - Feather 32u4 FONA
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Code reset - Feather 32u4 FONA

by mgbeets on Fri Aug 02, 2019 8:00 am

Hi
I have a Adafruit Feather 32u4 FONA Wireless Cellular Dev Board (FONA800) and would like to force a hard reset from within the Arduino code.
Please can you assist with a method to do this?
Something similar to ESP.reset()

mgbeets
 
Posts: 5
Joined: Fri Jul 13, 2018 12:02 am

Re: Code reset - Feather 32u4 FONA

by relaxing on Fri Aug 02, 2019 10:24 am

From the datasheet:
The ATmega16U4/ATmega32U4 has five sources of reset:
1 Power-on Reset. The MCU is reset when the supply voltage is below the Power-on Reset threshold (VPOT).
2 External Reset. The MCU is reset when a low level is present on the RESET pin for longer than the minimum pulse length.
3 Watchdog Reset. The MCU is reset when the Watchdog Timer period expires and the Watchdog is enabled.
4 Brown-out Reset. The MCU is reset when the supply voltage VCC is below the Brown-out Reset threshold (VBOT) and the Brown-out Detector is enabled.
5 JTAG AVR Reset. The MCU is reset as long as there is a logic one in the Reset Register, one of the scan chains of the JTAG system. Refer to the section “IEEE 1149.1 (JTAG) Boundary-scan” on page 325 for details.
6 USB End of Reset. The MCU is reset (excluding the USB controller that remains enabled and attached) on the detection of a USB End of Reset condition on the bus, if this feature is enabled by the user.

Points 2 or 3 are probably the only applicable options.
#3 is the best option. Set a WDT and have your code trigger a busy loop when you want a reset to occur.
People will advise you not to do #2 by wiring a digital pin directly to the RST pin on your Feather and pulling it low, because the data sheet says minimum pulse length is typically 400ns and there's a likelihood your digital pin won't be able to hold it low long enough.

relaxing
 
Posts: 59
Joined: Thu Mar 24, 2005 11:22 am

Re: Code reset - Feather 32u4 FONA

by relaxing on Fri Aug 02, 2019 10:38 am


relaxing
 
Posts: 59
Joined: Thu Mar 24, 2005 11:22 am

Re: Code reset - Feather 32u4 FONA

by mgbeets on Mon Aug 05, 2019 11:38 am

okay, I'll give this a shot and report back afterwards.
Thank you for the quick response!

mgbeets
 
Posts: 5
Joined: Fri Jul 13, 2018 12:02 am

Re: Code reset - Feather 32u4 FONA

by mgbeets on Mon Aug 05, 2019 12:02 pm

This worked really well! I can reset my Adafruit Fona every few hours to ensure it's connected properly!
Thanks again.


Code: Select all | TOGGLE FULL SIZE
#include <avr/wdt.h>

....

#define soft_reset() \
do                          \
{                           \
    wdt_enable(WDTO_15MS);  \
    for(;;){}               \
} while(0)

mgbeets
 
Posts: 5
Joined: Fri Jul 13, 2018 12:02 am

Please be positive and constructive with your questions and comments.