Go Down

Topic: How to reset arduino when program is stuck (Read 147 times) previous topic - next topic

0x4a53

Hi, I am running a mkrnb1500 and occasionally it looses cellular signal. When that happens it has trouble reconnecting so I have a timeout function in the void loop that calls NVIC_systemReset(). My problem is that sometimes when starting the board it will hang up in void setup trying to get connected to a network. Is there a way to call for a board reset when that happens even though it never makes it to void loop? Thanks for any help.

lastchancename

If you know it's stuck, then you could identify the issue and unstuck it.
Otherwise using the WDT is the most common unuversal approach to unlocking hung code.

With cellular modems, reinitializing is a multi-step process, so you could power-cycle the modem, then reinitialize it as needed.
Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

0x4a53

Well it randomly gets stuck on this line of code in setup.
Code: [Select]
Blynk.begin(auth, nbAccess, gprs, client, pin, domain, port);
But just how do I figure out what here is causing the problem??
I don't understand how I would power cycle the modem either.
Coming from learning on the Uno I haven't been able to figure out the watchdog timer on the samd21 but I will keep trying. 

lastchancename

Is it getting STUCK (locked up), or failing to run past this?
Without looking ar the code, my first guess would be if the WiFi actually connected"..

Some Serial.print() will help you work through this.
Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

0x4a53

#4
Jan 24, 2021, 09:43 pm Last Edit: Jan 24, 2021, 10:18 pm by 0x4a53
So when the problem happens the program never progresses past this line of code.
Code: [Select]
Blynk.begin(auth, nbAccess, gprs, client, pin, domain, port);
Maybe I wrongly assumed it gets stuck??
I should have stated that this is connecting to an LTE network not wifi. And I have good signal at this location.
So I see that I'm getting this from the serial monitor when the program gets stuck. 
Quote
init
or
Quote
cannot init
and then it just does nothing.
I think I need to figure out what all is happening in the .begin() function but I'm not sure just how to find it.



Go Up