Nessun prodotto
Follow us on facebook
Questo kit è rivolto principalmente a chi desidera iniziare a...
La scheda PROTO SHIELD PLUS rende comodo ed immediato sperimentare e...
Adatta facilmente componenti SMD a piastra sperimentale (breadboard) con...
La scheda PROTOSHIELD PLUS rende comodo ed immediato sperimentare e...
Published : 16/10/2018 21:33:19
Categories : Proto Shield Plus
This is not intended to be an exhaustive tutorial covering all the debugging features of Visual Micro for Atmel Studio, it is just a sneak peek to start looking at this feature.
Let’s start opening an existing .ino file.
i.e. Let’s open the APSP_demo_I2C.ino available from the Proto Shield Plus sample sketches (https://www.gtronicsshop.com/en/index.php?controller=attachment&id_attachment=2).
Once opened, your code will be shown in the code window.
We’re now ready to start discovering the Visual Micro IDE debugging features.
If you have an existing Atmel Studio project (.atsln) file you can directly open it.
i.e. In case you red the article (VISUAL MICRO for ATMEL STUDIO FEATURES) and you tested the features as it describes, you should have the APSP_demo_I2C.atsln available.
In the Solution Configurations drop down menu select Debug.
Your project is now ready to be debugged.
With breakpoints you can:
To set a new break point, just position the mouse pointer on the left side of the line where you want to insert the breakpoint.
Now assume that you want to monitor adc_key_in variable value in read_LCD_buttons() function (line 34).
As soon as you click, a red dot will appear indicating that the new breakpoint has been created.
By default a new breakpoint will act like it is supposed to be: it will pause the execution of your code.
By clicking the Build and Upload button your project will be compiled and uploaded to your Arduino board.
The Output window will appear showing the compile and upload process status.
At the end of the upload, the program will start running….and then it will pause on line 34 waiting for your action.
On the output window shows the sequence of actions:
Click the Continue button (or press F5) to resume code execution.
The code will start and run till execution of line 34… then it will pause again.
If you want to add or remove a breakpoint (or change breakpoint settings), you need to stop the debugging session by clicking the Stop Debugger button
Make your modification to the breakpoints and then Build and Uploadyour project to let it run with the new breakpoints settings.
Now let’s assume that you want to probe the value of adc_key_in variable on line 34.
Positioning the mouse over the red dot of the breakpoint, a little pop-up shows.
Click on the Settings… button
The Breakpoint Settings window appears
Select the Actions checkbox
to expand the Actions setting section
You can now choose a message to show in the Output Window and you can also choose to Continue or Stop code execution.
To probe the adc_key_in variable, you just have to insert:
{adc_key_in}
Everything that is in between curly brackets is interpreted as the variable to probe.
Now Build and Uploadyour project to let it run with the new breakpoints settings.
Once the project is uploaded, you will have:
The Output Window shows some useful additional informations:
Now try to click the Proto Shield Plus buttons to check the corresponding value on the adc_key_in variable.
If you want to log a custom message, just stop debugging (as explained before), click on {adc_key_in}
And add your custom message
i.e. Current adc_key_in value is: {adc_key_in}
Build and Uploadyour project to let it run with the new breakpoints settings.
The Output Window now shows your custom message…
The Action settings let you to stop or continue the code execution.
To just probe a variable value Continue execution checkbox must be selected.
If you want to stop code execution just uncheck Continue execution checkbox.
Now suppose that you want to probe adc_key_in value, only when a certain condition is met.
Just select the Conditions checkbox, the Breakpoint Settings window expands showing you the Conditions fields.
In the example below the breakpoint will execute only when adc_key_in value is less than 600.
Build and Uploadyour project to let it run with the new breakpoints settings.
You notice that the Expression Window and the Output Window, even clicking the A-SELECT button on the Proto Shield Plus, are not logging any information…
That’s because adc_key_in value is greater than 600.
But as soon as you click the B-LEFT button on the Proto Shield Plus, the Expression Window and the Output Window start showing adc_key_in value.
And, as you can see, its value is lower than 600.
The same happens if you click the C-DOWN button on the Proto Shield Plus….
You will also notice that, as soon as you release the buttons, the Expression Window and the Output Window stop logging the current adc_key_in value.
Now experiment by yourself with different Conditions...
Disabling breakpoints is very useful: by disabling a breakpoint it will not be compiled and executed, but you do not lose its settings. So if you want to turn it on again, you just have to enable it without setting it up from scratch.
To disable a breakpoint, just place the mouse pointer over the red dot, and the little pop-up shows.
Notice that even a pop-up showing the current breakpoint settings shows. This pop-up is very useful when you want to monitor breakpoints settings while their Settings window are “contracted”.
Click Disable Breakpoint and that’s it…the breakpoint is disabled.
Now just remember that if you want to contract the Breakpoint Settings Window, you have to click the Settings button or the X of the Breakpoint Settings window.
DO NOT CLICK THE RED DOT, otherwise the breakpoint will be DELETED.
Of course you can implement your own debugging, using the serial monitor provided with the Arduino “standard” IDE, but you have to write additional code to do that.
Visual Micro IDE do it for you and, of course, having these features ready to be used with such an easy interface is really useful and handy!
Just consider that under the hood, it consist in additional extra hidden code that do the debugging serial communication, so consider it if you’re dealing with time critical applications!
When you’re done debugging, just remember to switch the Solution Confirurations back to Release.
It will remove all the additional extra hidden code added by Visual Micro for debugging.