SOLVED: Teensy 3.1 crash troubleshooting
Hello,
I am building an open source sequencer with the Teensy 3.1. The prototype I am working with currently has two hardware debounced rotary encoders, 4 momentary switches, 8 Neopixel LEDs, and one 128x64 OLED display using the Adafruit_SSD1306 library.
Code is here: https://github.com/cosmikwolf/afx-01a
I wrote a small library for a sequencer object, which contains all step information (midi notes, gate lengths, velocity etc for each step).
The code has 4 iterations of this sequencer.
Only one sequence can be selected at any one time, and the LCD displays some information that is taken directly from the Sequence object (using public variables)
When I press a button to change the selected sequence, which changes what is displayed, OCCASIONALLY the whole thing locks up. I have printed out things to the serial console and it seems to be happening sometime during the display rendering part of the code. That code works just fine most of the time, except occasionally when the selected sequence variable is changed. One clue is that if I link this variable to a rotary encoder, and change the value with it instead of using a button, it freezes much more frequently. I can usually get it to freeze within 10 seconds.
This is the end of the serial output when I am running the program and it freezes:
This is the section of code where the last debug line (number 8) is printed out. This displayLoop() is called within the main loop. You can see the rest of the code in the github linked above.
I should also mention that I have an IntervalTimer object that runs an interrupt every 700 microseconds. The crash still happens even when the IntervalTimer is completely disabled.
SO my question is... How do I troubleshoot this? Any suggestions? It would be really helpful to figure out WHY the teensy is crashing, some kind of stack trace.
Thank you!
tk
Hello,
I am building an open source sequencer with the Teensy 3.1. The prototype I am working with currently has two hardware debounced rotary encoders, 4 momentary switches, 8 Neopixel LEDs, and one 128x64 OLED display using the Adafruit_SSD1306 library.
Code is here: https://github.com/cosmikwolf/afx-01a
I wrote a small library for a sequencer object, which contains all step information (midi notes, gate lengths, velocity etc for each step).
The code has 4 iterations of this sequencer.
Only one sequence can be selected at any one time, and the LCD displays some information that is taken directly from the Sequence object (using public variables)
When I press a button to change the selected sequence, which changes what is displayed, OCCASIONALLY the whole thing locks up. I have printed out things to the serial console and it seems to be happening sometime during the display rendering part of the code. That code works just fine most of the time, except occasionally when the selected sequence variable is changed. One clue is that if I link this variable to a rotary encoder, and change the value with it instead of using a button, it freezes much more frequently. I can usually get it to freeze within 10 seconds.
This is the end of the serial output when I am running the program and it freezes:
Code:
interrupt start
interrupt end
display debug 7
display debug 8
diinterrupt start
interrupt end
lay debug 7
display debug 8
di
This is the section of code where the last debug line (number 8) is printed out. This displayLoop() is called within the main loop. You can see the rest of the code in the github linked above.
Code:
void displayLoop() {
Serial.println("displayStart");
display.clearDisplay(); // clears the screen and buffer
display.drawTriangle( 120,0,
113,9,
127,9, WHITE);
if (tempoBool == true) {
display.fillTriangle( 120,0,
113,9,
127,9, WHITE);
}
Serial.println("displaydebug1");
display.setTextSize(1);
display.setTextColor(WHITE);
Serial.println("displaydebug2");
display.setCursor(0,0);
display.println(String(instrumentNames[sequence[selectedSequence].instrument+1]));
display.println("tempo:" + String(sequence[selectedSequence]._tempo));
display.println("as: " + String(sequence[selectedSequence].activeStep) + " ct: " + String(sequence[selectedSequence].clockTracker));
display.println("sequenceLength: " + String(sequence[selectedSequence]._sequenceLength));
Serial.println("displaydebug3");
display.println("lastActiveStep: " + String(lastActiveStep));
if (stepLength[selectedStep] == 1) {
display.println("Step: " + String(selectedStep) + " - " + sequence[selectedSequence]._gateLength[selectedStep] + " beat");
} else {
display.println("Step: " + String(selectedStep) + " " + sequence[selectedSequence]._gateLength[selectedStep] + " beats");
}
Serial.println("displaydebug4");
if (stepActive[selectedStep] == true){
display.println("Pitch: " + String(midiNotes[sequence[selectedSequence]._stepPitch[selectedStep]]) + " Vel: " + String(sequence[selectedSequence]._stepVelocity[selectedStep]));
} else {
display.println("Rest Step");
}
Serial.println("displaydebug5");
display.println("avgPeriod:" + String(avgPeriod));
Serial.println("display debug 6");
display.println("avgLoopTime:" + String(avgLoopTime));
display.println("avgRuntime:" + String(avgRuntime));
display.setTextSize(2);
display.setCursor(100,0);
Serial.println("display debug 7");
display.print(String(selectedSequence));
Serial.println("display debug 8");
display.display();
Serial.println("display debug 9");
Serial.println("displayLoopEnd");
}
I should also mention that I have an IntervalTimer object that runs an interrupt every 700 microseconds. The crash still happens even when the IntervalTimer is completely disabled.
SO my question is... How do I troubleshoot this? Any suggestions? It would be really helpful to figure out WHY the teensy is crashing, some kind of stack trace.
Thank you!
tk
Last edited: