0% found this document useful (0 votes)
14 views4 pages

In-Circuit Programming with Arduino UNO

This document provides instructions for using an Arduino board as an in-circuit serial programmer to burn a hex file onto a microcontroller. It involves uploading an ArduinoISP sketch to program the Arduino board, connecting the Arduino to the microcontroller via SPI, and using the avrdude command in the command prompt to flash the hex file onto the microcontroller while it remains in the circuit.

Uploaded by

Abdul Hadi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

In-Circuit Programming with Arduino UNO

This document provides instructions for using an Arduino board as an in-circuit serial programmer to burn a hex file onto a microcontroller. It involves uploading an ArduinoISP sketch to program the Arduino board, connecting the Arduino to the microcontroller via SPI, and using the avrdude command in the command prompt to flash the hex file onto the microcontroller while it remains in the circuit.

Uploaded by

Abdul Hadi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Arduino as In-Circuit Serial Programmer

Contents
1 Acknowledgements 2

2 Introduction 2

3 Software Resources 2

4 Steps to burn your program 3


4.1 Step 1: Setting up Arduino Board . . . . . . . . . . . . . . . . . 3
4.2 Step 2: Connect Arduino with microcontroller . . . . . . . . . . . 3

5 Step 3: Burn Hex file in microcontroller 3

1
1 Acknowledgements
This tutorial is prepared by Mohammad Azfar Tariq and Muhammad Usman
under the supervision of Dr. Rehan Ahmed for the course EE-222 Microproces-
sor Systems. Reporting any error or discrepancy found in the text is appreciated.

2 Introduction
Dispatching microcontroller from circuit and placing it on a high voltage pro-
grammer (MAXLOADER or SUPERPRO) again and again is tiresome. To
avoid this inconvenience in-circuit serial programming or generally, in-system
programming is used. It is a technique where a programmable device (like a
microcontroller) can be programmed while it is still in a circuit.
This is usually done using a host device. In our case we will be using using AT-
mega328P (a family member of ATmega16A) mounted on Arduino UNO board.
The communication protocol used for this purpose is Serial Peripheral Interface
(SPI). To learn what SPI actually is consult SparkFun website1 .

Figure 1: In red boundary ATmega328P

3 Software Resources
There are two software programs we need to undertake the task in hand
• Arduino IDE2
• WinAVR
Download WinAVR from this website3
1 [Link]
2 [Link]
3 [Link]

2
4 Steps to burn your program
4.1 Step 1: Setting up Arduino Board
• Start Arduino IDE
• Move to Files > Examples > ArduinoISP > ArduinoISP.
• A sketch will be opened. upload the sketch on Arduino after selecting the
appropriate port.

4.2 Step 2: Connect Arduino with microcontroller


Patch the circuitry as;
Arduino pin µC pin
11 MOSI
12 MISO
13 SCK
10 RST
VCC VCC
GND GND

Figure 2: Circuit

5 Step 3: Burn Hex file in microcontroller


1. Keep in mind the COM port your arduino is connected. You can check it
in Arduino IDE Tools > Ports.

3
2. Open Command Prompt.
3. Move to the folder that contains relevant hex file. This can be achieved
by entering cd space folder path in CMD prompt. For example to move
in folder “System32”, which is present in folder “Windows”, which in turn
is present in folder “C” we have to type,
1 cd C: \ Windows\ System32

4. Now run the following command replacing COM13 with your COM Port
name and [Link] with the name of your hex file.
1 avrdude −c a r d u i n o −p m16 −P COM13 −b 19200 −U f l a s h : w : abc . hex

Common questions

Powered by AI

The process begins with identifying the COM port connected to the Arduino and navigating to the folder containing the desired hex file using the Command Prompt. After setting the directory with the `cd` command, the `avrdude` tool is used with a command specifying the programmer type, microcontroller, COM port, and baud rate. The command `avrdude -c arduino -p m16 -P COM13 -b 19200 -U flash:w:abc.hex` instructs avrdude to write the hex file into the microcontroller's memory, completing the programming process .

Open-source platforms like Arduino have revolutionized microcontroller programming by democratizing access to technology and resources, allowing widespread user engagement and contribution. This accessibility accelerates learning curves, encourages community support and collaboration, and stimulates continuous innovation in programming strategies. Additionally, it empowers users to adapt and create applications tailored to specific needs, broadening skill development and practical application in real-world scenarios .

Setting up the Arduino board involves starting the Arduino Integrated Development Environment (IDE), navigating to Files > Examples > ArduinoISP > ArduinoISP, and opening the sketch. The user should upload this sketch to the Arduino board after selecting the appropriate communication port within the IDE to ensure successful connection between the board and the microcontroller .

Educational settings benefit from teaching in-circuit serial programming using Arduino as it provides students with hands-on experience in embedded systems and interfacing technologies. Such methodologies encourage problem-solving, enhance understanding of SPI protocols and microcontroller architecture, and foster skills in hardware-software integration. Moreover, using open-source tools like Arduino expands knowledge access and encourages innovation among students .

In-circuit serial programming (ICSP) provides significant benefits over traditional high voltage programming as it eliminates the need to repeatedly remove the microcontroller from its circuit for programming. This not only saves time but also reduces the risk of physical damage to the microcontroller during handling. ICSP allows for convenient updates and modifications directly within the circuit, which is more efficient and practical for iterative development processes .

The Arduino IDE is crucial in writing and uploading the required ArduinoISP sketch to the Arduino board, setting up the Arduino as an in-circuit serial programmer. It provides a user-friendly interface for selecting the correct port and board. The WinAVR software complements this setup by offering command-line tools for managing intricacies like the actual burning of hex files onto the microcontroller, leveraging `avrdude` for sending programming commands .

Challenges using Arduino as an ICSP might include issues with connection stability, incompatibility of certain microcontrollers, or incorrect software configurations. To overcome these, ensuring proper physical connections, updating software tools, and validating compatibility of devices is essential. Debugging involves checking COM port settings, ensuring the correct ArduinoISP sketch is loaded, and consulting SPI protocol documentation. Using diagnostic tools within the Arduino IDE can also aid in pinpointing and resolving issues .

The Serial Peripheral Interface (SPI) facilitates communication by using a synchronous serial communication protocol, enabling the Arduino board to send program instructions directly to the microcontroller while it remains in the system. SPI uses a master-slave architecture where the Arduino, acting as the master, controls data exchanges with the microcontroller, the slave, through relatively simple connections like MOSI, MISO, and SCK pins .

The structure of SPI protocol supports its functionality as an in-circuit serial programmer by allowing full duplex communication and a simple wiring scheme. With three primary lines (MOSI, MISO, SCK), SPI transmits data synchronously between Arduino and the microcontroller. This synchronous capability ensures that both sending and receiving devices are in sync, thus minimizing errors during the programming phase. By designating Arduino as the master, it controls the timing and data flow, streamlining the programming process .

The typical connections made between the Arduino and the microcontroller include MOSI (Master Out Slave In), MISO (Master In Slave Out), SCK (Serial Clock), and RST (Reset) pins, along with power connections like VCC and GND. These connections are crucial as they facilitate communication and provide power and clock signals necessary for synchronization. MOSI allows the Arduino to send data, MISO allows receiving data from the microcontroller, and SCK synchronizes these data transfers .

You might also like