Control Execution Speed With Hit Counters

by Visual Micro 16. January 2013 12:00

The Arduino Debugger can be used in a more advanced mode allowing you more control over the frequency of Break and Trace control/messages. Keep in mind that behind the scenes this debugger uses serial messages. Allowing too many messages will cause either the arduino or your pc to loose or corrupt messages and a possible slow down of cpu(s).

Placing a trace point in a fast loop() would produce too many messages. For this reason Visual Micro throttles the messages and forces the arduino to slow down.

By default, Visual Micro imposes a wait of up to 80 milliseconds between breakpoints. This value can be altered using the project property called "Throttle (ms)". A value of 0 uses the current default which is 80 ms.

The Throttle is designed for new users and/or quick tests in applications that do not require the arduino to run at full speed (except for when transmitting a debugger message).

Using the Throttle is not the recommended solution!

Instead of using the Throttle, the debugger "Hit Count" facility should be used to "smooth" debugger breakpoints and/or tracepoint message. 

Depending on the frequency and position of your Arduino breakpoints you might want to ensure the Throttle is disabled. To do this you set the project property called "Throttle Enabled=False"

You will see on the options menu for each Breakpoint a menu item called "Hit Count". Normally in windows debugging the hit count is a count of how many times the point in the code has been hit. This is the same for Visual Micro except that a counter is often not very useful. Instead we can optionally switch from a count to a millisecond interval timer.

For example:- Setting the option "Break when hit is a multiple of x" to 200 would cause the arduino to break or trace when the code it hit every 200 times. However setting the project property called "Hit Counter" to milliseconds will cause the break/trace point to execute every 200 milliseconds. 

note: when using non-breaking tracepoints the stream of debug messages are processed on the pc in batches of up to 10 per second (also depends on the amount of data). The time displayed in the pc debug trace is the time each message is processed on the pc, not the time the message was sent from the micro-controller. For example, we might use a tracepoint at 4hz (every 250ms). In this case the debug data will be an accurate reflection of the micro_controller every 4hz however the millisecond values in the pc trace might not appear enitrely consitent. 

Basic Hit Counter Information