Flash ATMEGA with Studio7

If you need to replace the microcontroller on an Arduino board or if for some reason you have used it by writing it completely and thus eliminating its bootloader, you can reprogram it to make it work with the native Arduino ide.

Already programming micro Atmel I already have at home I have the Atmel ICE programmer and therefore I use this together with the Atmel Studio 7 program.

A quick and easy process .. and above all smoothly (usually).

 

It is necessary to connect the programmer to the computer, open Atmel Studio and click on the button for programming the micro (1), then select our programmer (in the example none), choose the type of micro to program (2), in the case of Arduino UNO or Nano boards it is a ATmega328P (check your micro for safety) and then click on the button apply to confirm the selection.

Now it is necessary to power the micro or if on the board, feed Arduino directly with the USB cable and connect the programmer to the ICSP pins and then check if everything communicates correctly by reading the ID of the micro with the button read.

We select the item Memories (3) and browse the path where to find the bootloader of our model, for this thing it is necessary to have installed the Arduino ide, the bootloader is located in this path (if you have installed lide on disk C):
C: \ Program Files (x86) \ Arduino \ hardware \ arduino \ avr \ bootloaders \ optiboot \ optiboot_atmega328.hex
If you have different versions of Arduino you will need to select the one suitable for the micro in use.
At this point, press the button program to program the micro with the selected bootloader.

The last step is to program the spindles, go to the relative item (3) and set the following values on the registers:

EXTEND:0x05
HIGH:0xDE
LOW:0xFF

Finally press the button program.

P.S. If you need it, you can calculate the time zones online on the site: https://www.engbedded.com/fusecalc

End! 

PS .: With this method it is possible to program the micro directly even if we wanted to remove the bootloader to load the program directly into memory, so that even by connecting Arduino to the PC it will not be possible to delete / modify its program (but only via ICSP).