lost out of loop()

Wilfried56

New member
I am running a teensy 4.1-based project utilizing various hardware elements connected via GPIO, USB, FlexIO, ...
Under some special conditions it happens that my software doesn't react anymore. So far I can show that my timer driven ISRs are still running, but I am no longer in loop(). I am trying to find out, where I am then instead. Are there any suggestions, ideas how to best find that out?
Any help is appreciated.
 
Are there any suggestions, ideas how to best find that out?
Show your code, so that we can see what is happening. Use the </> button to post your code, this maintains formatting which will make your code easier to read and understand.
 
First guess is too many ISR's are taking too much time and never allowing time to return to loop() execution.

How much code how often is in the ISR's? Can the ISR's be reduced - even just to test? ISR code need to enter and exit as quickly as possible, especially when running at a high rate.

posting code as per @BriComp p#2 would give a clue if that doesn't suggest the source of the issue.
 
Are there any suggestions, ideas how to best find that out?

Maybe CrashReport breadcrumbs can help?

The basic approach would look something like this.
  1. Set 1 or more of the 6 breadcrumbs to distinct values at meaningful locations in your program.
  2. Cause a crash to happen after some time. See the MyFault library for examples of sure ways to crash.
  3. Add code in setup() to print or capture prior CrashReport info before your program gets going.
Ignore the crash info since you intentionally caused it, but of course focus on the breadcrumb numbers to get an idea of what your program was doing before the crash. Rinse and repeat with more breadcrumbs until you have a pretty good idea of what was happening.
 
One more small tip, you might also add some code like this to know how many times loop() has run:

Code:
  static uint32_t loopcount = 0;
  CrashReport.breadcrumb(4, ++loopcount);

Even though the examples use fixed constants, you can make use of variables for the 32 bit breadcrumb values. Knowing how many times the code ran, or what the most recent data was, or elapsed time might help. For time, RTC might be more reliable since it doesn't need interrupts to increment.

Making use of breadcrumbs is more art and intuition than science. What exactly you should to depends heavily on the specifics of your program. But hopefully this at least gives you a useful tool to get started.
 
I also rely a lot on adding serial prints and setting or toggling io pins that I connect up to logic analyzer.

Note with Seria.prints sometimes I will also do a flush, as I have had hangs where some of the prints don’t output. And I end up barking up the wrong tree.

cases like you have your own interrupt handler, which does not properly clear the condition that causes the interrupt. Or you have a totally rouge memory copy or clear that wipes out everything…
but like everyone here can only throw 🎯
 
Back
Top