I'm working on a project that need the atmega 328p soldered on a costume pcb, so i desolder it from it's pcb "arduino pro mini 5V" and soldered it to my pcb with Crystal oscillator and everything need to run.
i tried to program it via SPI and it worked several times than it stopped work, and the ic get locked and it needs a high voltage programmer to program it again.
i have another arduino "mega" that works well and i need to build from it a high voltage programmer to reset all the atmega 328p fuses, but I don't know how to connect it to the arduino mega and witch sketch need to make it?
Generally what people do for that is build a "fuse doctor" on a dedicated board - there's code around the internet for that (iirc, the one I saw used an attiny4313 for it), though IIRC it wasn't an arduino sketch.
Note that if you're programming via ISP (aka SPI), you don't need to unsolder anything from an existing board - just take a virgin '328p from digikey et. al and 'burn bootloader' via ISP (note, recommend using MiniCore with "no bootloader" option for this, to get the extra 512b of flash - it also lets you use the superior and less expensive 328pb and access all it's added functionality).
It also is not possible to brick the board programming via ISP unless you're writing to the fuses. If you weren't doing that on the fateful programming run that broke the board, that's a bad sign regarding the hardware...
atmega 328p
Note that the ATmega328p doesn't have "High Voltage Serial Programming." It only has High Voltage Parallel Programming, which requires somewhere around 18 signals to be connected between the chip and the programmer. (only one is actually "high voltage", but it'd still be a major effort.)
On the bright side, the chance that you managed to brick your chip in a way that needs HVPP to fix it is very small. Probably you just need to feed a clock into XIN. See This tutorial
Nick Gammon also has a page on it here
http://www.gammon.com.au/forum/?id=12898
Note the High Voltage is only 12V, and it only needs to be switched on one pin.
Next time, put an ICSP header on your board so you can program it with a Programmer, or an FTDI type port so you can plug on an FTDI Basic and download just like you were downloading into a ProMini. Or both. Or at least make the pins accessible.
It sounds like he already was using ICSP to program it though, and claims that he managed to brick it.
And if he was messing with fuses, there are two bits he could have changed that would brick it such that HV programming was necessary, the one to disable reset, and the one to disable SPI programming. Messing up the clock source would require supplying a clock to the appropriate pin, and then all would be well and you could fix the fuses (there's a version of ArduinoISP floating around that does output a 8mhz signal on one pin for this exact purpose)
Here's a version of the ArduinoISP sketch that outputs a 4 MHz clock signal on pin 3:
https://raw.githubusercontent.com/arduino/Arduino/1c9055864b51d0017464bb222b8a231f2e12405d/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino
the one to disable SPI programming.
You can't actually disable SPI programming FROM SPI programming...
Note 2 in the datasheet for table 27-8:
- The SPIEN Fuse is not accessible in serial programming mode.
so from replays i understood that some how i disabled the rest pin, so for future projects"how can i program my atmega328p on a costume pcb "ISP or via FTDI board" to not missing up with fuses?
I suppose the problem could also be related to what else is connected to the SPI lines which might interfere with an attempt to re-program it (reload the bootloader) through the ICSP header.
Here is an Application Note (see page 8 ) :
on my pcb, i left the D13,D12,D11"SCK, MISO, MOSI"vnot connected anywhere else ISP to not interfere with it, but in my original arduino board it was a tiny SMD Crystal oscillator 16Mhz, and in my custom pcb i change the oscillator to THT one one but also 16Mhz with to 22pf capacitors, so could it be that changing the Crystal oscillators make my problem?
also that my programmer is a "FTDI" with another arduino pro mini that i program it from arduino sketch "arduino ISP example" than i cut the reset pin form Arduino pro mini to prevent it from resetting it self when uploading new sketch to my atmeg328p on my custom pcb(it is right to make a programmer like that?)
i can share with schematic for my programmer if it's necessary.
If you look at boards.txt, it has the fuse settings for various board types.
Here are the fuse settings for a 16 MHz Uno for example:
uno.bootloader.low_fuses=0xFF
uno.bootloader.high_fuses=0xDE
uno.bootloader.extended_fuses=0xFD
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
I use these fuses for all my '328P projects, using 28 pin DIP parts, or 32 pin surface mount parts.
I also use 16 MHz crystal and two 22pF caps.
I also have a 10K pullup resistor on the Reset line.
What fuse settings did you use?
obaida963:
on my pcb, i left the D13,D12,D11"SCK, MISO, MOSI"vnot connected anywhere else ISP to not interfere with it, but in my original arduino board it was a tiny SMD Crystal oscillator 16Mhz, and in my custom pcb i change the oscillator to THT one one but also 16Mhz with to 22pf capacitors, so could it be that changing the Crystal oscillators make my problem?
also that my programmer is a "FTDI" with another arduino pro mini that i program it from arduino sketch "arduino ISP example" than i cut the reset pin form Arduino pro mini to prevent it from resetting it self when uploading new sketch to my atmeg328p on my custom pcb(it is right to make a programmer like that?)
i can share with schematic for my programmer if it's necessary.
Any successful programming will rely on the Reset pin of the target MCU being functional. The FTDI connects to the reset pin of the MCU via a 100nF capacitor. The ICSP reset connection to the reset pin is direct.
If you are using an Arduino as an ISP, it is usually only necessary to connect a 10uF capacitor between its reset pin and ground to prevent it resetting while it is being used in this mode.
Yes, publish your schematic.
I'm using mini cores settings."for the fuse bit" i placed the board file.
in my schematic"in witch i forget to add a 100nf between DTR and reset pin"later i fixed it, the U1"atmega328p" solder in place"the main ic to programe other ics via SPI, "U4,U6,U8" they are just empty ics sockets that i can just plug in a new ic there to program it than remove it, or use just SPI M/F header to program.
later i just added a plastic corner for "U4,U6,U8" to easily fix the target ic in place.
boards.txt (28.4 KB)