Programming 3217 custom board

I think I have found my problem. This para is from DLloyds GIT page. I might have to trick it into thinking it is ok as I am not powering it from the A0-A5 lines.

OVL Sense:

On startup, the OVL sense analog input (A6) will be checked. If the voltage on A0-A5 (target power) has dipped below 90% (4.5V), then the yellow LED will indicate overload status by blinking at 4Hz. The user will then need to correct the problem and press reset to clear.

That's true when the pin is reset. But when the pin is GPIO, it could be set to output. In that case you need to use a power cycle HV programming scheme, so that the HV pulse is applied during the short time after power on before the output enable timer expires, see the datasheet UDPI enable by 12v programming subsection.

Does this mean that being powered by its own internal 12V supply it will never program? Also it is set as an Analog I/P.

Is it possible that a mod I did to the board, a 1K pullup on the UPDI pin, to work as a voltage divider when in I/O mode may be causing a problem?

Hi @windoze_killa,

Just noticed this thread now ... haven't had much time to post here due to a rush home renovation job that'll keep me occupied for another 8-12 weeks or so.

Yes, the 1K pullup on the UPDI pin will create an issue with both the 12V pulse and regular UPDI programming. It needs to be temporarily disconnected.

Your diagram is quite pixelated when zooming in so a better image or perhaps a pdf attachment would help in viewing the part numbers.

The HVUPDI programmer has a built-in 1.2K series resistor, so its best to connect directly to the target UPDI (PA0) wthout any additional series resistor.

It looks like you have an OLED display connected. If the SCL and SDA lines have pullups, this might interfere with the required power cycle, so I think the best HV programming method would be automatically just after power-up.

There are 2 points in time when the programmer sends the 12V pulse.

  1. Immediately after power-up
  2. Just after performing its own power-cycle on the T5V power signal.

Let's focus on being able to power your board by using just the true 5V power and GND (hopefully this can be done). If so, then you can use PCHV mode and connect:

  1. The direct 5V power from the programmer's 6-pin header to target VCC (do not use T5V).
  2. Direct connection of UPDI to target PA0
  3. GND to target GND

With this method, the power-cycle is actually the power-up of the programmer and target board. The 5V power from the programmer's 6-pin header is more robust and should be able to power up your board c/w OLED.

Bugger. Unfortunately due to the design and the limited number of wires I can't power it from 5V. I can see a new design coming with additional wires but I was really trying to avoid it. It was going to be a fool proof design so sticky fingers couldn't screw it up.......looks like I am too smart for my own good.

As T5V is not connected, could I possibly use this to switch the 12V on via a latch of some sort? When initially powered on the device doesn't get power until the programmer does a POR, may be the HV pulse will be applied during the power on cycle as required. Just a thought.

You could try powering up your 12V board and the programmer simultaneously. The programmer will create and apply the 12V pulse on the UPDI line automatically within 8ms after power-up.

Make sure to use PCHV mode and just connect:

  1. Direct connect programmer UPDI to target PA0
  2. GND on programmer to target GND

In this case, no 5V or T5V connection is required.

I will give it a go but I will have to think about how I can do that. Would powering the programmer (Nano) from the same 12V source work? Will this override the 5V from the USB? Power both from the 12V and then connect the USB?

Sounds like a good idea, but I would only attempt this using a modified USB cable where the 5V power line is disconnected.

Good point. I have heaps.

Still doesn't work. I am guessing the timing is out. I have added the error message if that helps.

avrdude: Version 6.3-20201216
Copyright (c) 2000-2005 Brian Dean,
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "/home/jason/snap/arduino/61/.arduino15/packages/megaTinyCore/hardware/megaavr/2.3.2/avrdude.conf"
     User configuration file is "/home/jason/snap/arduino/61/.avrduderc"
     User configuration file does not exist or is not a regular file, skipping

     Using Port                    : /dev/ttyUSB0
     Using Programmer              : jtag2updi

JTAG ICE mkII sign-on message:
Communications protocol version: 1
boot-loader FW version: 1
firmware version: 6.00
hardware version: 1
boot-loader FW version: 1
firmware version: 6.00
hardware version: 1
Serial number: 00:00:00:00:00:00
AVR Part : ATtiny3217
Chip Erase delay : 0 us
BS2 : P00
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 0
StabDelay : 0
CmdexeDelay : 0
SyncLoops : 0
ByteDelay : 0
PollIndex : 0
PollValue : 0x00
Memory Detail :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
       prodsig        0     0     0    0 no         61   61      0     0     0 0x00 0x00
       fuses          0     0     0    0 no          9   10      0     0     0 0x00 0x00
       fuse0          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse6          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse7          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       fuse8          0     0     0    0 no          1    0      0     0     0 0x00 0x00
       lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
       data           0     0     0    0 no          0    0      0     0     0 0x00 0x00
       usersig        0     0     0    0 no         32   32      0     0     0 0x00 0x00
       flash          0     0     0    0 no      32768  128      0     0     0 0x00 0x00
       eeprom         0     0     0    0 no        256   64      0     0     0 0x00 0x00

     Programmer Type : JTAGMKII_PDI
     Description     : JTAGv2 to UPDI bridge
     M_MCU hardware version: 1
     M_MCU firmware version: 6.00
     S_MCU hardware version: 1
     S_MCU firmware version: 6.00
     Serial number:          00:00:00:00:00:00
     Vtarget         : 5.0 V

avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: jtagmkII_program_enable(): bad response to enter progmode command: RSP_NO_TARGET_POWER
avrdude: jtagmkII_program_enable(): bad response to enter progmode command: RSP_NO_TARGET_POWER
avrdude: jtagmkII_read_byte(): bad response to read memory command: RSP_NO_TARGET_POWER
avr_read(): error reading address 0x0000
read operation not supported for memory "signature"
avrdude: error reading signature data for part "ATtiny3217", rc=-2
avrdude: error reading signature data, rc=-2
avrdude: jtagmkII_program_disable(): bad response to leave progmode command: RSP_NO_TARGET_POWER

avrdude done. Thank you.

the selected serial port
does not exist or your board is not connected

Problem solved.....sort of.

I built up another board and left the 1K "voltage divider" off the UPDI pin and it programmed perfectly. Reconnected the 1K and wouldn't program. Bugger. Another new board design. Just a couple of $00 down the pooh shute.

Thanks for all your ideas. I was really hoping I could solve it with out a board redesign.

Now for help with a permanent soloution. If I drive a MOSFET to switch the 1K into circuit but only after say 100ms to allow the programmer to make sure it has enabled programming mode, would this work?

I am assuming once in programming mode the code that switches the MOSFET will be disabled until restart, is this correct?

The UPDI pin is quite sensitive to external load ... I would try building your MOSFET switch on a beadboard first, then connect it up and give it a test. Remember that it needs to tolerate and not interfere with the 12V pulse on PA0.


  • Looks like your circuit diagram has PA0 labelled "Gear In". If the purpose of this is just to check the presence of a 12V signal, perhaps all you need to do is use a voltage divider to get 0-5V signal, then use a series 220K resistor to connect the 0-5V signal to the PA0 input. This shouldn't interfere with HV UPDI communication.

  • Use a jumper to select "Gear In" or "Programming Mode"

  • Have a 4-pin header ... 3 pins for programming and the 4th pin "Gear In" can have a jumper installed to connect it to PA0 for normal use. Remove the jumper to program the board.

A couple of things.

I think the 12V pulse is working but the programming data is being the problem as the device restarts when I try to program it.

Gear in is an analog voltage between 0V and 5V. The input on the pin is what ever the voltage is when divided between the 1K and the resistance from the gear box switch. This resistance is between 870R and 15K.

I can't use jumpers as it will be potted in epoxy for weather proofing.

I will have a play with a MOSFET and see what happens.

Just an update.

The MOSFET idea seems to have worked. YEEEEHAAAAA

1 Like