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.
The Adafruit Trinket uses an usbtiny USB programmer as the external 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.
An Arduino Uno can be turned into an external programmer. From the Arduino IDE, select File▶Examples▶Arduino ISP▶Arduino 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.
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 |