strategy to debug?

Status
Not open for further replies.

M4ngu

Well-known member
Hi there,
I have a code (about 8k lines) for Teensy 4.1 which has a glitch, some times the machine freezes and the sound becomes a nasty blip for a second or so, I'm trying to figure out which part of the code is the problem with no luck at the moment, one of the problems is that if I activate the serial communication (to monitor which part of the code was running before the glitch) most of the times the glitch disappear, but not always. Also on every change in the code the glitch could almost disappear too or becomes very frequent.
What suggestions do you guys have to find the problem? maybe storing some variables with the elapsed MCU cycles in different sections of the code?
any tip, suggestion or idea is welcomed.
Thanks!
 
What @KurtE ( others ) would perhaps do with a logic analyzer is toggle pins on entry exit to suspect functions to detect code flow running as expected.

digitalToggleFast() doesn't add much overhead - if there are free pins and a logic analyzer is handy it might help point to a suspect code section.

p#1 doesn't give a good idea of the code process and how or what it is doing and where it might be failing, or what hardware might be involved causing trouble.

General advice is that an array or pointer is running out of bounds and fixing that will solve the problem. Or perhaps some delay() or code/hardware piece is taking too long for the rest of the program.

If the core code function could boil down to a simple sample the error might become clear - or it could be posted for review.
 
I have a similar problem, and I am betting you have noticed how just changing one connection in a sketch might activate or deactivate this "feature." I really think it's something in the compilation chain but can't prove it, and when I posted an easy-peasy run this and see example it's been three days now, over 100 views and not a single reply.
 
Status
Not open for further replies.
Back
Top