Loading...
 

Debugging with Atmel Studio 6

In this example we will be using Arduino IDE Release v1.7.6 (http://www.arduino.org/downloads ) and Atmel Studio 6 (http://www.atmel.com/tools/ATMELSTUDIO.aspx )


Creating the file needed for debugging

Launch the Arduino.org IDE, open the blink.ino sketch and then select the Arduino M0 Pro (Programming Port) from the boards menu :

Image


Image

Comment out rows 26 and 28, to remove the delay call and save the sketch with a new name (i.e. save it as blink1.ino) :

Image

Click the arrow button so to compile the sketch and programming the Arduino M0 Pro. Once done, at this point copy into your clipboard the Blink1.cpp.bin path reported in the output shell (e.g. : C:\Users\...........\AppData\Local\Temp\build6278736204043834605.tmp) :

Image  
 
Use Atmel Studio 6 for debug

Now launch Atmel Studio 6 and from its main menu browse to : File -> Open -> Open Object File For Debugging

Image

select the file Blink1.cpp.elf in Object file To Debug, then click 'next' :

Image

Choose SAMD21G18A, as shown in the next picture, and press 'finish' :

Image

At this point, the "Remap Object Files To Disk Files" window will pop-up :

Image

Select the three-point box in the same row of the Blink1.ino file :

Image

and open the Blink1.ino file itself, then click on finish. Open now the Blink1.ino entry in the Solution Explorer workspace of the main window of Atmel Studio :

Image


Click on the left side (the grayed out part) of the source code window to put a breakpoint (for example at row 25) in it :

Image


Press the play symbol in the top bar to start debugging :

Image

A window will pop-up asking you to choose the edbg debugger/programmer, press continue and then select the proper EDBG and SWD entries as shown in the image below :

Image

Press once again the play button and if required, update the edbg firmware entry and click play another time. Debugging will start and the code will stop at the breakpoint. You can go ahead in debugging by pressing F11 or F10. The software executes the next function or instruction, according to pressed key. Please pay attention at the code is executed on the board itself, this is why we commented out the two delay calls so to speed up the debugging example.