Clock advice

Hello all, so i'm trying to build myself an original Atmega328(not the pico power) that will run at 3.3v. I have it working fine so far at 16 Mhz but from what I've read that's a bad thing to do. So i would like to drop it down to 10 Mhz, i know the norm is 8 but due to availability id like to stick with the 10. I know i need a new entry in Boards.txt i just copied the uno entry and changed the clock frequency, is there anything else i need to change ? From what i understand as long as i'm willing to use an FTDI or an Arduino as ISP that should be all i need to change ? I would like it if the boot loader was setup for 10 Mhz tho. So i'm wondering if there are any good guides for getting started playing with a boot loader oc

Yes, 10MHz will be within-spec for 3V3 and guaranteed to operate within spec, while 16MHz is not.

To get it to work in the Arduino IDE you will indeed need a new boards.txt entry as you said. Change the build frequency to 10000000L, (instead of 16000000L).

If you intend to use an FTDI or similar adapter to program, unless you compile a new bootloader you need to change the upload baud rate as well. If you use an Arduino as ISP, you won’t need the bootloader at all, since uploading over ISP removes the bootloader.

I would just use the Uno bootloader and change the boards.txt upload baud to be 10/16 of the normal one (which is 115200), so 72000.

Since you said you are using a 328, and not a 328p, you also need to change the build.mcu to 328 (instead of 328p), or else you will get a signature mismatch error.

I should add that I cannot say what impact running at 10MHz will have on some Arduino libraries. I would hope all will work correctly (timing-wise), but I have no first-hand experience on that front (I stick to 8/16MHz).

Sounds like you have a much simpler fix for the 328 instead of the p, the one i found involves swapping between an avrdude config file every time i need to burn the 328. The boards sole purpose will be an nrf24 so maybe i will just remove the bootloader and use ftdi.

I think you have that backwards!

The whole purpose of changing the build frequency of the bootloader, is that it will correctly operate at the standard baudrates. That much has nothing to do with boards.txt (myboot.upload.speed=115200 can stay), but you need to change in boards.txt, the clock rate (myboot..build.f_cpu=10000000L) in order for the libraries to compile correctly.

Paul__B:
myboot.upload.speed=115200 can stay

Only if you re-compile the bootloader to expect a 10MHz clock. The Uno bootloader expects a 16MHz clock and will receive upload at 115200, and can be used with an 8MHz clock if you set the upload speed to 8/16, or 57600. My post assumed the OP didn’t want to try to re-compile the bootloader, which of course could be done, and then changing the upload frequency, as you say, would stay at 115200 (though is that an attainable baud with 10MHz clock? - it isn’t really at 8MHz, though it has been known to work).

To the OP: If you use an FTDI, you must use a bootloader. If you use an ISP programmer, the bootloader doesn’t matter.

Those posts about swapping avrdude conf files are work-arounds for prior versions of the avrdude included with the IDE. The newer IDE might have the correct config file (EDIT: it appears that the avrdude.conf file with IDE 1.6.5r5 does have entries for both the m328 and the m328p). Or, just use a 328p and avoid that alltogether.

i don't think there has ever been a credible case of failure of 16mhz at 3.3v. certainly not in my own tests even over extreme temperatures. some commercial arduino boards are actually designed for 16mhz@3.3v.

i do agree with madmattd that its best to stick with 8mhz or 16mhz. not optimum for comms and the latter can misbehave at 115kbps but still less complications and calculating. funny how some hobbyist beginners tend to make life hard on themselves.

i also agree isp is a good way to flash and rarely see any benefit to serial bootloaders.

The config files aren't really all that big of a deal the only difference is the device id. I tried last night using 1.6.5 not sure of the revision i can't seem to find it, i'll just go download the latest .I guess my main concern would be getting the serial and timing to work a little better, if i have to make an ISP programmer i can live with that. I have plenty of 5v pro mini's lying around. I'd prefer not to play around with boot loaders as I've never done it but i don't mind learning something new, BUT my C/C++ knowledge is basically revolved around arduino. I generally program in .NET. I'm not necessarily making things hard on myself just trying to work with what i have lol.

micros(), and hence delay, will be off by 4 64ths with the stock core . They have to divide 64 by clock speed, in mhz, and if it gets integer math 'ed, those are off.

cgroshko: The config files aren't really all that big of a deal the only difference is the device id. I tried last night using 1.6.5 not sure of the revision i can't seem to find it, i'll just go download the latest .I guess my main concern would be getting the serial and timing to work a little better, if i have to make an ISP programmer i can live with that. I have plenty of 5v pro mini's lying around. I'd prefer not to play around with boot loaders as I've never done it but i don't mind learning something new, BUT my C/C++ knowledge is basically revolved around arduino. I generally program in .NET. I'm not necessarily making things hard on myself just trying to work with what i have lol.

Any version of 1.6.5 should be fine, I don't believe they changed the tool chain since 1.6.0.

You say you don't want to mess with bootloaders, so:

Make the 2 boards.txt mods I mentioned. Burn the Uno Bootloader. And move on.

Though I still don't understand the need for 10MHz over 8MHz. DrAzzy points out a good reason to stick with 8/16.

Availability. It's all i could find the last time i was in the city (6 hour drive). As for ordering online the next time the wife let's me build an order i was going to order some 8's. I'm just impatient i guess and wanted to get it working with what i had for now.

cgroshko: Availability. It's all i could find the last time i was in the city (6 hour drive). As for ordering online the next time the wife let's me build an order i was going to order some 8's. I'm just impatient i guess and wanted to get it working with what i had for now.

Fair enough. You have DrAzzy's info on what to expect. It will work, your timing might just be off a touch in the meantime.

Don't forget the crystal loading caps (~22pF) and the 0.1uF ones on all Vcc/AVcc pins.

I'm alright with the timing being just off. There was almost a half a second difference before. I've got the loading caps but haven't come across anyone saying anything about the 0.1uF caps ? I have a 22uF going across the power and ground rails after the mcu.

Pretty much every tutorial for setting up a 328p is flawed, as most ignore the 0.1uF caps. They're there for voltage filtering on the chip, and should be as close as possible to the chip. To use the FTDI, adding another in-line between the reset pin of the 328p and the DTR pin of the FTDI programmer (with a ~10k pullup resister on reset) will allow the auto-reset to work without having to manually hit a button (in fact, you don't even need the reset button if you are OK with power-cycling to reboot the chip).

The Pro Mini schematics are pretty good for minimal implementations. In the one below, C3 is the filtering cap, though there really ought to be 2 or 3 (one for each power pin, pins 4 and 6 are close enough I usually let them share the same cap).

https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Arduino-Pro-Mini-v14.pdf

madmattd: Don't forget the crystal loading caps (~22pF) and the 0.1uF ones on all Vcc/AVcc pins.

and 1 or 2 usbasp while youre at it. arduino-as-isp is great but usbasp has advantages like the convenient 5v/3.3v switch on the newest versions not to mention the compact form factor and ready to go cabling.

I was just thinking about it. Instead of the 10 Mhz would i be better off using the internal clock until i can order 8's ? I've read some bad things about the internal clock.

Internal is fine, may need to adjust the calibration byte to tweak the frequency a little.

28.4 Calibration Byte
The ATmega48A/PA/88A/PA/168A/PA/328/P has a byte calibration value for the Internal RC Oscillator. This
byte resides in the high byte of address 0x000 in the signature address space. During reset, this byte is
automatically written into the OSCCAL Register to ensure correct frequency of the calibrated RC Oscillator.

I was reading a site saying to use the lily pad boot loader. Will that have the calibration byte already adjusted ?

madmattd: Only if you re-compile the bootloader to expect a 10MHz clock. ... My post assumed the OP didn't want to try to re-compile the bootloader,

Ah yes, that certainly is one approach, same in effect as fitting an 8 MHz crystal and calling it a Pro Mini 8 MHz.


cgroshko: I was reading a site saying to use the lily pad boot loader. Will that have the calibration byte already adjusted ?

No because you need to adjust it to the individual chip - that is why it is a calibration byte. :grinning:

Promicro does not use '168. Promini perhaps. But promini expects external crystal. So one the Lilypad variants I think would be best.

john1993: i don't think there has ever been a credible case of failure of 16mhz at 3.3v. certainly not in my own tests even over extreme temperatures. some commercial arduino boards are actually designed for 16mhz@3.3v.

For what it's worth, my 328P bare boards, running as 22.1184 MHz, are rock stable at 3.3v.