Programming Arduino Mega2560 using AVR Studio & AVRISP mkII

I'm writing a program in assembly that will generate a high frequency PWM signal from an Arduino Mega 2560. I'm new to using Arduino microcontrollers and AVR studio. When I'm writing my program in the Arduino IDE, I notice that the default programmer for my Arduino Mega 2560 is the avrisp mkII. I also noticed that AVR Studio 4 has avrisp mkII as an option for a programmer.

So, is it possible to use avrisp mkII on the Arduino Mega2560 to upload a .hex file from AVR studio into the board's flash memory?

When I bought my Arduino Mega 2560, the bootloader was already programmed into the board's flash memory. But, the datasheet does not say where the bootloader is stored in flash memory. I also looked at the forum and online, and I couldn't find any answers.

Thus, does anyone know where the bootloader is stored in the Arduino Mega 2560 board's flash memory? (Specifically, I want to know what the starting memory address for the location of the bootloader in flash memory.)

For this post, I apologize in advance if any of the questions have been addressed numerous times already. If my questions have been addressed in another topic, please send me the link for those topic(s).

The bootloader section is at the high end of Flash memory.

So, is it possible to use avrisp mkII on the Arduino Mega2560 to upload a .hex file from AVR studio into the board's flash memory?

avrisp mkII is a hardware device, not software that runs on the Arduino. Yes, you can use the AVRISP MkII to program the ATmega chip on an Arduino. You connect it to the 6-pin ICSP header. The Arduino IDE uses avrdude to talk to either an ISP device (such as the AVRISP MkII) or the Arduino bootloader.

Thanks for your reply johnwasser. Your response did help me with some questions, but it also raised more questions.
When using the arduino IDE, I notice that the default programmer for my Arduino Mega2560 board is the avrisp mkII. In addition, I inspected my board and it appears that an avrisp mkII is already installed on the Arduino Mega2560 board when I bought it. The attachment below shows a picture of my board with red arrows pointing to what I think is the avrisp mkII (note: you need microsoft office word 2007 or later to view this attachment). So, is it possible to use the avrisp mkII on the board to upload a program from avr studio to the ATMEGA2560 microcontroller?
In addition, if I deleted the Arduino bootloader before uploading a program from avr studio, would my program still run correctly after I uploaded it and manually executed the program?

Thanks in advance for any help.

Arduino pic.docx (553 KB)

When using the arduino IDE, I notice that the default programmer for my Arduino Mega2560 board is the avrisp mkII.

You generally do not use a 'programmer' with an Arduino unless you need to re-install the bootloader. The bootloader takes care of writing your sketch into memory. The upload protocol for the bootloader on the Mega 2560 is STK500V2 (see boards.txt where it says: mega2560.upload.protocol=stk500v2)

In addition, I inspected my board and it appears that an avrisp mkII is already installed on the Arduino Mega2560 board when I bought it.

The component you are pointing to is the ATmega16u2 processor chip being use as a USB to Serial converter. It allows your PC to talk to the bootloader through the serial port of the main ATmega2560 chip.

So, is it possible to use the avrisp mkII on the board to upload a program from avr studio to the ATMEGA2560 microcontroller?

If you have the Arduino bootloader installed in the ATmega2560 chip you can use the STK500V2 protocol to upload sketches to the Arduino Mega.

In addition, if I deleted the Arduino bootloader before uploading a program from avr studio, would my program still run correctly after I uploaded it and manually executed the program?

If you delete the bootloader there will be no software to interpret the STK500V2 messages so you will no longer be able to upload sketches without a hardware ISP. The hardware ISP connects to the 6-pin ISP connector next to the ATmega2560 chip and uses the SPI interface to write directly to FLASH memory.

Thanks for your reply johnwasser.It really helped me understand how the bootloader on the Arduino boards works and how sketches are upload to the AtMega2560 microcontroller via the bootloader.

I'm thinking of writing a problem in assembly language that will generate high frequency pwm signals to control the mosfets in an h-bridge inverter.
So, if I upload this program using avr studio and a avrisp mkII programmer, would the program automatically execute after uploading or would I need to manually execute the program using commands?
I looked at the datasheets on the avrisp mkII programmer and avr studio, but I could not find anything on how to run the program after uploading to the microcontroller.

It executes on startup. So, power-on or reset. No manual start is necessary. (Usually, the last thing that happens after programming is to reset the chip, so it starts executing immediately. But that depends on how you wire it up, and what you use to upload your program. Safe bet is to hit reset afterwards.)