1

After creating a working prototype with DIP ATMega328 chip/ Arduino UNO I recently got PCBs assembled with SMD components and ATMega328P TQFP soldered onto them, but now I'm having a hard time trying to upload the Arduino program.

This is the schematic of the PCB with ATMega328P TQFP with ISP headers for programming: enter image description here

I'm using USBasp programmer with upgraded firmware to upload the code. The chip gets detected and also I can upload sketches to it but the problem is the code runs slow, which I found out is due to the default 8MHz internal clock.(the blink program makes LED blink every 16 seconds instead of 1 second,i.e. with delay(1000))

Now to switch to the external 16MHz clock which I want to use I found out here that I have to change the fuse values from the default

lfuse: 0x62 hfuse: 0xD9 efuse: 0x3F

to

lfuse: 0xFF hfuse: 0xDE efuse: 0x05

I tried it two times and both the times it screwed up the ATMega328P chip

C:\Users\p>avrdude -p m328p -c usbasp -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efu
se:w:0x05:m

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xDE"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDE:
avrdude: load data hfuse data from input file 0xDE:
avrdude: input file 0xDE contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0x05"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


C:\Users\p>avrdude -p m328p -c usbasp

avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

Both of the PCBs are not responding to the USBasp programmer and now I have only got one PCB left. I desperately want to get the final one working.

This is my first time using the SMD ATMega328P chips and any help would be appreciated.

1
  • You should connect AVcc to a supply voltage. According to the datasheet AVcc has a minimum requirement of Vcc - 0.5 V. Also put a 0.1 µF decoupling capacitor between AVcc and Gnd.
    – Nick Gammon
    Aug 30, 2015 at 0:57

1 Answer 1

3

It looks like the capacitors on your crystal are considerably bigger than they should be.

You are switching the clock to the external crystal, and because you have such massive capacitors on it it's failing to oscillate. Without that oscillation the chip can't run, and so it can't respond to the programming.

The crystal capacitors should be roughly 2x the "load capacitance" of the crystal you are using.

CX1 = CX2 = 2(CL - CSTRAY)

10
  • Is there a value for capacitance you can suggest?
    – vee
    Aug 29, 2015 at 19:18
  • Use the formula I stated and insert the load capacitance of your crystal. You can most likely ignore the stray capacitance as it should be tiny. Without knowing what crystal you have I can't suggest a value. It will be in the low 10s of picofarads though.
    – Majenko
    Aug 29, 2015 at 19:26
  • Got it, thanks,will let you know if it works
    – vee
    Aug 29, 2015 at 19:33
  • The arduino board uses 22pF.
    – Gerben
    Aug 29, 2015 at 19:57
  • @Gerben Which one? Most I have seen use ceramic oscillators. Or are you on about the USB interface chip (32U4 or whatever it is on your version)?
    – Majenko
    Aug 29, 2015 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.