Go Down

Topic: programming arduino via HV Programmer (Read 786 times) previous topic - next topic

obaida963

Feb 14, 2020, 01:01 am Last Edit: Feb 14, 2020, 01:06 am by obaida963
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?

DrAzzy

#1
Feb 14, 2020, 10:02 pm Last Edit: Feb 14, 2020, 10:02 pm by DrAzzy
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...
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

westfw

Quote
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

CrossRoads

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

DrAzzy

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)
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy


westfw

Quote
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:
Quote
2. The SPIEN Fuse is not accessible in serial programming mode.

obaida963

#7
Feb 15, 2020, 12:29 pm Last Edit: Feb 15, 2020, 12:31 pm by obaida963
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?

6v6gt

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 ) :

http://ww1.microchip.com/downloads/en/appnotes/atmel-2521-avr-hardware-design-considerations_applicationnote_avr042.pdf

obaida963

#9
Feb 15, 2020, 02:40 pm Last Edit: Feb 15, 2020, 02:50 pm by 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.

CrossRoads

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?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

6v6gt

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.


obaida963

#12
Feb 15, 2020, 06:00 pm Last Edit: Feb 15, 2020, 06:01 pm by obaida963
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.

obaida963

#13
Feb 15, 2020, 06:08 pm Last Edit: Feb 15, 2020, 06:23 pm by obaida963
later i just added a plastic corner for "U4,U6,U8" to easily fix the target ic in place.

Go Up