atmega328p fuses wrong?

I am working on a 328p board that I designed using reference sketches from a pro mini. I can get the boot loader burner using nick gammons software and I can upload to it just fine. The issue is that when I take it off the programmer and hook in the 12V battery I am using with a 5v regulator the clock speed goes from normal (blink blinks at 1sec intervals) to really really fast. I have an external 8mhz clock on it and I think that I am setting the fuses correctly in avrdude but really I have no idea. This is new territory for me.

This is what I get from the fuse calculator, -U lfuse:w:0x5f:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m

This is my input to AVRDUDE:
avrdude -carduino -pATMEGA328P -PCOM16 -b57600 -U lfuse:w:0x6f:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m

The super annoying thing is that I can get this exact circuit working just fine on a pro mini with a bunch of breakout boards. This was supposed to join it all together in a better package but I am just hitting wall after wall.

I have found a bunch of info on setting the clock incorrectly but I can't find anything on why it would be different from the programmer powering it to the battery. Any suggestions?

I notice you have CKDIV8 set. That divides the clock by 8.

My recommendation is to forget about that Nick Gammon thing. Do this instead:

That will ensure all the fuses are set correctly. Just remember to always use the same MiniCore board from then on.

I'll give that a shot. I tried using the arduino as ISP to burn the bootloader but I couldn't get it to work with my nano clone. I haven't tried MiniCore yet though.

Okay, I gave it a shot and It had some issues.

First the setup:
Nano clone with the ch340 chip. I uploaded the example 11 sketch with nano selected and I used the atmega328p (old bootloader) processor as that is what it needs.

I have 5V to 5V, GND to GND.
Mosi and Miso to Mosi and Miso.
I have SS (d10) to Reset on the new board.

After uploading to the nano I set the programmer to 328p and the external 8mhz clock. I set it to Arduino as ISP.

When I click burn bootloader this is what I get:

Arduino: 1.8.7 (Windows 10), Board: "ATmega328, Yes, 328P / 328PA, 2.7v, Disabled (default), 8 MHz external"

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Users\Eric\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1/avrdude.conf -v -patmega328p -carduino -PCOM13 -b19200 -e -Ulock:w:0x3f:m -Uefuse:w:0xfd:m -Uhfuse:w:0xd6:m -Ulfuse:w:0b11110111:m 

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean,
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Eric\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1/avrdude.conf"

         Using Port                    : COM13
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x15
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x15
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
         Hardware Version: 4744608
         Firmware Version: 0.4611299
         Topcard         : STK502
         Vtarget         : 1.8 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

Error while burning bootloader.
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10

avrdude done.  Thank you.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Try connecting a 10 uF capacitor between the reset and ground pins on the board used as an "Arduino as ISP" programmer.

That seemed to have worked with the capacitor between the RST of the nano and the GND. It said complete and now it flashes twice every second or so when powered on. However, Now I cannot upload any code to it using the ftdi programmer. It says that its not in sync. Before when the clock was off it would still program just fine.

I have it set on pro mini at 3.3V/8mhz (even though its at 5mhz). It also didnt work on 16mhz but I didnt expect it to. I tried AVRISP mkII because that has always worked well for me.

When you upload, you need to leave Tools > Board and any other custom Tools menus set to whatever you had selected when you burned the bootloader.

An update! I can upload the code using my programmer but not the nano as an ISP. I’ve noticed that the blink example runs perfectly when powered from the programmer and when powered from the power supply. However, when I run my actual code it goes crazy and switches on and off really fast. I’m wondering if its shorting out somewhere on the actual code and that is causing it to reset.

The actual code runs at the correct speed on the programmer but most of the things like relays don’t work because USB doesn’t provide enough power.

Here is a copy of my schematic:

I can upload the code using my programmer

Which programmer is that?

but not the nano as an ISP.

How did you try to upload with the nano as an ISP? What happened?

However, when I run my actual code it goes crazy and switches on and off really fast.

Please post your full sketch. If possible, you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it’s OK to add it as an attachment. After clicking the “Reply” button, you will see an “Attachments and other settings” link.

Please always do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

When your code requires a library that’s not included with the Arduino IDE please post a link (using the chain links icon on the toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.