Arduino projects

Burn Bootloader to AT328P-PU Arduino Uno

The Arduino UNO development board is a great development platform for making a wide variety of entertainment devices and useful microcontroller circuits, but including a complete Arduino UNO development board assembly in each project can be very expensive. This article will focus on burning the Bootloader to the ATmega controller and then implementing Arduino Uno-like functions. With the instructions in this article, you can reduce this cost by 50% or more.

What is an Arduino? Are you sure?

It’s hard to live on Earth if you haven’t heard of Arduinos since 2003; love them or hate them, they’re everywhere. But what exactly is an Arduino?

Contrary to what many people think, an Arduino is not a microcontroller; it is a specific brand of PCBA (Printed Circuit Board Assembly) that contains a microcontroller. The microcontroller is usually from the ATmega series from Microchip , and the most commonly used ATmega microcontroller is the AT328P . But it’s not just the AT328P that will work in an Arduino PCBA or the Arduino IDE; the picture below shows what happens when you try to upload a sketch to a regular AT328P that you bought directly from a vendor.

Burn Bootloader to AT328P-PU  Arduino Uno

As you can see, the upload failed ten times, and each time it failed for the same reason. Even though the error message doesn’t state it, the reason for the failure is that the ATmega microcontroller does not contain the Arduino bootloader, which is a small piece of code that tells the ATmega microcontroller how to respond to Arduino IDE instructions. Fortunately, the bootloader code can be uploaded to the selected ATmega microcontroller through a relatively simple process.

Below are step-by-step instructions for uploading the Arduino bootloader code to the AT328P-PU using a genuine Arduino UNO board. Essentially, the process is divided into four parts:

1. Build the bootloader circuit

2. Set up the Arduino UNO development board as an ISP (In-Circuit Serial Programmer)

3. Connect the Arduino UNO to the bootloader circuit

4. Upload the bootloader code

After successfully uploading the bootloader code to the AT328P-PU, the bootloader circuit can be easily converted into a programming and operating circuit for the microcontroller, making it a development platform with many of the capabilities of the UNO. This article will also provide details of the process.

Building the Bootloader Circuit

In order to upload the bootloader code from an Arduino UNO to a blank ATmega328P-PU , a small bootloader circuit is required.

The schematic diagram of the AT328P-PU bootloader circuit is shown below and is very simple. The oscillator circuit consists of X1, C1, and C2; note that X1 must be a 16MHz crystal, not a 20MHz one. Although the AT328P-PU can use a 20MHz crystal, the bootloading process requires a 16MHz operating frequency. R1 is the pull-up resistor for the reset pin, and C3 is a typical Vcc bypass capacitor.

The callouts on the left side of the schematic define the pins on the UNO that each wire should be connected to, and the connections are shown in the breadboard photo below the schematic. The wire colors shown in the schematic correspond to the wire colors in the photo.

Burn Bootloader to AT328P-PU  Arduino Uno

Setting up Arduino UNO as ISP

After double-checking the wiring of the bootloader circuit, but before connecting it to the UNO, you must set up the UNO as an ISP (In-Circuit Serial Programmer). Connect the UNO to your computer, launch the Arduino IDE, and select the correct COM port for the UNO. Then, follow the steps shown in the following Arduino IDE screenshots.

1. Make sure the board is connected as a Genuine UNO.

2. Make sure the UNO development board functions as an Arduino ISP .

3. Open the Arduino ISP sketch.

4. Upload the Arduino ISP sketch to the UNO.

5. When you see the ” done uploading ” message, your UNO board is ready to act as an ISP and is able to recognize and respond to commands from the Arduino IDE.

Upload Bootloader Code

Now, connect the bootloader circuit to the Arduino UNO board using six wires exactly as shown in the schematic and photos provided in the Building the Bootloader Circuit section above. Once all the wiring has been double checked, you are ready to burn the following bootloader code into the AT328P-PU microcontroller in the bootloader circuit.

1. Select ” Burn Bootloader ” as the function for your UNO; when you click ” Burn Bootloader ” the process should start immediately.

2. When you see the ” Done burning bootloader ” message, the process is complete and the AT328P-PU is able to recognize and respond to instructions from the Arduino IDE.

Minimal programming (and operating) circuit

It is quite simple to convert the AT328P-PU bootloader circuit into a minimal programming and operating circuit as shown in the following diagram and breadboard photo.

1. Remove all six wires between the UNO and the bootloader circuit.

2. Connect R2 and LED1 between ground and pin 19 of AT328P-PU.

3. Connect pins 1, 3, 4, and 5 of the USB-to-TTL converter to the AT328P-PU as shown. Pin 2 is not used.

4. Connect Pin 6 to C4 (0.1μF capacitor) to Pin 1 of the AT328P-PU. (C4 ensures that the DTR signal from the USB-to-TTL converter produces a transient reset signal rather than a signal that remains at a logic low for a long time.)

Uploading the First Sketch: Blinking an LED

1. To confirm the operation of the AT328P-PU minimal programming and operating breadboard, open the ” Blink ” sketch from the basic examples included with the Arduino IDE.

2. After selecting the correct COM port, compile and upload the “Blink” sketch to the AT328P-PU.

The first attempt to upload the “Blink” sketch failed; can you see why it failed? Hint: Look at the lower right corner of the IDE window above and compare it to the same area of ​​the two IDE windows below.

The reason the first upload attempt failed was because the wrong COM port (3) was selected instead of the correct COM port (6).

Summarize

We have now completed our build! You have uploaded the Arduino bootloader to the AT328P-PU and then uploaded the “Blink” sketch to the AT328P-PU, as confirmed by the blinking yellow LED on the minimal programming and operating circuit breadboard. Now, any other functional Arduino sketch can be uploaded likewise and the components required for that sketch can be attached to the AT328P-PU and used successfully.

Back to top button