From 97a594483fb25f52229b71b857747a79c57043fe Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Thu, 4 Dec 2025 14:11:49 +0800 Subject: Arduino Uno post. --- _site/archive/arduino-uno/index.html | 75 ++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 37 deletions(-) (limited to '_site/archive/arduino-uno') diff --git a/_site/archive/arduino-uno/index.html b/_site/archive/arduino-uno/index.html index 2de0ece..2e0ddf1 100644 --- a/_site/archive/arduino-uno/index.html +++ b/_site/archive/arduino-uno/index.html @@ -67,52 +67,53 @@ oscillator.

5V-16MHz configuration

-
    -
  1. Connect pin 1 to 5V via a 10kΩ resistor.
  2. -
  3. Connect a 16MHz crystal oscillator across pins 9 and 10.
  4. -
  5. Connect each pin of the crystal to ground via 22pF capacitors.
  6. -
  7. Connect pins 7, 20, and 21 to 5V.
  8. -
  9. Connect pins 8 and 22 to ground.
  10. -
- -

In addition to the the connections above, it’s a good idea to add 0.1μF -decoupling capacitors between pins 7, 20, and 21 and ground. -Here’s a sample Makefile for avr-gcc and avrdude.

+

Powering ATmega328P microcontrollers with 5V is the most common setup. This is +also how Arduino Uno boards are wired.

+ +

In this configuration, the microcontroller’s pin 1 is connected to 5V via a +10kΩ resistor. Pins 9 and 10 are connected to a 16MHz crystal oscillator via +two 22pF capacitors connected to ground. The microcontroller is powered by +connecting pins 7, 20, and 21 to a 5V DC power supply. Lastly, pins 8 and 22 +are connected to ground. In addition to the these connections, which are +required, it’s a good idea to add 0.1μF decoupling capacitors between pins 7, +20, and 21 and ground.

+ +

Here’s a sample Makefile for compiling C programs for ATmega328P +microcontrollers using avr-gcc/avrdude toolchain.

3.3V-8MHz configuration

-

Standard ATmega328P chips are preconfigured to run at 5V. To run one at 3.3V, -we must first modify its fuses (e.g., BOD level). If the chip contains a -pre-installed bootloader that expects a 16MHz clock (such as the Arduino Uno -bootloader), it must be replaced with one that is more amenable to an 8MHz -clock.

- -

In the following steps, we use an Arduino Uno as an in-system programmer to -replace the embedded bootloader and modify the appropriate fuses.

- -
    -
  1. Upload the ‘ArduinoISP’ sketch to the Arduino Uno.
  2. -
  3. Wire up the ATmega328P IC as described in the previous section, while -replacing the 5V supply with a 3.3V supply and 16MHz crystal with an 8MHz -crystal.
  4. -
  5. Connect the SPI ports (SCK, MISO, and MOSI) of the two MCUs.
  6. -
  7. Connect the Arduino Uno’s SS pin to the IC’s RESET pin (pin 1).
  8. -
  9. Connect the IC’s VCC to a 5V supply (e.g., the Arduino Uno’s 5V -pin).
  10. -
  11. Burn the bootloader to the ATmega328P: -
      -
    • Select ‘ATmega328P (3.3V, 8MHz)’ from Tools > Processor.
    • -
    • Select ‘Arduino as ISP’ from Tools > Programmer.
    • -
    • Select Tools > Burn Bootloader.
    • -
    -
  12. -
+

Electrical connections for running an ATmega328P at 3.3V are identical to that +of the 5V circuit. The only differences are that all the 5V connections are +replaced with a 3.3V power source and a 8MHz crystal oscillator takes the place +of the 16MHz crystal.

+ +

However, standard ATmega328P chips are preconfigured to run at 5V. To run one +at 3.3V, we must first modify its fuses that control characteristics like the +BOD level. If a bootloader that expects a 16MHz clock (e.g., Arduino +bootloader) is pre-installed on the ATmega328P, it must be swapped with one +that accepts an 8MHz clock. To accomplish that, we need an in-system programmer +(ISP).

+ +

Fortunately, we can turn an ordinary Arduino Uno board into an ISP by uploading +the ‘ArduinoISP’ sketch found in the Arduino IDE. The ISP communicates with the +microcontroller using a Serial Peripheral Interface (SPI). So, connect the SPI +port of the ATmega328P to that of the Arduino Uno, and the Uno’s SS pin +to the ATmega328P’s RESET pin.

+ +

Power up the the ATmega328P by connecting its VCC to a 5V supply (we +can use Arduino Uno’s 5V pin). From the Arduino IDE, select ‘ATmega328P (3.3V, +8MHz)’ for processor from the tools menu. Also from the tools menu, select +‘Arduino as ISP’ as programmer. Finally, upload the new bootloader by selecting +‘Burn Bootloader’ from the tools menu.

The ATmega328P is now ready to run at 8MHz with a 3.3V power supply. You can upload programs to the ATmega328P as you normally would using avrdude. Here’s a sample Makefile with adjusted parameters (e.g., baud rate) for an 8MHz clock.

+

Remarks

+

In both configurations, if you intend to use the ATmega328P’s analog-to-digital converter with the internal 1.1V or AVcc voltage as reference, do not connect AREF (pin 21) to Vcc. Refer to section 23.5.2 in the -- cgit v1.2.3