Issue loading bootloader onto ATMEGA328P-MU

I have designed a custom board that I am using a ATMEGA328P-MU to control but I am not able to load a bootloader on to it. I am using an Arduino nano as the ISP but it is not able to connect to the ATMEGA and also using a level shifter to convert the 5V signal of the Arduino to the 3.3V signal of my custom board. I have tried swapping the MISO and MOSI pins to no luck, and I have also tried scoping the signals of the SCLK, MOSI, MISO and RESET and they all look fine. I have also tried loading the boot loader using a USBTinyISP but no luck there as well. I have checked the voltage of the ATMEGA and it is 3.3V, but the Ceramic Resonator does not seem to be outputting 16MHz. I have tried 2 different of my PCB's and the result is the same for both. What suggestions do y'all have for debugging this?

Here's a diagram of my setup:

Here's the schematic of my PCB:

here's the output of the Arduino IDE:
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

     Using Port                    : COM9
     Using Programmer              : stk500v1
     Overriding Baud Rate          : 19200
     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 : STK500
     Description     : Atmel STK500 Version 1.x firmware
     Hardware Version: 2
     Firmware Version: 1.18
     Topcard         : Unknown
     Vtarget         : 0.0 V
     Varef           : 0.0 V
     Oscillator      : Off
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0xffffff (probably .avr8x_mega) (retrying)

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0xffffff (probably .avr8x_mega)
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.

avrdude done. Thank you.

Error while burning bootloader.

Thank you in advance for the help!

Even if you were able to burn the bootloader, it would not matter since the 328P can't run at 16MHz on only 3.3V

Hi Jim-p,
Thank you for the reply!
I have read that in the datasheet and I have ordered some 8 MHz ceramic oscillators to try but have not gotten yet. I have seen from others posts that they were able to get their 328P's to work with 3.3V and 16MHz most of the time. So I wanted to see if I could get mine to work with 3.3V at 16MHz as well in the mean time. is there anything else that I am doing wrong? is there a way to use the internal oscillator rather than the external one?

You are lucky if it works at 16MHz, and that could change with temperature and the current draw.
If it was never programmed before it should be using the internal 8MHz oscillator with the frequency divider of 8, for an operating frequency of 1MHz.
I would try powering it with 5V and remove the level translator and see if you can burn the boot.

I had a similar problem like this, i designed and made a pcb expecting it to work at 3v3 using a 16MHz crystal. it didn't. I had to either redesign and make my pcb again but with 5v in mind, or you run the atmega chip at 3v3 and remove the crystal (and caps) and use the internal 8MHz crystal. I think i followed this instructable.
-Extract the file to the hardware folder, and restart your IDE. should appear as a new board "hardware avr - ATmega 328 on a breadboard 8MHz internal clock". (Note: I may have made a silly mistake but for some reason this doesn't show up for me on versions of the IDE above 2.0.0 . I had to install another older arduino IDE, i used version 1.8.13 and it worked).
-Upload the "Arduino ISP" sketch to your nano like you did before, and wire it like you did without logic converter, use 5v or 3v3, doesn't matter now.
-select tools<board<hardware avr< atmega328 on breadboard 8mhz int clock
-select programmer as "Arduino as ISP"
-burn bootloader
good luck!

Thanks for the help Jim-p,
I tried it with powering the 328P with the Arduino Nanos 5V supply and I was still not able to program the device, and the ceramic oscillator does not seem to be acting correct, this is what I see when I scope the ceramic oscillator on my board and this is what I see when I scope the Arduino Nano oscillator. I have tried swapping the crystal from an Arduino nano board to my PCB and it still looks the same.

my board:

Arduino nano board:

Thank you Batterylicker, I tried this as well and no luck.

What kind of level shifter are you using?
Note that MISO is an INPUT to the programmer (your Arduino Nano), so the level shifting needs to be in the "other" direction (or isn't needed at all, since 3.3V logic levels read OK on a 5V Arduino.)

Hi Westfw,
The level shifter is bi directional so I don't think that is the issue.
Here is the level shifter: https://www.sparkfun.com/products/12009

Is my Ceramic Resonator incorrect for the ATMEGA328P? it is : CSTNE16M0V530000R0

Thank y'all for your help! I found the issue!

solution:
"If you are using the DTR pin to connect to the Reset pin you are connecting to the wrong side of the capacitor. You also have your Reset button on the wrong side of the capacitor. See the Arduino UNO schematic. The 'DTR' line is for serial upload with the bootloader. For ISP programming you have to connect directly to the Reset/PC6 pin."

from this thread: Device signature = 0x000000 when burning bootloader to custom PCB

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.