From 25615d16f93ffafcb19d0940cfab75e1f374b3b9 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Fri, 7 Nov 2025 21:07:12 +0800 Subject: Improve writing. --- _site/archive/arduino-uno/index.html | 49 +++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to '_site/archive/arduino-uno/index.html') diff --git a/_site/archive/arduino-uno/index.html b/_site/archive/arduino-uno/index.html index 7509267..3b0234d 100644 --- a/_site/archive/arduino-uno/index.html +++ b/_site/archive/arduino-uno/index.html @@ -2,12 +2,12 @@ - Programming ATmega328P chips + ATmega328P chips - Programming ATmega328P chips + ATmega328P chips @@ -40,15 +40,15 @@
-

PROGRAMMING ATMEGA328P CHIPS

+

ATMEGA328P CHIPS

10 APRIL 2025

-

This post is a step-by-step guide for wiring up ATmega328P ICs to run at 5V -with a 16MHz crystal and 3.3V with an 8MHz crystal. While the 5V -configuration is common, the 3.3V configuration can be advantageous in -low-power applications and when interfacing with parts that run at 3.3V.

- -

5V-16MHz configuration

+

This is a quick reference for wiring up ATmega328P ICs to run at 5V and 3.3V. +While the 5V configuration is common, the 3.3V configuration can be useful in +low-power applications and when interfacing with parts that themselves run at +3.3V. In this guide, the 5V setup is configured with a 16MHz crystal +oscillator, while the 3.3V configuration makes use of an 8MHz crystal +oscillator.

The steps that follow refer to the following pinout.

@@ -65,6 +65,8 @@ low-power applications and when interfacing with parts that run at 3.3V.

+

5V-16MHz configuration

+
  1. Connect pin 1 to 5V via a 10kΩ resistor.
  2. Connect a 16MHz crystal oscillator across pins 9 and 10.
  3. @@ -73,23 +75,30 @@ low-power applications and when interfacing with parts that run at 3.3V.

  4. Connect pins 8 and 22 to ground.
-

In addition to the connections described above, it’s a good idea to add 0.1μF +

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.

3.3V-8MHz configuration

-

The following steps use Arduino Uno as an ISP and Arduino utilities to program -ATmega328P’s bootloader and the fuses (e.g., BOD level) for a 3.3V supply.

+

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 Uno.
  2. -
  3. Wire up the ATmega328P as described in the previous section. Replace the 5V -supply with a 3.3V supply and use an 8MHz crystal instead of the 16MHz +
  4. Upload the ‘ArduinoISP’ sketch to the Arduino Uno.
  5. +
  6. 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.
  7. Connect the SPI ports (SCK, MISO, and MOSI) of the two MCUs.
  8. -
  9. Connect Uno’s SS pin to the IC’s pin 1 (RESET).
  10. -
  11. The IC can be powered by the Arduino Uno’s 5V pin.
  12. +
  13. Connect the Arduino Uno’s SS pin to the IC’s RESET pin (pin 1).
  14. +
  15. Connect the IC’s VCC to a 5V supply (e.g., the Arduino Uno’s 5V +pin).
  16. Burn the bootloader to the ATmega328P:
    • Select ‘ATmega328P (3.3V, 8MHz)’ from Tools > Processor.
    • @@ -100,14 +109,14 @@ crystal.

The ATmega328P is now ready to run at 8MHz with a 3.3V power supply. You can -upload programs to the ATmega328P as you usually would using avrdude. +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.

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 ADC -Voltage Reference in the datasheet for more information.

+not connect AREF (pin 21) to Vcc. Refer to section 23.5.2 in the +datasheet for more information.

-- cgit v1.2.3