[SOLVED] Unable to program Mega328P-AU using ISP - Page 1
Forum section: electronics / general

author: gmc
author_rank: Regular Contributor
timestamp: October 02, 2020, 04:53:48 pm
content: Been pulling my hair out for the past few days trying to get a mega328p-au programmed via ISP.I've got a prototype PCB that I've had manufactured and I've soldered on a mega328p-au smd component which I'm now tying to load the bootloader on. (all components are smd)It's a simple circuit, I've double checked the voltages, no shorts, 22pf caps and 16Mhz xtal is connected.Been at this a while so have tried the following:- Known good USBTinyISP with avrdude. I keep getting initialization failed. If I use force option I get random device signatures.- Tried Arduino as ISP and tried to write bootloader with Arduino IDE. Also get the same error.- Beeped out all the connections to ISP.- Triple checked all voltage rails and beeped out all tracks to the mega.I though it might be a faulty Atmel so have tried another PCB with a new Mega328p-au. Same issue.I then built an adapter board and soldered another mega to a DIP32 socket (That was fun!) and inserted in into my TL866II+. Low and behold it reads the chips. Yay....chips aren't faulty.Have also tried reading the chip in circuit using the TL866 with ICSP connected to ISP pins and it too comes it with a error.I'm thinking it must be something with the external crystal then? (Unless there is a design issue on the schematic that I've missed. I've double checked this to other google images and looks ok)I've also tried a external 1Mhz clock driven by a Arduino UNO. Made no difference. (Tried another plain old 2 pin 16Mhz xtal, so difference, also tried a 12Mhz for good measure. Also replaced smd caps with non 22pf smd caps in case the values I was send are wrong)The TL866 reads the fuses as:low 0x62high 0xD9extended 0xFFlock 0xFFDo the fuse settings hold any clue as to what could be the issue? Any pointers would be appreciated.

author: georges80
author_rank: Frequent Contributor
timestamp: October 02, 2020, 05:09:01 pm
content: What is the mega's reset pin connected to? Caps?Get a scope out and probe the ISP pins as you attempt to read out fuses etc. In case of shorts to other pins or issues.Raw mega should not care about the external crystal until the fuses are set to use the external crystal. Until then ISP will work with the internal RC oscillator of the mega. I'd set max frequency to 200kHz for ISP. You could try dropping it down to 50kHz as an experiment.cheers,george.

author: Peabody
author_rank: Super Contributor
timestamp: October 02, 2020, 05:20:17 pm
content: I don't know if it's true, but I've been told that you have to connect ALL of the 328P's ground pins to ground, not just one of them, and all of the Vcc pins to Vcc. You also need a significant cap on Vcc. Maybe someone can confirm if that's true or not.Is Vcc 5V? Both ISP and target running at 5V?Just as a test to make sure you know which part isn't working, you might try using your ISPs to burn its normal bootloader to some 5V Arduino. Just make sure the problem is actually with the target and not the ISP.Edit: Like George, I'm unclear about the Reset pin. You have it as an ISP header pin, but what does it connect to on the ISP? Using the IDE and an Uno or Nano as ISP, it would normally be connected to pin 10.

author: gmc
author_rank: Regular Contributor
timestamp: October 02, 2020, 05:49:32 pm
content: Thank for the reply. You have set me on the right path.Looking at my schematic I have a 100nF cap between reset and the ISP!!!There is a 10k from the uC reset pin to Vcc, and then 100nF cap to reset on the ISP.Also in the circuit is a CH340 which should have a 100nF cap connected between CH340 reset and the mega328 reset (Not from mega328 reset to ISP reset)

author: Peabody
author_rank: Super Contributor
timestamp: October 02, 2020, 08:32:54 pm
content: Yes, I think the cap normally goes to DTR for use in USB flashing. But for ISP, I think there should be a direct connection between the processor's reset pin and the ISP "RESET" header, which in turn connects to a Uno as ISP's pin 10.