Arduino As ISP Programmer - DevBhoomi Robots

Home Top Ad

Responsive Ads Here

Post Top Ad

Your Ad Spot

Monday, September 17, 2018

Arduino As ISP Programmer




isp_shield_topOne of the nice aspects of Arduino compatible hardware is the ease of program downloads. This is, in part, due to the bootloader that is programmed into the controller. How does that bootloader get on the hardware in the first place?
One answer is that a second Arduino can be used to load the bootloader (or any other stand-alone code) into the ‘virgin’ target hardware. The Arduino IDE includes an example program called ArduinoISP used for this, but it helps to have some supporting hardware. I built a shield with a few connections that speeds up the process of programming controllers.

 

 

How it Works

To program new Atmel controllers, you can use a device called and AVR ISP (AVR In System Programmer or In-circuit System Programmer). The AVR ISP device implements a communication protocol (see here for more information) used by all Atmel AVR tools and is used for programming tinyAVR and megaAVR devices using the SPI interface.
isp_icsp_header




The ArduinoISP software is loaded into a working Arduino system to implement this protocol. The Arduino communicates to the target hardware using the SPI pins MISO, MOSI and SCK. On all Arduinos, these pins can be found on the ICSP/SPI header (usually 6 pins arranged a 2 rows of 3 pins). On an Arduino Uno, these are also digital pins 11, 12 and 13, respectively; other models may map differently.
There is no shortage of information on how the host and target ICs need to be connected to each other. The majority of explanations, however, use temporary jumpers between the programming and target devices. As I use standalone microcontrollers in a few projects, I decided to build a dedicated shield to avoid recreating the point to point connections every time.
The shield I made (shown below) is used to program ATTiny 8 pin and 20 pin target devices, but the same principles apply for other types. Note that I accidentally inserted the IC sockets upside down, so the dot (•) marks the actual pin 1 of the IC.
isp_shield
Click to enlarge
There are a couple of other features implemented to support the ArduinoISP software:
  • The Reset pin to the IC socket(s) and ICSP header needs to be modified to connect to pin 10 (yellow wires). This allows the software to control resetting the target device. The trace to the ICSP header from the hardware reset needs to be cut.
  • 3 LEDs with with resistors (white wires) on
    • Pin 9 for a Hearbeat – the software fades this on/off to show the programmer is running (green LED on the shield).
    • Pin 8 for Error – the software lights this up if something goes wrong (Red LED).
    • Pin 7 for Programming – the software is communicating with the target device (Yellow LED).
isp__icsp_cablesAdditionally, I made a couple of accessories that connect to the ICSP header to allow me to program devices that are not 8 or 20 pin ICs.
The first is a parallel cable ICSP socket to ICSP socket cable. This enables easy programming of a target device already placed in a circuit with an ICSP header, such as another Arduino Board.
The second is a ICSP cable that ends in small clips labelled with the signal names. This caters for devices where there is no ICSP header. The clips connect to the IC pins directly. This is not as convenient as plugging in the IC, but works as a last resort.

Using the Programmer

To use the programmer, you need to load the ArduinoISP code to the working Arduino system from the IDE (menu selections File | Examples | ArduinoISP). ArduinoISP needs to be compiled for the Arduino board (in my case this was Arduino Genuino/Uno). Once it has loaded, the hearbeat LED will start pulsing.
Now Select the Arduino as ISP programmer type from the IDE Tools menu.
The next step is to attach the programmer to the target hardware (put the IC in the shield socket or connect via the ICSP header). In the IDE, load the software to be programmed in the target device and select the target from the boards menu. This selection may have to be previously installed using the Board Manager if it is a standalone controller.
Compile and download the software to the target device. The IDE will now use the ArduinoISP system to download the target software using the AVR ISP protocol.

Post Top Ad

Your Ad Spot