代做COMP9032 Lab 0 Getting Started with Microchip Studio调试R语言程序

COMP9032 Lab 0

Getting Started with Microchip Studio

Sept. 2025

1. Objective

•     Install Microchip Studio at home.

•     Learn how to use Microchip studio to debug and run AVR assembly programs.

2. Installing Microchip Studio

Download the Microchip Studio installer from the following link

https://www.microchip.com/en-us/tools-resources/develop/microchip-studio#Downloads.

The software is also available on the course website (follow the link References → Tools → Microchip Studio). There are different types of MCUs. As we will use AVR 8-bit MCU (Microcontroller Unit) in our course, make sure you select the AVR 8-bit MCU option during installation.

Unfortunately, Microchip Studio only supports Windows. If you want to install Microchip Studio on a non-Windows computer, you need to set up a Windows virtual machine. Obtain necessary software for setting up a Windows virtual machine from the following link:

https://taggi.cse.unsw.edu.au/FAQ/Windows/

There are also plenty of resources available online about installing Windows virtual machines.

3. Introduction to Microchip Studio

Below is a short tutorial on how to use Microchip Studio (previously called Atmel Studio).

3.1 Start Microchip Studio

To start Microchip Studio, double click the Microchip Studio icon, or click on Start → Programs → Microchip Studio 7.0.

3.2 Create a New Project

To create a new project, on the Start Page screen, click the “New Project …” link. The dialog box will appear.

Figure 1: New Project

Among the installed programs, select Assembler and enter a project name (e.g. “lab_0”), as shown in Figure 1. Next, select the project location. This is the location where Microchip Studio will store all files associated with the project. It is good practice to create a separate directory for each lab. After choosing the project software type, name, and location, press “OK” to continue. You will be asked to choose the device for your project. Choose “ATmega2560” from the Device list, as shown in Figure 2. Then press “OK” to continue.

Figure 2: Device Selection

Now the project window with a file called main.asm appears, as shown in Figure 3.

Figure 3: Project Window

Replace the sample code (that was automatically generated by the Studio) with your code given in Figure 4.

Figure 4: Your assembly code

In the assembly code, file m2560def.inc is included. It contains the definitions required by the assembler for the microcontroller. The next step is to build the code (i.e. assemble the assembly program into machine instructions) . This is done by selecting “ Build Solution” from the “Build” menu (or press F7). The Output window (see Figure 5) then displays the information from the assembler. From this window we can see that the assembly process was completed with no errors and the executable file is 12 bytes long.

Figure 5: Build Your Program

Now we can investigate the code execution in the debug mode by selecting “Start Debugging and Break” under the Debug menu. If you are prompted to select a connected tool, select Simulator and try again. Notice that a yellow arrow is pointing to the first instruction “ldi a, 10” in the assembly code window, as shown in Figure 6. This arrow indicates the next instruction to be executed.   Before simulation, we may want to set up the Register View so that we can see the value of each register during the program execution. Select DebugWindowsProcessor Status and drag the created window to the right-side window (see Figure 6).

Figure 6: Start Debugging

The value of each register is initially 0. These registers will be dynamically updated during the program execution. You can also assign and change values of these registers by clicking on the value of a register and entering a new value at any time during the simulation. You can also change the value display format (binary or hexadecimal or decimal) by right clicking on the value and selecting a format you want to use from the list, as shown in Figure 6.

3.3 Run Simulation

There are two commands to single step through the code: “Step Over” F10 and “Step Into” F11. The difference between these two commands is that F10 does not trace into subroutines. Since our example does not contain any subroutines, there is no difference between the two here. Now, single step down to the third line of the code by repeatedly pressing the F11 key (For some computers you may need to use Fn key to active the function key, e.g. Fn+F11). Notice how the color changes from black to red on the registers when their values are just updated (See Figure 7). This makes it easy to identify which register changes its value when an instruction is executed.

Figure 7: Single-Step Execution

You can also run the code with breakpoints. To add a breakpoint, move the cursor to the instruction you want to stop on, and right click mouse and select BreakpointInsert Breakpoint. Figure 8 shows a breakpoint (indicated by the red dot) is added on the mov instruction.

Figure 8: Setting Breakpoint

Now press the Continue (or F5) button. The simulation will continue and then stop at the → breakpoint, as shown in Figure 9. The breakpoint can be removed/disable by selecting Breakpoint Delete Breakpoint/Disable Breakpoint.

Figure 9: Execution with Breakpoint

To end the debugging session, press “Ctrl+Shift+F5” or selecting Debug → Stop Debugging from the menu.

3.4 Status Register

Each AVR microcontroller has a Status REGister (named as SREG) that keeps eight flags such as C, S and V.  The definitions of these flags can be found in Mega2560 Data Sheet (page 14), which is available on the course website (follow the link References Documents → Mega2560 Data Sheet. These flags are dynamically updated during the program execution and can also be observed in the Processor Status window.  When a flag bit is set, the corresponding bit block is highlighted in red. For example, after instruction add a, b” is finished, bit 0 (C) and bit 1 (Z), are set, as shown in Figure 9.

3.5 Entry File

There is only one assembly file (main.asm) in the project. You can add more files into your project by right-clicking on the project name and clicking Add on the drop-down menu, as shown in Figure 10. You can then add a new or an existing file.

Figure 10: Adding More Files to Project

By default, main.asm is the entry file and only the entry file will be built and simulated. To set an assembly file as the entry file, right click on the file and select the Set As EntryFile option, as shown in Figure 11.

Figure 11: Set Entry File

Note that the work of this lab will not be assessed. However, you are strongly recommended to complete it in Week 1 and be ready for the following lab exercises.




热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图