HOWTO: High Voltage Parallel Programming (HVPP) with STK500 example

If it happens that you completely mess up with AVR fuse bits and can't use In-System Programming (ISP) any more, High Voltage Parallel Programming will be the only option to “unbrick” your MCU. If you have STK500 on hand then it can be used for that.

Here is one example how did I recover ATMega328P where fuse bits was totally spoiled. Hint: do not use avrdude with -F flag, especially if your programmer is broken!

STK500

STK500 has two pin headers to use HVPP: “PROG CTRL” needs to be connected with “PORTD” and “PROG DATA” needs to be connected with “PORTB”. There are also “VTARGET”, “RESET, “OSCSEL”, “BSEL2” and “PJUMP” jumpers that needs to be connected correct way to use HVPP. However,this works only for chips that you can insert to the STK500 sockets.

If you need to program chip that is in your own PCB or is not supported by STK500 (like my ATMega328P was), then you need to know a little bit more about HVPP circuit.

From AVR datasheet ( ATmega328P for example) you can find a diagram how to connect your MCU with HVPP programmer

When programming AVR in High-voltage Programming mode, OSCSEL should be mounted on pins 1 and 2 to give the master microcontroller control of the target clock. This is explained in detail in Section 3.7.2 on page 3-11 of AVR STK500 User Guide. In section 3.8.5 it is shown how to connect BSEL2. VTARGET, RESET and XTAL1 jumpers needs to be installed too.

This is quite a lot of connections! Here is the the list of pins in STK500 that should be used with ATMega328P and my ExtraCore board

Function STK500 pin ATMega328P pin ExtraCore pin
DATA0 PROG DATA pin 1 PB0 D8
DATA1 PROG DATA pin 2 PB1 D9
DATA2 PROG DATA pin 3 PB2 D10
DATA3 PROG DATA pin 4 PB3 D11 (MOSI)
DATA4 PROG DATA pin 5 PB4 D12 (MISO)
DATA5 PROG DATA pin 6 PB5 D13 (SCK)
DATA6 PROG DATA pin 7 PC0 A0
DATA7 PROG DATA pin 8 PC1 A1
RDY/BSY PROG CTRL pin 2 PD1 TX
/OE PROG CTRL pin 3 PD2 D2
/WR PROG CTRL pin 4 PD3 D3
BS1 PROG CTRL pin 5 PD4 D4
XA0 PROG CTRL pin 6 PD5 D5
XA1 PROG CTRL pin 7 PD6 D6
PAGEL PROG CTRL pin 8 PD7 D7
BS2 BSEL2 right pin PC2 A2
XTAL PORTE/AUX pin 7 (XT1) PB6 (XTAL1) solder (1)
VCC PORTE/AUX pin 10 (VTG) VCC VCC
GND PORTE/AUX pin 9 (GND) GND GND
/RESET PORTE/AUX pin 4 (RST) PC6 (/RESET) RST (2)

1) you do not need to remove crystal but it is hard to solder XTAL1 wire together with SMD crystal installed
2) To make RESET work you need to remove reset circuit (R1 and C2). Especially it is important to remove C2. Otherwise +12V voltage rise is too slow for STK500.

Software

avrdude

Unfortunately avrdude does not support HVPP with STK500. Would be really great if anyone adds this functionality.

AVR Studio

You can use Atmel Studio for that. If you work in Linux environment (like I do), then t even works in virtual Windows environment (I used Windows XP running in VirtualBox). Make sure your can route your PC RS232 port to the VM for that. I used pl2303 based USB-RS232 converter for that.

Open “Tools” → “Device Programming”

Select your SKT500 and enter “ATMega238P” to the Device field. Note: you can't select it from the device list because there is no socket for such MCU in STK500 board. Then choose “HVPP” as interface and press “Apply”

After that make sure your STK500 board is connected and powered up. Next press “Read” for device signature and you should get 0x1E950F (ATMega328P signature, will be different in case of using different AVR).

Now select “Fuses” to read current fuse bits and change them. In case of ATMega328P, the default fuse bits should be:

  • EXTENDED - 0xFF
  • HIHG - 0xD9
  • LOW - 0x62

If the numbers are different, then just change them and “Program” a new ones. If you have different AVR then consult with your chip datasheet.


 
howto/stk500-hvpp.txt · Last modified: 2012/05/16 20:36 by cougar
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki ipv6 ready