Could not burn bootloader to Atmega328P

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Hi,

I am new here in the forum, and after two days of trial and error, I am completely desperate and need your help:

I have built my first PCB and use an Atmega328P. Due to my inexperience, I forgot to design the isp header to burn the bootloader to the Atmega.

Due to this fact, I soldered some wires to MISO,MOSI, SCK and Reset, and connected it to an Arduino Nano, which should work as an ISP.I used this tutorial to prepare the Nano:

https://wolles-elektronikkiste.de/atmega328p-standalone-betreiben

Its in German, but pictures and tables should be clear.

 Appropriate sketch was loaded to the Nano, and this ISP is able to burn the bootloader to another Nano. So, sketch and cabling should be ok.

But I am struggling with getting the bootloader to the stand alone Atmega on my new board. Here are the schematics and PCB layout:

 

 

At first I tried the minimal configuration as described in the tutorial, by using the board ATMega328P on a breadboard (8MHZ clock), but I got always an error during burning process. Then I tried some other configurations with regular Nano board and some other boards, and somehow, burning was working, but just for one time, and I was not able to repeat the process at the next day. In order to exclude the option of a damaged processor, I used a new PCB (I got 5 from JLCPCB) and tried again with the same result.

The Nano is still able to burn to the other Nano. So it seems there is no hardware or software problem. Even when I played around with several obviously wrong boards and parameters, I was not able to kill the Nano.

According to my assumption there is some electrical parameter close to the edge. So it works under good conditions, but more ore less accidentally.

What kind of problem should that be? I tried to bring CS to 5V, in order to avoid some disturbing actions from the MCP2515, but this does not help.

 

 Any ideas? I need your help!!

Thanks in advance.

 

This topic has a solution.
Last Edited: Sun. Oct 25, 2020 - 04:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

stefan2020 wrote:
I soldered some wires to MISO,MOSI, SCK and Reset

 

You'll need to connect ground as well, and clearly 5V as well if you're powering the board from the programmer.

 

The crystal circuit looks strange. What is the purpose of C11, the 100nF cap between XTAL2 and +5V ? You probably don't need R2 either.

 

When you do get it working, the two libraries I would recommend are MCP_CAN (for beginners to CAN) or ACAN2515 (more control). The latter is very well written and the documentation is a master class.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, that is clear:

I powered the Atmega via a power supply on the new PCB, and connected ground between PCB and Nano (ISP).That should be the same than powering from the ISP, or do you see some problems there?

 

The design of the crystal circuit I copied somewhere. Do you think this can lead to problems?

 

Last Edited: Mon. Oct 19, 2020 - 11:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You just need a common ground connection.

 

I still don't understand that external crystal circuit. Which Arduino core are you using ? Does it allow use of the internal oscillator, and so remove the external circuit from the equation ?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried to use a core which uses the internal 8MHZ clock, but I was not able to burn it. Therefore I burned the core for the nano/uno board wihich uses the external 16MHZ crystal, which exists in my layout. But if this circuit is not working properly, it is maybe the root cause  for my problems, what do you think?

But why I cannot burn the core which uses the internal clock? Does the mcu check, whether an external crystal is connected or not?

  

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you remove C11 and maybe R2 ?

 

Also, for an Arduino board, I would expect to see a 100nF cap from /RESET to ground.

 

Which hardware design did you use for inspiration ? All Arduino, Adafruit and Sparkfun board designs are open-source hardware, and are know to work.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd suggest a pullup resistor on CS to ensure the CAN chip doesn't barf on the SPI lines

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks like you don't have any bypass caps for any of your IC's. I bet that will solve your problem.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Sorry, I did not copy the power supply part from my schematic.

 

Did you speak about these caps, or do I need additional ones?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This I have already done, but with no effect, unfortunately.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I will remove R2 and C11 tonight and will post the result.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should have a 0.100uF cap at every IC power and ground pins, as close to the chip as possible, this will filter out noise in the power lines, so each IC will have a nice smooth 5V

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great, I removed C11 and R2, and it works like a charme. I can now upload the bootloader via ISP, and also load sketches via serial interface.

 

I think C11 was hindering the oscillator to swing. When I think about that, it should be clear, because I shortcut the oscillator circuit against 5V for high frequencies, which we have in an oscillator...

 

Thank you for your help so far. I can now go on with my PCB.