Teensy slows down for some unknown reason

Evgeni

New member
Hello I'm going back to my project after some time and for some reason there is a delay of 7 seconds that happens for some reason.

What happens the MC runs fine, this can be indicated by the internal led i have setup to blink, but when I send the magic character that adds a packet to the packet stack there is a delay of 7 seconds that happens before the function is executed. This does not make any sense since there is no reason for that delay since there are on other functions between the reading of the character from the serial port and the if() that checks the character and executes the function. What makes even less sense is that is delay happens only if there is a loop in another function, but this loop is only ran when there is a packet in the packet stack.

The problem that I'm describing is between the functions "sendPacketHandle()" and "sendPacket()" that are being ran in loop() in main.cpp and are a part of BusComLib.h.

Further info on the project: this is a project that for now has the task to run communication via a bus. The code I'm sending is the code of the master device that collects all the data.
I have been pulling my hair out for the past few days on this and i don't understand why, any help on it would be very much appreciated.
 

Attachments

  • BusComLib.cpp
    7.2 KB · Views: 10
  • BusComLib.h
    1.4 KB · Views: 11
  • main.cpp
    975 bytes · Views: 14
  • utils.cpp
    380 bytes · Views: 9
  • utils.h
    46 bytes · Views: 7
You have at least one while loop inside a critical section (i.e. with interrupts turned off). You should be turning off interrupts briefly for critical section stuff only (a few microseconds). Also that while loop is waiting for a condition that can't happen. Thus I suspect the watchdog is simply reseting your program every few seconds.
 
Back
Top