Before we get to the hardware though, we need add a new entry to the
boards.txt
file defining the new setup (see the previous post for details on this and how to upload code etc.).atmega328p16mhz.name=ATmega328P (16 MHz external crystal) atmega328p16mhz.upload.protocol=stk500v1 atmega328p16mhz.upload.maximum_size=30720 atmega328p16mhz.upload.speed=9600 atmega328p16mhz.bootloader.low_fuses=0xD7 atmega328p16mhz.bootloader.high_fuses=0xDF atmega328p16mhz.bootloader.extended_fuses=0x07 atmega328p16mhz.bootloader.unlock_bits=0x3F atmega328p16mhz.bootloader.lock_bits=0x0F atmega328p16mhz.build.mcu=atmega328p atmega328p16mhz.build.f_cpu=16000000L atmega328p16mhz.build.core=arduino:arduino atmega328p16mhz.build.variant=standardMost of this is identical to the definition for the 8MHz version. The two main changes are to the low fuse (to specify that we are using an external full-swing crystal) and to the processing speed (changed from 8000000 to 16000000).
To make this work we need to add three small components to the previous circuits: a 16MHz crystal and two 22pF capacitors. Fortunately these are very cheap components and add just 36p to the cost of the circuit (making a total cost of £5.54 or £3.87 if you ordered parts for ten circuits). You can see how these are wired up in these diagrams (for programming on the left and in use on the right).
Configuring the fuses and uploading sketches to this new circuit is exactly the same procedure as for the 8MHz version, other than ensuring you select the 16MHz version from the boards menu.
There is, however, one important thing to note. Once you have configured the chip to run at 16MHz, you can't then use it without a 16MHz crystal present. You can't even re-programme the fuses to set it back to run at 8MHz. So if you want to go back to using the internal RC oscillator re-programme the fuses with the crystal present and then simplify the circuit.
Many thanks Mark....I'll have to create a folder for you.
ReplyDeleteI can get a lightning trigger for a couple of hundred pounds but I'd like to make one that doesn't work prior to purchasing one that does.
Have a great Christmas. Hope the pudding is now perfect. I used to do batches of them. I spread them around the family as presents. The local butcher vac packed them in the bowl for me.