0

MagTag .reset() causes crash
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MagTag .reset() causes crash

by snaxter on Sun Jan 10, 2021 3:22 pm

I am trying to reset my MagTag after multiple network errors. Calling microcontroller.reset() cases a hard crash "CircuitPython core code crashed hard. Whoops! Crash into the HardFault_Handler." Is there a better way to reset the MagTag?

Here is a simple code snippet that reproduces the problem when you hit button "C".

I'm running 6.1.0 RC0, with mpy bundle 20210109

Code: Select all | TOGGLE FULL SIZE
import time
import microcontroller
import terminalio
from adafruit_magtag.magtag import MagTag
 
magtag = MagTag()
magtag.peripherals.neopixel_disable = False
 
magtag.add_text(
    text_font=terminalio.FONT,
    text_position=(120, 55),
    text_scale=2,
)
 
magtag.set_text("Idle")
 
while True:
    if magtag.peripherals.button_a_pressed:
        magtag.set_text("A")

    elif magtag.peripherals.button_b_pressed:
        magtag.set_text("b")

    elif magtag.peripherals.button_c_pressed:
        microcontroller.reset()
       
    time.sleep(.1)

Attachments
code.py
(554 Bytes) Downloaded 2 times

snaxter
 
Posts: 25
Joined: Mon Mar 24, 2008 10:57 pm

Re: MagTag .reset() causes crash

by mikeysklar on Mon Jan 11, 2021 9:15 pm

Thanks for the clear summary.

Your system looks up to date in terms of CircuitPython and the libraries. Can you confirm that your bootloader is also current?

https://circuitpython.org/board/adafrui ... grayscale/

On the Arduino side we can use the CMSIS ARM standard and call:

Code: Select all | TOGGLE FULL SIZE
NVIC_SystemReset()


I mention it that there might be an alternative to microcontroller.reset() for CircuitPython that you can find that I was not able to locate.

mikeysklar
 
Posts: 2880
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.