arduino:atmega328p_arduinos_and_custom_fuse_settings
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
arduino:atmega328p_arduinos_and_custom_fuse_settings [2020/01/04 00:46] – [Burn the bootloader and test] mithat | arduino:atmega328p_arduinos_and_custom_fuse_settings [2021/04/22 01:13] – [Where do I put new board specs?] mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== ATmega328P Arduinos and custom fuse settings ====== | ====== ATmega328P Arduinos and custom fuse settings ====== | ||
- | |||
- | <WRAP center round info 60%> | ||
- | Work in progress. | ||
- | </ | ||
Programming your device with the code you want to execute, whether with a bootloader or directly with a programmer, is one layer of programming your device. Another layer is the so-called //fuses// inside an ATmega microcontroller. | Programming your device with the code you want to execute, whether with a bootloader or directly with a programmer, is one layer of programming your device. Another layer is the so-called //fuses// inside an ATmega microcontroller. | ||
Line 15: | Line 11: | ||
===== The hard way or the hard way? ===== | ===== The hard way or the hard way? ===== | ||
- | There are a couple ways we can go about setting the fuses on an ATmega328P Arduino. We can use a programmer along with the command-line '' | + | There are a couple ways we can go about setting the fuses on an ATmega328P Arduino. We can use a programmer along with the command-line '' |
- | Both create different kinds of difficulties. To keep things as " | + | Both create different kinds of difficulties. To keep things as " |
===== Four general questions ===== | ===== Four general questions ===== | ||
- | ==== Where do I put new board specs? ==== | + | ==== 1. Where do I put new board specs? ==== |
Specs for Arduino boards, including fuse bit settings, are found in various '' | Specs for Arduino boards, including fuse bit settings, are found in various '' | ||
Line 54: | Line 50: | ||
The following method works on the version of Arduino I used at the time or writing this: 1.8.8. I don't know whether it can be relied on to hang around for a while or has been deprecated. | The following method works on the version of Arduino I used at the time or writing this: 1.8.8. I don't know whether it can be relied on to hang around for a while or has been deprecated. | ||
- | So, until I'm advised this is a horrible idea, my recommended | + | So, until I'm advised this is a horrible idea, the way I recommended you add your own custom board descriptions is to create a folder called '' |
- | + | ==== 2. How do I specify new board characteristics? | |
- | ==== How do I specify new board characteristics? | + | |
- | There is a //lot// of arcane knowledge that applies to writing custom Arduino '' | + | There is a //lot// of arcane knowledge that applies to writing custom Arduino '' |
- | Another good resource to look through is the breadboard-1-6-x.zip | + | Another good resource to look through is the files found in the breadboard-1-6-x.zip |
- | But there are some surprises. I walk through those in the case study below. | ||
- | ==== What specs do I want? ==== | + | ==== 3. What specs do I want? ==== |
- | This article covers making a variant of an existing board where only the fuses have been changed. The relevant | + | This article covers making a variant of an existing board where only the fuses have been changed. The relevant |
- | Exactly which fuses do what and how is an article in and of itself. I haven' | + | Exactly which fuses do what and how is an article in and of itself. I haven' |
When you're figuring out what your fuse values should be, don't be afraid to reference back to the original settings in whatever '' | When you're figuring out what your fuse values should be, don't be afraid to reference back to the original settings in whatever '' | ||
Line 74: | Line 68: | ||
There is one additional caveat here: You can only change fuses that are compatible with what the bootloader you plan to use will let you do. Again there isn't a lot of documentation here, so if you've done everything right but things still don't work, this might be the reason. The solution to this is to compile a custom bootloader, which is well beyond the scope of this piece. | There is one additional caveat here: You can only change fuses that are compatible with what the bootloader you plan to use will let you do. Again there isn't a lot of documentation here, so if you've done everything right but things still don't work, this might be the reason. The solution to this is to compile a custom bootloader, which is well beyond the scope of this piece. | ||
- | ==== How do I burn a bootloader? ==== | + | ==== 4. How do I burn a bootloader? ==== |
This too is a pretty big topic, but the TL;DR is: hook up a programmer to your board, select the right board and programmer, then do a //Tools > Burn Bootloader// | This too is a pretty big topic, but the TL;DR is: hook up a programmer to your board, select the right board and programmer, then do a //Tools > Burn Bootloader// | ||
Line 129: | Line 123: | ||
===== Case study ===== | ===== Case study ===== | ||
- | In the section, I walk through the process of creating a custom version of a 3.3V/8MHz Pro Mini where the brown-out detection (BOD) threshold is changed from the stock nominal | + | In the section, I walk through the process of creating a custom version of a 3.3V/8MHz Pro Mini where the nominal |
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | Don't use programs uploaded by the bootloader if you reduce the BOD threshold or turn off BOD entirely. See [[arduino: | + | If you reduce the BOD threshold or turn off BOD entirely, don't run programs uploaded by the bootloader at low voltages. See [[arduino: |
</ | </ | ||
Line 149: | Line 143: | ||
| 0 | BODLEVEL0 | | | 0 | BODLEVEL0 | | ||
- | ^ BODLEVEL2, 1, 0 ^ Typ. voltage | + | ^ BODLEVEL2, 1, 0 ^ V< |
| 111 | BOD disabled | | 111 | BOD disabled | ||
- | | 110 | 1.8V | | + | | 110 | 1.8V((The ATmega328P datasheet indicates this state is " |
| 101 | 2.7V | | | 101 | 2.7V | | ||
| 100 | 4.3V | | | 100 | 4.3V | | ||
Line 159: | Line 153: | ||
Now is a good time to mention that the ATmega328P fuses are //active low//, meaning that a 0 sets (" | Now is a good time to mention that the ATmega328P fuses are //active low//, meaning that a 0 sets (" | ||
- | So, to set the brown-out threshold to 1.8V we want the last three bits of the extended fuse byte to be '' | + | So, to set the brown-out threshold to 1.8V I want the last three bits of the extended fuse byte to be '' |
==== Preparing the new board files ==== | ==== Preparing the new board files ==== | ||
- | === file structure === | + | === Folder |
Inside my Arduino sketches folder (''/ | Inside my Arduino sketches folder (''/ | ||
Line 171: | Line 165: | ||
+-- hardware/ | +-- hardware/ | ||
+-- mfkcustom/ | +-- mfkcustom/ | ||
- | | + | |
- | +-- bootloaders/ | + | +-- bootloaders/ |
- | +-- atmega/ | + | +-- atmega/ |
- | +-- variants/ | + | +-- variants/ |
</ | </ | ||
Line 230: | Line 224: | ||
==== Burn the bootloader and test ==== | ==== Burn the bootloader and test ==== | ||
- | Whether you plan to upload your sketches with a USB to serial converter (i.e., using the bootloader) or directly | + | Whether you plan to upload your sketches with a USB to serial converter (i.e., using the bootloader) or directly |
=== Burn it === | === Burn it === | ||
Line 236: | Line 230: | ||
* Create a new project consisting of a simple sketch (e.g. blink.) | * Create a new project consisting of a simple sketch (e.g. blink.) | ||
* Under //Tools > Board// you should see an entry for "Pro Mini 3.3V/8Mhz, 1.8V BOD, ATmega328P" | * Under //Tools > Board// you should see an entry for "Pro Mini 3.3V/8Mhz, 1.8V BOD, ATmega328P" | ||
- | * As a sanity check, Verify/ | + | * As a sanity check, Verify/ |
* Hook up a programmer to a 3.3V/8MHz Pro Mini and select the programmer you're using under //Tools > | * Hook up a programmer to a 3.3V/8MHz Pro Mini and select the programmer you're using under //Tools > | ||
* Plug the programmer into your computer | * Plug the programmer into your computer | ||
Line 254: | Line 248: | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | Don't run programs uploaded by the bootloader at low voltages | + | If you reduce the BOD threshold or turn off BOD entirely, don't run programs uploaded by the bootloader at low voltages. To run a sketch at low voltage |
</ | </ | ||
- | To run a sketch at low voltage you should upload your sketch directly using a programmer. | ||
==== Upload with programmer and test ==== | ==== Upload with programmer and test ==== | ||
- | After burning the bootloader to set the fuses, hook up your programmer. Be sure you have set both the board and programmer to the correct values under //Tools//. Then upload your simple test sketch with //Sketch > Upload Using Programmer// | + | After burning the bootloader to set the fuses, |
Follow the instructions above to read the fuse settings. You should see: | Follow the instructions above to read the fuse settings. You should see: | ||
Line 275: | Line 268: | ||
</ | </ | ||
- | The extended fuse should | + | Confirm that the extended fuse is still '' |
- | You can now connect the Pro Mini to a variable supply to see whether it works as expected below 2.7V. It may not work all the way down to 1.8V though, but because you're not using a bootloader, the chances | + | You can now connect the Pro Mini to a variable supply to see whether it works as expected below 2.7V. It may not work all the way down to 1.8V though, but because you're not using a bootloader, |
arduino/atmega328p_arduinos_and_custom_fuse_settings.txt · Last modified: 2021/04/22 01:37 by mithat