AVR® Programming Interfaces
HVPP
It’s first important to understand that all (see Exceptions below) AVR-based Tiny and Mega devices include an HVPP (High Voltage Parallel Programming) or an HVSP (High Voltage Serial Programming) programming interface. Both require the application of a “high voltage” (12 V) to the Reset pin and both require access to a large number of pins. The HVPP interface requires access to at least 16 pins while the HVSP interface requires access to at least 8 pins. For those reasons these interfaces are primarily used for production programming the devices. The following schematic depicts the required HVPP connections for the ATmega328PB (See section 33.7 in the data sheet):
The good news…
- The HVPP or HVSP interfaces are always enabled because they cannot be inadvertently disabled by a fuse setting or user action.
The bad news…
- They are almost never a realistic programming option once a Tiny or Mega is soldered onto a custom board because they simply require too many pins.
ISP/JTAG
In addition to the HVPP or HVSP interfaces, all (see Exceptions below) Tiny and Mega devices also include one or two “standard” programming interfaces: ISP or JTAG.
ISP (In-Circuit Serial Programming) allows the program memory to be reprogrammed In-System through an SPI serial interface. The following schematic depicts the required ISP connections for the ATmega328PB (See section 33.9 in the data sheet):
Depending on CKSEL Fuses, a valid clock must be present for ISP to function.
ISP is covered in detail in app-note AVR910 - In-System Programming.
The good news…
- These standard interfaces only require 3 or 4 pins.
The bad news…
- They can be easily disabled by the wrong fuse settings.
Combined Interfaces
All (see Exceptions below) Tiny and Mega devices include one of the two following combinations of programming interfaces:
- HVPP (or HVSP) and ISP
- HVPP (or HVSP) and ISP and JTAG
The ISP and JTAG interfaces are the standard programming interfaces for the Tiny and Mega devices. It’s recommended to include a programming header for one of the two interfaces on any custom board to allow convenient reprogramming of the device if necessary.
If a device only has an ISP interface and it is disabled via a fuse setting the only recovery is through its HVPP or HVSP interface (which is most likely not physically possible).
If a device has both an ISP and JTAG interface and one of those two is disabled by fuse settings the other interface can be used to access the part if the pins required are accessible. The ISP interface requires 3 pins and the JTAG interface requires 4 pins so it’s more likely either of those interfaces would be easier to access than the HVSP or HVPP interfaces.
Exceptions
- The Tiny4/5/9/10/20/40 devices do not have an HVPP or HVSP interface. They only have a TPI (Tiny Programming Interface). Newer devices like the Tiny417/817/1617 devices only have a UPDI (Unified Program and Debug Interface). As long as you have access to those interfaces there is no worry about “bricking” these devices.
- The Xmega devices include only a PDI (Programming and Debug Interface) or both a PDI and JTAG interface. You can’t disable the PDI interface so as long as you have access to the one PDI pin that can’t be used for any other function and the Reset pin you can’t “brick” these devices.