The Arduino will run the Arduino ISP sketch and function as a programmer device. Be careful when handling electronic components. This graphic is from Arduino to a Microcontroller on a breadboard.
The programmer becomes a USB to SPI converter. The hex file stored on your PC will be recorded into the flash memory of the target chip. Pin10 of our Programmer toggles the reset of our target chip. A hex file from your PC is uploaded through the programmer to the target chip.
Upload the ArduinoISP sketchThis is an ordinary sketch included in Examples->11.ArduinoISP. Read some of the code to see what the authors say about it. Arduino Uno at the bottom means the programmer device.
Upload to the programmer Uno and it becomes a programming device named avrisp or stk500v1 located on a serial comms port.
The Arduino Uno board is now a programmer that you can use to program boards containing ATmega and ATtiny chips. The same USB port that interfaced the Uno to the PC is now a programmer like a USBasp or USBtiny dongle.
Close the Arduino ISP sketch and look at the green LED connected to the Pulse pin9 of the programmer. We are finished programming this Uno to be a programming tool.
Sketch for ATmega168Open a sketch you want to upload to the Target chip. Here we use Blink. Menu File->Examples->Basic->Blink. Our diagram has an ATmega168 chip as target and that processor is used in the Diecimila board.
Select the board and processor by going Tools->Board->AVR->Diecimila and then Tools->Processor->ATmega168.
Arduino as ISPLook through the menu at Tools->Programmer and you see a lot of choices. Select Arduino as ISP.
Menu Sketch->Upload Using Programmer or ctrl+shift+U on keyboard. The Arduino IDE program will talk to the programmer in a pass through mode to reach the target device.
Good question. Now that you have a programmer device you can flash your chip with new programs. A bootloader is needed only if you want to your chip to be programmed on the USB port like an Arduino board.
The bootloader consumes flash memory that you may want for a program. You may be better off just programming a chip once with an Arduino ISP programmer.
Target ATmega328pThe target can be another Uno board containing an ATmega328p processor. Or it could be an ATtiny chip. Use menu Tools->Boards Manager to select the Arduino Uno board.
Pin10 of our Programmer toggles the reset of our Target board. A hex file from your PC is uploaded through the programmer to the target chip.
Upload Using ProgrammerWatch the progress for any error information. Bottom of the screen shows target board. Menu Sketch->Upload Using Programmer or press Ctrl+Shift+U on the keyboard.
Turn on verbose output during upload and take a look at the line with the avrdude command. Our Arduino as ISP becomes a -c stk500v1 programmer circuit. We will use this information, later.
There are some good reasons to Burn Bootloader onto an ATmega328p chip. When you buy chips from the factory they will not have the bootloader program. Uno boards that you have been programming may have the bootloader erased.
Menu Tools->Burn Bootloader watch for message 1 bytes of lock verified. Burn Bootloader sets a fuse to block erasure of the flash memory where the bootloader program is installed.
Open a terminal window. Type the avrdude command.
avrdude -p m328p -c avrisp -P /dev/ttyACM0 -b 19200 -U flash:r:target.hex:i
Notice that avrdude has read the fuse settings for the target chip. When you program a Uno board through the serial port these values are blocked from you.
I'm getting failuresYou may have to clear red error indicator on pin8 by pressing resetbutton on programmer board. Check the parameters you've typed. Double-check part and circuit values. Use -b 9600 to slow baud rate.
avrdude -p m328p -c avrisp -P /dev/ttyACM0 -b 9600 -U flash:r:target.hex:i
Is everything connected? Try using another computer. Try different USB cables. Switch from USB2 to USB3 ports and vice-versa. Try a GUI version of Avrdude. Is the green pulse LED still throbbing.
Refresh the ArduinoISP sketch in the programmer board. Verify port number.
MicroChip StudioATmega and ATtiny chips are made by MicroChip. MicroChip Studio and MPLab X IDE can write programs that will run on the chips. MicroChip Studio also provides a programmer upload feature.
Menu Tools->External Tools to set up a new programming device.
We will call the new External Tool ArduinoISP. On this computer the arguments need to be
-p atmega328p -c avrisp -P com6 -b 19200 -U flash:w:$(BinDir)\$(TargetName).hex:i
Like the avrdude command earlier. Scripting allows us to upload a hex file named after the project in a directory named debug.
To program the device use menu Tools->ArduinoISP and a black command window will flash as avrdude is executed.
AVR ISP Arduino programmer shield with 28pin ZIF socket can seat ATmega328p, ATmega8 and ATmega168 chips. You can program other boards with 6pin and 10pin ISP/ICSP in service programming headers.
Insert chip into ZIF socket or connect with an ISP cable. Install shield on Uno board. Connect to PC and upload ArduinoISP sketch. Check throbbing pulse indicator. Clear red Error indicator by reseting Uno board.
Comments
Please log in or sign up to comment.