summaryrefslogtreecommitdiffstats
path: root/_site/archive/arduino-uno/index.html
blob: 2de0ece06da7a0de3e30869de40ee59331c6ebd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>How to configure ATmega328P microcontrollers to run at 3.3V and 5V</title>

    <head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>How to configure ATmega328P microcontrollers to run at 3.3V and 5V</title>
  <link rel="stylesheet" href="/assets/css/main.css">
  <link rel="stylesheet" href="/assets/css/skeleton.css">
</head>



  </head>
  <body>

    <div class="container">
  <ul id="navlist" class="left">
    
    <li >
      <a href="/" class="link-decor-none">hme</a>
    </li>
    <li class="active">
      <a href="/archive/" class="link-decor-none">blg</a>
    </li>
    <li >
      <a href="/projects/" class="link-decor-none">poc</a>
    </li>
    <li >
      <a href="/about/" class="link-decor-none">abt</a>
    </li>
    <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
  </ul>
</div>



    <main>
      <div class="container">
        <h2 class="center" id="title">HOW TO CONFIGURE ATMEGA328P MICROCONTROLLERS TO RUN AT 3.3V AND 5V</h2>
        <h6 class="center">10 APRIL 2025</h5>
        <br>
        <div class="twocol justify"><p>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.</p>

<p>The steps that follow refer to the following pinout.</p>

<table style="border: none; width: 100%;">
  <tr style="border: none;">
    <td style="border: none; width: 50%; vertical-align: top;">
      <img src="pinout.png" alt="Pinout" style="width: 100%" />
      <p style="text-align: center;">Pinout</p>
    </td>
    <td style="border: none; width: 50%; vertical-align: top;">
      <img src="breadboard.jpeg" alt="Circuit" style="width: 100%" />
      <p style="text-align: center;">Breadboard</p>
    </td>
  </tr>
</table>

<h2 id="5v-16mhz-configuration">5V-16MHz configuration</h2>

<ol>
  <li>Connect pin 1 to 5V via a 10kΩ resistor.</li>
  <li>Connect a 16MHz crystal oscillator across pins 9 and 10.</li>
  <li>Connect each pin of the crystal to ground via 22pF capacitors.</li>
  <li>Connect pins 7, 20, and 21 to 5V.</li>
  <li>Connect pins 8 and 22 to ground.</li>
</ol>

<p>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.
<a href="Makefile">Here’s</a> a sample Makefile for avr-gcc and avrdude.</p>

<h2 id="33v-8mhz-configuration">3.3V-8MHz configuration</h2>

<p>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.</p>

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

<ol>
  <li>Upload the ‘ArduinoISP’ sketch to the Arduino Uno.</li>
  <li>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.</li>
  <li>Connect the SPI ports (SCK, MISO, and MOSI) of the two MCUs.</li>
  <li>Connect the Arduino Uno’s SS pin to the IC’s RESET pin (pin 1).</li>
  <li>Connect the IC’s V<sub>CC</sub> to a 5V supply (e.g., the Arduino Uno’s 5V
pin).</li>
  <li>Burn the bootloader to the ATmega328P:
    <ul>
      <li>Select ‘ATmega328P (3.3V, 8MHz)’ from Tools &gt; Processor.</li>
      <li>Select ‘Arduino as ISP’ from Tools &gt; Programmer.</li>
      <li>Select Tools &gt; Burn Bootloader.</li>
    </ul>
  </li>
</ol>

<p>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.
<a href="3v3.Makefile">Here’s</a> a sample Makefile with adjusted parameters (e.g., baud
rate) for an 8MHz clock.</p>

<p>In both configurations, if you intend to use the ATmega328P’s analog-to-digital
converter with the internal 1.1V or AV<sub>cc</sub> voltage as reference, do
not connect AREF (pin 21) to V<sub>cc</sub>. Refer to section 23.5.2 in the
datasheet for more information.</p>

</div>
        <p class="post-author right">by Wickramage Don Sadeep Madurange</p>
      </div>
    </main>

  </body>
</html>