328P with external 8MHz clock

I'm busy with a custom arduino board, using a 328P at 3V3, to run at 8MHz (I will select 8MHz pro mini 3v3 from the boards list when programming).

I have these on hand: http://docs-europe.electrocomponents.com/webdocs/12e7/0900766b812e7647.pdf in the 8MHz flavour.

This is not like a crystal with two load caps - it has one clock output. I imagine I connect the output to XTAL1 (as shown on pg 35 of the datasheet http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf ).

However, in the same page of the 328 datasheet, it states CKSEL Fuses must be programmed to “0000” in order to use an external clock.

How do I change those fuses? Do I actually need to?

Thanks

They can be changed by:
Creating a new entry in boards.txt with the altered fusebits (it's part of the low fuse, see datasheet to see where in the low fuse the CKSEL bits are. I think it's the low 4 bits of the low fuse), and select it, connect your ISP programmer to the chip, and do "burn bootloader".
Using avrdude from the command line, along with an ISP programmer, to manually change the low fuse
Using USBAsp + ExtremeBurnerAVR gui tool to set the low fuse byte.

In any event, an ISP programmer is required to set fusebytes.

Thanks!

I plan to use the Arduino ISP (Accessories — Arduino Official Store) to upload the sketch in any case, since I'd like to save board space by only having ISP, and not pins for an FTDI adaptor.

So in that case, I'd create a new entry in boards.txt, select that board in the IDE, and hit File>Upload Using Programmer... right?

nicshackle:
Thanks!

I plan to use the Arduino ISP (Accessories — Arduino Official Store) to upload the sketch in any case, since I'd like to save board space by only having ISP, and not pins for an FTDI adaptor.

So in that case, I'd create a new entry in boards.txt, select that board in the IDE, and hit File>Upload Using Programmer... right?

You have to do "burn bootloader" once to tell it to use the external clock source (even though you're not actually using a bootloader). You should change the other settings to not try to use a bootloader if using ISP for uploads.

I see, thank you.

I've taken the fuse bits from the 3v3 328P pro mini, but have just changed the clock fuse bit (I used this tool AVR® Fuse Calculator – The Engbedded Blog).

This results in:
Low: 0xE0
High: 0xDA
E: 0xFD

Do these seem correct?

(I won't disable the bootloader for now, although thank you for the suggestion).

Update:

I've created a new entry in boards.txt, based on the 3V3 328 pro mini:

##############################################################

omo.name=Arduino Omo

omo.upload.tool=avrdude
pro.upload.protocol=arduino

omo.bootloader.tool=avrdude
omo.bootloader.unlock_bits=0x3F
omo.bootloader.lock_bits=0x0F

omo.build.board=AVR_PRO
omo.build.core=arduino
omo.build.variant=eightanaloginputs

## Arduino Omo (3.3V, 8 MHz, ATmega328)
## --------------------------------------------------
omo.menu.cpu.8MHzatmega328=ATmega328 (3.3V, 8 MHz)

omo.menu.cpu.8MHzatmega328.upload.maximum_size=30720
omo.menu.cpu.8MHzatmega328.upload.maximum_data_size=2048
omo.menu.cpu.8MHzatmega328.upload.speed=57600

omo.menu.cpu.8MHzatmega328.bootloader.low_fuses=0xE0
omo.menu.cpu.8MHzatmega328.bootloader.high_fuses=0xDA
omo.menu.cpu.8MHzatmega328.bootloader.extended_fuses=0xFD
omo.menu.cpu.8MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex

omo.menu.cpu.8MHzatmega328.build.mcu=atmega328p
omo.menu.cpu.8MHzatmega328.build.f_cpu=8000000L


##############################################################

However, when I try to burn the bootloader with that board selected, I get the following error:

 ***failed;  
avrdude: verification error, first mismatch at byte 0x0000
         0x05 != 0xfd
avrdude: verification error; content mismatch
Error while burning bootloader.

Have I not changed something I should've, or have I changed too much? :confused:

You’re tryting to set efuse to 0xFD. But that’s not valid, because 5 of those bits that you’retrying to set to 1 are not actually writable fusebits, and always read as zero per avrdude.conf.

omo.name=Arduino Omo

omo.upload.tool=avrdude
omo.upload.protocol=arduino

omo.bootloader.tool=avrdude
omo.bootloader.unlock_bits=0x3F
omo.bootloader.lock_bits=0x0F

omo.build.board=AVR_PRO
omo.build.core=arduino
omo.build.variant=eightanaloginputs

## Arduino Omo (3.3V, 8 MHz, ATmega328)
## --------------------------------------------------
omo.menu.cpu.8MHzatmega328=ATmega328 (3.3V, 8 MHz)

omo.menu.cpu.8MHzatmega328.upload.maximum_size=32256
omo.menu.cpu.8MHzatmega328.upload.maximum_data_size=2048
omo.menu.cpu.8MHzatmega328.upload.speed=57600

omo.menu.cpu.8MHzatmega328.bootloader.low_fuses=0xE0
omo.menu.cpu.8MHzatmega328.bootloader.high_fuses=0xDE
omo.menu.cpu.8MHzatmega328.bootloader.extended_fuses=0x05
omo.menu.cpu.8MHzatmega328.bootloader.file=optiboot/optiboot_atmega328.hex

omo.menu.cpu.8MHzatmega328.build.mcu=atmega328p
omo.menu.cpu.8MHzatmega328.build.f_cpu=8000000L

Better entry - fixed pro name still sitting there, and switched to optiboot, which takes up 512 bytes of flash instead of 2048.

That did the trick. Thank you so much!