diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-12-04 14:11:49 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-12-04 14:11:49 +0800 |
| commit | 97a594483fb25f52229b71b857747a79c57043fe (patch) | |
| tree | beac87ff3c8a36d0e69abd4e76a35b0f1cab6d7a | |
| parent | 11364a5c6ca432a09c3e50e4bc34a69243b70882 (diff) | |
| download | www-97a594483fb25f52229b71b857747a79c57043fe.tar.gz | |
Arduino Uno post.
| -rw-r--r-- | _archive/arduino-uno.md | 66 | ||||
| -rw-r--r-- | _site/archive/arduino-uno/index.html | 75 | ||||
| -rw-r--r-- | _site/feed.xml | 2 | ||||
| -rw-r--r-- | _site/posts.xml | 2 |
4 files changed, 77 insertions, 68 deletions
diff --git a/_archive/arduino-uno.md b/_archive/arduino-uno.md index 2d402ab..934e5ab 100644 --- a/_archive/arduino-uno.md +++ b/_archive/arduino-uno.md @@ -29,45 +29,53 @@ The steps that follow refer to the following pinout. ## 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. Connect each pin of the crystal to ground via 22pF capacitors. - 4. Connect pins 7, 20, and 21 to 5V. - 5. Connect pins 8 and 22 to ground. +Powering ATmega328P microcontrollers with 5V is the most common setup. This is +also how Arduino Uno boards are wired. -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](Makefile) a sample Makefile for avr-gcc and avrdude. +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](Makefile) 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. 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. - 3. Connect the SPI ports (SCK, MISO, and MOSI) of the two MCUs. - 4. Connect the Arduino Uno's SS pin to the IC's RESET pin (pin 1). - 5. Connect the IC's V<sub>CC</sub> to a 5V supply (e.g., the Arduino Uno's 5V - pin). - 6. 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. +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 V<sub>CC</sub> 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](3v3.Makefile) 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 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 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.</p> <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> +<p>Powering ATmega328P microcontrollers with 5V is the most common setup. This is +also how Arduino Uno boards are wired.</p> + +<p>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.</p> + +<p><a href="Makefile">Here’s</a> a sample Makefile for compiling C programs for ATmega328P +microcontrollers using avr-gcc/avrdude toolchain.</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 > Processor.</li> - <li>Select ‘Arduino as ISP’ from Tools > Programmer.</li> - <li>Select Tools > Burn Bootloader.</li> - </ul> - </li> -</ol> +<p>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.</p> + +<p>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).</p> + +<p>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.</p> + +<p>Power up the the ATmega328P by connecting its V<sub>CC</sub> 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.</p> <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> +<h2 id="remarks">Remarks</h2> + <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 diff --git a/_site/feed.xml b/_site/feed.xml index 67b1d12..381cdec 100644 --- a/_site/feed.xml +++ b/_site/feed.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2025-12-04T13:13:24+08:00</updated><id>/feed.xml</id><title type="html">ASCIIMX | Archive</title><author><name>Wickramage Don Sadeep Madurange</name></author><entry><title type="html">How I manage Suckless software packages</title><link href="/archive/suckless-software/" rel="alternate" type="text/html" title="How I manage Suckless software packages" /><published>2025-11-30T00:00:00+08:00</published><updated>2025-11-30T00:00:00+08:00</updated><id>/archive/suckless-software</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[Since suckless software requires users to modify the source code and recompile to customize, I need a way to maintain patches over the long term while retaining the ability to upgrade the software as new versions are released.]]></summary></entry><entry><title type="html">Neo4J A* search</title><link href="/archive/neo4j-a-star-search/" rel="alternate" type="text/html" title="Neo4J A* search" /><published>2025-09-14T00:00:00+08:00</published><updated>2025-09-14T00:00:00+08:00</updated><id>/archive/neo4j-a-star-search</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[Back in 2018, we used Neo4J graph database to track the movement of marine vessels. We were interested in the shortest path a ship could take through a network of about 13,000 route points. Algorithms based on graph theory, such as A* search, provide an optimal solution to this problem. Therefore, it was useful to model the set of route points as a graph.]]></summary></entry><entry><title type="html">MOSFETs as electronic switches</title><link href="/archive/mosfet-switches/" rel="alternate" type="text/html" title="MOSFETs as electronic switches" /><published>2025-06-22T00:00:00+08:00</published><updated>2025-06-22T00:00:00+08:00</updated><id>/archive/mosfet-switches</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[Recently, I needed a low-power circuit for one of my battery-operated projects. Much of the system’s power savings depended on its ability to electronically switch off components, such as servos, that draw high levels of quiescent currents. My search for a solution led me to MOSFETs, transistors capable of controlling circuits operating at voltages far above their own.]]></summary></entry><entry><title type="html">How to configure ATmega328P microcontrollers to run at 3.3V and 5V</title><link href="/archive/arduino-uno/" rel="alternate" type="text/html" title="How to configure ATmega328P microcontrollers to run at 3.3V and 5V" /><published>2025-04-10T00:00:00+08:00</published><updated>2025-04-10T00:00:00+08:00</updated><id>/archive/arduino-uno</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[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.]]></summary></entry><entry><title type="html">How to set up ATSAM3X8E microcontrollers for bare-metal programming in C</title><link href="/archive/arduino-due/" rel="alternate" type="text/html" title="How to set up ATSAM3X8E microcontrollers for bare-metal programming in C" /><published>2024-10-05T00:00:00+08:00</published><updated>2024-10-05T00:00:00+08:00</updated><id>/archive/arduino-due</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[This article is a step-by-step guide for programming bare-metal ATSAM3X8E chips found on Arduino Due boards. It also includes notes on the chip’s memory layout relevant for writing linker scripts. The steps described in this article were tested on an OpenBSD workstation.]]></summary></entry></feed>
\ No newline at end of file +<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2025-12-04T14:11:20+08:00</updated><id>/feed.xml</id><title type="html">ASCIIMX | Archive</title><author><name>Wickramage Don Sadeep Madurange</name></author><entry><title type="html">How I manage Suckless software packages</title><link href="/archive/suckless-software/" rel="alternate" type="text/html" title="How I manage Suckless software packages" /><published>2025-11-30T00:00:00+08:00</published><updated>2025-11-30T00:00:00+08:00</updated><id>/archive/suckless-software</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[Since suckless software requires users to modify the source code and recompile to customize, I need a way to maintain patches over the long term while retaining the ability to upgrade the software as new versions are released.]]></summary></entry><entry><title type="html">Neo4J A* search</title><link href="/archive/neo4j-a-star-search/" rel="alternate" type="text/html" title="Neo4J A* search" /><published>2025-09-14T00:00:00+08:00</published><updated>2025-09-14T00:00:00+08:00</updated><id>/archive/neo4j-a-star-search</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[Back in 2018, we used Neo4J graph database to track the movement of marine vessels. We were interested in the shortest path a ship could take through a network of about 13,000 route points. Algorithms based on graph theory, such as A* search, provide an optimal solution to this problem. Therefore, it was useful to model the set of route points as a graph.]]></summary></entry><entry><title type="html">MOSFETs as electronic switches</title><link href="/archive/mosfet-switches/" rel="alternate" type="text/html" title="MOSFETs as electronic switches" /><published>2025-06-22T00:00:00+08:00</published><updated>2025-06-22T00:00:00+08:00</updated><id>/archive/mosfet-switches</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[Recently, I needed a low-power circuit for one of my battery-operated projects. Much of the system’s power savings depended on its ability to electronically switch off components, such as servos, that draw high levels of quiescent currents. My search for a solution led me to MOSFETs, transistors capable of controlling circuits operating at voltages far above their own.]]></summary></entry><entry><title type="html">How to configure ATmega328P microcontrollers to run at 3.3V and 5V</title><link href="/archive/arduino-uno/" rel="alternate" type="text/html" title="How to configure ATmega328P microcontrollers to run at 3.3V and 5V" /><published>2025-04-10T00:00:00+08:00</published><updated>2025-04-10T00:00:00+08:00</updated><id>/archive/arduino-uno</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[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.]]></summary></entry><entry><title type="html">How to set up ATSAM3X8E microcontrollers for bare-metal programming in C</title><link href="/archive/arduino-due/" rel="alternate" type="text/html" title="How to set up ATSAM3X8E microcontrollers for bare-metal programming in C" /><published>2024-10-05T00:00:00+08:00</published><updated>2024-10-05T00:00:00+08:00</updated><id>/archive/arduino-due</id><author><name>Wickramage Don Sadeep Madurange</name></author><summary type="html"><![CDATA[This article is a step-by-step guide for programming bare-metal ATSAM3X8E chips found on Arduino Due boards. It also includes notes on the chip’s memory layout relevant for writing linker scripts. The steps described in this article were tested on an OpenBSD workstation.]]></summary></entry></feed>
\ No newline at end of file diff --git a/_site/posts.xml b/_site/posts.xml index 1e5b30a..3acdfb5 100644 --- a/_site/posts.xml +++ b/_site/posts.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="/posts.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2025-12-04T13:13:24+08:00</updated><id>/posts.xml</id><title type="html">ASCIIMX</title><author><name>Wickramage Don Sadeep Madurange</name></author></feed>
\ No newline at end of file +<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="/posts.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2025-12-04T14:11:20+08:00</updated><id>/posts.xml</id><title type="html">ASCIIMX</title><author><name>Wickramage Don Sadeep Madurange</name></author></feed>
\ No newline at end of file |
