Creating, Simulating, and Emulating in Atmel Studio
Creating, Simulating, and Emulating in Atmel Studio
Schwartz
Department of Electrical & Computer Engineering Christopher Crary, Asst. Lecturer
Page 1/8 Revision 0 21-May-18
CREATING, SIMULATING, AND EMULATING IN ATMEL STUDIO
INTRODUCTION
The purpose of this document is to present a quick tutorial on how to create an AVR assembler project within
Atmel Studio, how to simulate an assembly program with the software debugger built into Atmel Studio, and also
how to emulate an assembly program with the debugger/programmer built into your µPAD.
Additionally, the appendix of this document identifies how to do the aforementioned using the C programming
language. When using C and working across a network, you will need to perform additional steps also laid out in
the last page of this document.
For more information on Atmel Studio, visit the Atmel Studio User Guide.
REQUIRED MATERIALS
• GPIO_Output.asm
• µPAD v2.0 with USB A/B connector cable
SUPPLEMENTAL MATERIALS
• µPAD v2.0 Schematic
PROCEDURE
NOTE: This tutorial assumes that you already have Atmel Studio installed, and that you have set your workspace
folder to a known location. See the Atmel Studio Installation Instructions posted on our course website to learn how
to do so.
1. Open Atmel Studio, and create a new project by navigating to File New Project.
2. Under Installed, select Assembler, and then AVR Assembler Project (see Figure 1).
3. Browse to a desired location for which to save the file (using the Location textbox), and save the file with a
meaningful name (using the Name textbox). For this tutorial, we will call the project “GPIO_Output”. Leave
everything else default, and create the project by clicking the OK button.
4. In the Device Selection window that automatically opens, select the correct device and click OK. For the entirety
of this semester, we will be using the ATxmega128A1U (see Figure 2).
Figure 1: Choosing the project type Figure 2: Choosing the device type
University of Florida EEL 3744 Dr. Eric M. Schwartz
Department of Electrical & Computer Engineering Christopher Crary, Asst. Lecturer
Page 2/8 Revision 0 21-May-18
CREATING, SIMULATING, AND EMULATING IN ATMEL STUDIO
You should now see a workspace similar to what is
shown in Figure 3. From this point on, we will
begin to use the code from the GPIO_Output.asm
file mentioned above. This short program utilizes a
GPIO port connected to the RGB LED package on
your µPAD. A GPIO port can be defined in many
capacities, though in the context of this tutorial, it
suffices to relate a GPIO port with a group of
physicals pins controlled by electrical signals, i.e.,
a low voltage signal corresponding to a binary ‘0’,
a higher voltage corresponding to a binary ‘1’.
To start the program simulation, i.e., to start debugging, you can either select the Start Debugging icon (also known
as the Continue icon) specified by the green arrow near the top of the Atmel Studio window (see the topmost red
arrow in the Figure 7), or navigate to Debug Continue, or even simply press F5 on your keyboard.
9. Start debugging the main program. The program should stop execution at the breakpoint you placed, and the
specified line of code should be highlighted yellow, following a yellow arrow in the gray pane where the
breakpoint resides. (The yellow arrow, along with the yellow highlight, indicates the next instruction to be
executed.)
While debugging, you can view any of the processor’s registers, I/O ports, memory locations, etc. To do so is
extremely helpful when writing any embedded software. Since we are using the I/O port PORTD in this example
program, in addition to internal GPIO registers, we will explore the I/O and Processor Status views of the debugger.
10. Open the I/O view by navigating to Debug Windows I/O, as shown in Figure 8. Open the Processor
Status view by navigating to Debug Windows Processor Status.
University of Florida EEL 3744 Dr. Eric M. Schwartz
Department of Electrical & Computer Engineering Christopher Crary, Asst. Lecturer
Page 5/8 Revision 0 21-May-18
CREATING, SIMULATING, AND EMULATING IN ATMEL STUDIO
NOTE: When simulating, if you would like the simulated clock frequency to match the clock frequency of the
actual µPAD board (if it does not already match), i.e., the actual clock speed when you emulate, select the value
listed next to Frequency in the Processor Status window, and enter the oscillator frequency that you have chosen
for your device (e.g., 2.000 MHz, the default ATXMEGA128A1U clock frequency).
Now, we will utilize the I/O view to view all of registers within PORTD, starting at the point of execution specified
by our chosen breakpoint.
11. Within the I/O view, filter for and select I/O Port Configuration (PORTD). (To search for this, you may type
something as simple as “portd” in the Filter textbox, as shown in Figure 9.) After selecting the correct port
configuration, you will be able to view all of the registers associated with PORTD.
To execute the next instruction within your program, you can click the Step Into icon (as pointed to by the
leftmost red arrow in Figure 9), or press F11 on your keyboard. (You may also step through each instruction by
navigating to Debug Step Into).
12. Step through the program code, identifying changes that occur to the registers within PORTD, as well as to
the microcontroller’s internal GPIO registers.
NOTE: Two other useful debug stepping features are Step Over and Step Out, as pointed to by the second-
rightmost and rightmost red arrows in Figure 9, respectively. Step Over will always execute the next instruction in
the current procedure frame as a single unit, i.e., if the next instruction to be executed consists of a procedure call,
the entire procedure will be executed in a single step. Step Out executes the remaining lines of a function in which
the current execution point lies.
University of Florida EEL 3744 Dr. Eric M. Schwartz
Department of Electrical & Computer Engineering Christopher Crary, Asst. Lecturer
Page 6/8 Revision 0 21-May-18
CREATING, SIMULATING, AND EMULATING IN ATMEL STUDIO
Figure 9: Step Into, Step Over, and Step Out debug icons
We will now stop debugging and begin to emulate the program on the µPAD. To stop debugging, you can
navigate to Debug Stop Debugging, or click on the Stop Debugging icon, i.e., the red square, in the toolbar.
13. Connect the µPAD to your computer with your USB A/B connector cable. Select the on-board Atmel Embedded
Debugger (EDBG) as the Selected debugger/programmer, within the project Tool menu, as done in Step 7.
Also verify that the Interface is chosen to be PDI (as shown in Figure 10). Finalize these changes by saving
the project.
NOTE: The PDI clock frequency is only representative of the programmer/debugger, and need not be the same
value as the clock frequency of the processor. It is recommended to not change the default value.
University of Florida EEL 3744 Dr. Eric M. Schwartz
Department of Electrical & Computer Engineering Christopher Crary, Asst. Lecturer
Page 7/8 Revision 0 21-May-18
CREATING, SIMULATING, AND EMULATING IN ATMEL STUDIO
14. Repeat steps 9-12. The code will now be executing in hardware rather than in software; once more, this is
known as emulation. Upon stepping through the program, you should see the RGB LED package at the bottom
left of your µPAD (labeled D4) reflect the changes made to PORTD within the program. These LEDs are
connected to PORTD of your processor, as shown in the µPAD v2.0 Schematic.
University of Florida EEL 3744 Dr. Eric M. Schwartz
Department of Electrical & Computer Engineering Christopher Crary, Asst. Lecturer
Page 8/8 Revision 0 21-May-18
CREATING, SIMULATING, AND EMULATING IN ATMEL STUDIO
APPENDIX A: SPECIAL CONSIDERATIONS FOR PROJECTS USING C
Atmel Studio cannot work accoss networks without using a network drive. Below are instructions on how to create
a network drive, for Windows 10 and versions prior.
NOTE: Details for each optimization level specified by the AVR/GNU C Compiler can be found in the Atmel
Studio User Guide.