arduino 1.0.5 vs 1.8.6 clock speed help

Well I'm finally getting around to updating to the latest arduino setup and I'm running into an issue I know I've seen before in 1.0.5 but I can't recall how I solved it.

First of all, I'm using Arduino to load a standalone atmega328p on a board with a 10MHz crystal

I've modified the board.txt and avrdude.conf files in the respective directories for each environment to change the clock speed for the UNO board from 16MHz to 10MHz and use an atmega328p as the device. I'm programming using an AVRispv2

In both 1.0.5 and 1.8.6 the programs load into the same microcontroller board but I'm getting very different results. In the original the speed of operation is a factor of 4-10 times faster than that of the 1.8.5 version.

I know I'm close but I can't seem to get over the last hump.

here are snippets of the avr-g++ command for 1.0.5:
avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=10000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I/Applications/Arduino (original).app/Contents/Resources/Java/hardware/arduino/cores/arduino -I/Applications/Arduino (original).app/Contents/Resources/Java/hardware/arduino/variants/standard

and for 1.8.5:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=10000000 -DARDUINO=10806 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard

P.S. is there a better way to use the Arduino software to program a standalone microcontroller board? For example, should I make a separate "board" entry in Tools->boards?

Thank you for your help

You should do this: -DF_CPU=10000000L. Otherwise the number will be treated as an int, which can't hold 10000000.

sonicnuance:
should I make a separate "board" entry in Tools->boards?

That's what I'd do. I'd create my own custom hardware package. That's better than adding a board to Arduino AVR Boards because you don't want to lose your custom board definition everytime Arduino AVR Boards is updated. You can reference pretty much everything from Arduino AVR Boards so there's not much to it:

pert:
You should do this: -DF_CPU=10000000L. Otherwise the number will be treated as an int, which can't hold 10000000.

Thanks Pert for the reply. I was hopeful this was the issue as the symptoms are exactly as would be expected for the clock rate being set too low, but alas, I got the same results :frowning: Here is a snippet of the avr-g++ command run in Arduino for 1.8.6:

Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=10000000L -DARDUINO=10806 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard

I'll try making a custom hardware package and see if that might show me what I'm doing wrong

ugh, I'm stuck. I've tried multiple pieces of atmega328p units and even some board builds available from Preferences->Additional Board Manager URLs->https://raw.githubusercontent.com/carlosefr/atmega/master/package_carlosefr_atmega_index.json (which is nicely written to allow for selecting the mcu and clock speed)

No matter what I've done, the programmed hardware is running about 10x slower using Arduino 1.8.5 vs Arduino 1.0.5

Not sure what else to check. I've been looking at the environments to see what is different with no luck :frowning:

oh, and not sure how much this matters, but I've used an ATMEGA328p-PU as well as an ATMEGA328P with the same results.

Well, if it’s 8x too slow, it’s probably the clkdiv8 fuse that needs to be un-set
This is usually done by “burn bootloader”

westfw:
Well, if it’s 8x too slow, it’s probably the clkdiv8 fuse that needs to be un-set
This is usually done by “burn bootloader”

That was promising (and honestly I do think the clkdiv8 fuse IS the problem), however burning the bootloader did not fix the issue in 1.8.6

Not sure it matters, but I'm using an ATMEGA328P-PU.