Uploading Programs to the Microcontroller

After the source code has been generated and compiled to the machine code, it needs to be uploaded to the microcontroller. To get the program into its flash memory the microcontroller uses a few pins that are called programming pins. These programming pins are connected to the PC through a device called an external programmer. A software called the programmer uploads the program through the external programmer onto the microcontroller.

It's not necessary to specify the entire toolchain to upload the program if the default setting are used. For example, for an Arduino Uno it suffices to specify the connection port to which the external programmer, and by extension the board itself, is connected.

Load the package.
Download code to an Arduino Uno though a specified port.
Specify the programmer, external programmer, and connection port.

The Adafruit Trinket uses an usbtiny USB programmer as the external programmer.

Download to an Adafruit Trinket using the usbtiny programmer.

To upload to a standalone microcontroller its programming pins must be connected to an external programmer, in addition to powering it correctly.

The following shows the connections to program an ATmega168 using an usbasp programmer.

2.gif

Program an ATmega168A_ 28PDIP microcontroller.

An Arduino Uno can be turned into an external programmer. From the Arduino IDE, select FileExamplesArduino ISPArduino ISP and upload it to the Arduino. Now the Arduino board is an AVR In System Programmer (AVRISP). Connect the programming pins of the microcontroller to the Arduino pins as shown below, and the board is ready to upload to the microcontroller.

3.gif

Program an ATmega168A_ 28PDIP microcontroller using an Arduino Uno.

The following settings can be specified for the programmer and external programmer:

"ProgrammerName"programmer to be used
"ProgrammerInstallation"location of the programmer software
"ProgrammerConfigurationName"programmer configuration to be used
"ProgrammerConfigurationInstallation"location of the programmer configuration software
"ExternalProgrammer"external programmer to be used
"ConnectionPort"port where external programmer is connected
"BaudRate"baud rate at which to upload the code
"f"programmer flag f

Program upload settings.

Specify the programmer, programmer location, and connection port on a Mac.
Get verbose diagnostic output and direct it to a log file.
Import the log file.