Let's upload a sketch to a board containing an ATmega328p chip using an external programmer.
ATmega Minimal DevBoardIt may look different but this board is an Arduino Uno or Nano. Same processor, same components except Arduinos have a built-in programmer circuit.
We will use the USBTiny programming device. Careful inserting the cable. The 10pin connectors are keyed to go in only one way. This protects both the board and the programmer.
Open a New sketchCall the sketch count.ino. This code toggles IO pins on all three ports. It will work on ATmega328 and ATmega8 processors.
// toggle IOs on output ports
void setup()
{ /* DDRA=0xFF;*/ DDRB=0xFF;DDRC=0xFF;DDRD=0xFF;} // all ports as output
void loop()
{ /* PORTA++;*/ PORTB++;PORTC++;PORTD++; delay(50); } // binary count
CompileClick the checkmark icon in the menu to verify the code compiles. Correct any errors.
Look at the bottom right of the screen and ensure your Arduino IDE is set to compile for a regular Uno board.
PreferencesMenu File->Preferences and tick the box for Verbose output during: Upload. We want to see the upload progress details.
Menu Tools -> Programmer. We select USBTinyISP.
Take a look at the other programmer names.
Burn BootloaderYou only have to do this once. If your chip is new then Arduino needs you to Burn Bootloader. Go to the menu Tools->Burn Bootloader. A small program will be written to the integrated circuit so that it will work as an Arduino.
Watch for the message avrdude: 1 bytes of lock verified.
Upload Using ProgrammerMenu Sketch->Upload Using Programmer or Ctrl+Shift+U on your keyboard.
It will take a while to compile. Watch the bottom of the screen. The orange text is the verbose output.
SuccessThe message "avrdude done. Thank you." tells us the firmware was uploaded to the device through the programmer.
While the asterisks cross the screen the board goes through a programming cycle. The LED bar is connected to PORTB. During the programming we see 3 wires carrying signal then one during the verification cycle.
Comments