ThermalRunaway
New Member
Hi everyone,
As I've started taking on more complex programming tasks with Microcontrollers I've started to give consideration to the usefulness of debug and self test code within my projects. At the moment I am trying to think about the best way to implement this type of code.
For example, my current project sends debug code out on a serial port so that I can connect a terminal to it and monitor what my software is doing as it executes. It can tell me what functions I'm executing, values returned for sensor readings, and stuff like that.
This is all very well, but of course it adds to the overhead in terms of memory usage and runtime of the application. Ideally it would be nice if I could turn the debug mode on and off so that it only executes this extra code when I need it to. An easy way to do this is to declare a debug variable and then check it within the program each time the debug code would normally be called.
This improves matters, but there is still the overhead involved in continually checking my debug variable as the program is executing.
A more ideal solution would be if the debug code could be completely deactivated so that there is no additional overhead at all when the debug mode is not required. I can do this at compile time quite easily, but I can't figure a way to do this in a runtime situation. And this leads on to my question for more experienced embedded programmers:
Is it possible to implement debug/test code into applications that can be switched on and off at runtime in a way that totally removes the additional overhead when the mode is not required? Or, is it normal to continually check the status of a variable and live with the small overhead that results?
Thanks all,
Brian H.
As I've started taking on more complex programming tasks with Microcontrollers I've started to give consideration to the usefulness of debug and self test code within my projects. At the moment I am trying to think about the best way to implement this type of code.
For example, my current project sends debug code out on a serial port so that I can connect a terminal to it and monitor what my software is doing as it executes. It can tell me what functions I'm executing, values returned for sensor readings, and stuff like that.
This is all very well, but of course it adds to the overhead in terms of memory usage and runtime of the application. Ideally it would be nice if I could turn the debug mode on and off so that it only executes this extra code when I need it to. An easy way to do this is to declare a debug variable and then check it within the program each time the debug code would normally be called.
This improves matters, but there is still the overhead involved in continually checking my debug variable as the program is executing.
A more ideal solution would be if the debug code could be completely deactivated so that there is no additional overhead at all when the debug mode is not required. I can do this at compile time quite easily, but I can't figure a way to do this in a runtime situation. And this leads on to my question for more experienced embedded programmers:
Is it possible to implement debug/test code into applications that can be switched on and off at runtime in a way that totally removes the additional overhead when the mode is not required? Or, is it normal to continually check the status of a variable and live with the small overhead that results?
Thanks all,
Brian H.