Description
CircuitPython version
Adafruit CircuitPython 9.2.3-14-g52b5b2da1a on 2025-01-26; Adafruit Feather ESP32-S3 TFT with ESP32S3
Code/REPL
import board
import time
import array
import pulseio
f = open("/codes.txt", "r") # https://github.com/mario872/Sonic-Screwdriver/blob/main/Software/src/codes.txt
# Just moved some lines around from https://raw.githubusercontent.com/adafruit/Adafruit_Learning_System_Guides/master/CircuitPython_TVBGone/codes.txt
input() # To make sure I can tell it when to start
count = 0
for line in f:
code = eval(line)
print(code)
# If this is a repeating code, extract details
try:
repeat = code["repeat"]
delay = code["repeat_delay"]
except KeyError: # by default, repeat once only!
repeat = 1
delay = 0
# The table holds the on/off pairs
table = code["table"]
pulses = [] # store the pulses here
# Read through each indexed element
for i in code["index"]:
pulses += table[i] # and add to the list of pulses
pulses.pop() # remove one final 'low' pulse
with pulseio.PulseOut(
board.D13, frequency=code["freq"], duty_cycle=2**15
) as pulse:
for i in range(repeat):
pulse.send(array.array("H", pulses))
time.sleep(delay)
time.sleep(code["delay"])
count += 1
Behavior
When running the above code it gets around 3-6 repeats in then I get:
Auto-reload is off.
Running in safe mode! Not running saved code.
You are in safe mode because:
CircuitPython core code crashed hard. Whoops!
Hard fault: memory access or instruction error.
Please file an issue with your program at github.com/adafruit/circuitpython/issues.
Press reset to exit safe mode.
Interestingly, when I run a more complicated program, with this script basically as a function instead, I get:
Auto-reload is off.
Running in safe mode! Not running saved code.
You are in safe mode because:
Internal watchdog timer expired.
Press reset to exit safe mode.
Description
N/A
Additional information
Running a very similar script on the RPi Pico 2 W didn't produce any error less than two weeks ago (with that build of CP from two weeks ago
Edit: Here's the longer program code: https://github.com/mario872/Sonic-Screwdriver/tree/main/Software/src/v5.3
Edit 2: Changing the pulseio.PulseOut line to:
pulse.deinit()
time.sleep(0.01)
pulse = pulseio.PulseOut(board.D13, frequency=code["freq"], duty_cycle=2**15)
Makes it work until line 128 of codes.txt, until it gives this error:
{'index': [0], 'freq': 6961, 'delay': 0.33, 'repeat': 2, 'repeat_delay': 0.127, 'table': [[143]]}
Traceback (most recent call last):
File "test.py", line 34, in <module>
espidf.IDFError: Invalid argument
Then is goes into safe mode. Edit 4: (Hard Fault: memory access or instruction error)
Edit 3: It appears that then removing any line with an index of [0]
fixes that issue, then changing the time.sleep(0.01)
to time.sleep(1)
stops CP from crashing at all.
Edit 5: There are no lines with and index of [0]
until line 128, and with no delay it fails way before then.