Use Microchip Studio to program an Arduino UNO board (Initial Setup and one exmaple)


Download Microchip Studio and start a new Project



Choose Black Solution



In the solution, add new project



Choose Assembler project so it can be programmed in assembly



Choose ATmega328P as the microcontroller.



Add a second project. The first one is used for simulation, the second one is called 'target' is used for programming the chip.



Use this code as the first example. Explanations can be found in the end of this tutorial.
Right click the project and build the code.



Doenload the Arduino IDE from their official website. Install it.


Plug in your Arduino UNO board, open your 'Device Manager' from Windows System, you can see the COM port number being used. Please note that if you switch to a different Arduino board, the port number can be different.



In Arduino IDE, go to Files - Preferences, check 'Upload' under 'Show verbose output during'.



Be ready to program your board using the Arduino IDE using their Blink example.







After run it, in the log window, you will see several lines of arguments. Copy then to a text editor and make the following changes accordingly.
What I got:
C:\Users\yli\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude

I changed it to:
C:\Users\yli\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude.exe

What I got:
"-CC:\Users\yli\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM5" -b115200 -D "-Uflash:w:C:\Users\yli\AppData\Local\Temp\arduino\sketches\B2188FE64605BEAF56B87A6FF5C66379/Blink.ino.hex:i"


I changed it to:
-C"C:\Users\yli\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM5" -b115200 -D "-Uflash:w:"$(ProjectDir)Debug\$(TargetName).hex":i



Come back to the Microchip Studio interface, select 'Tools' and then 'External Tool'. This will allow to add the just downloaded Arduino IDE to program your Arduino UNO board.



Add an external tool. Here I already added it before so it shows up in the window.
In the 'Command' and 'Arguments' entries, use the ones you just edited before. For your references, I copy/pasted what I have in the entries here:
Commands entry:
C:\Users\yli\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude.exe

Arguments entry:
-C"C:\Users\yli\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM6" -b115200 -D "-Uflash:w:"$(ProjectDir)Debug\$(TargetName).hex":i

Plesae note that you may have a different COM port number, please change it accordingly for the argument above!!!!



Come back to 'Tools', you will see 'Arduino UNO' is there. You may see other people use 'Send to Arduino' here from other tutorials. It is just a name of this command, you can name it whatever works the best for you.



To verify if this works, comment out the two lines that enables the blink in the assembly code:



Rebuild it.



Program it using the new tool.



Port B number 5 is actually the digital Pin 13 according to the pinout in the following figure:



Make the following connections:



After you program it, the LED should be constantly ON. Then uncomment the delay function, it should start blinking.





------------------
References
1. Refer to this link for explanations to the code. If this link is disabled, here is the printed version.