Author Topic: atmega - using pins used by programmer  (Read 1358 times)

0 Members and 1 Guest are viewing this topic.

Offline redloffTopic starter

  • Jr. Member
  • **
  • Posts: 17
  • Helpful? 0
atmega - using pins used by programmer
« on: January 09, 2013, 01:57:13 PM »
I have my circuit built on a breadboard and noticed, that if I have any diode or servo plugged in to one of the pins used by my programmer (avrmkII), that would be for instance PB3, PB4 or PB5 I cannot flash my uC (cannot transfer .hex file to it). I'm using avrdude, and when I try I get the following:

Code: [Select]
$ sudo avrdude -p m328p -c avrispmkII -P usb -U rs_control.hex

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

I suspect this is due to the fact that avrispII programmer powers on the uC and connected diodes/servos change the voltage on the pins which confuses avrisp/avrdude and makes flashing it impossible.

Is this really the case and if yes, how would I go around it? I really need those pins as almost all others are already used.


Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: atmega - using pins used by programmer
« Reply #1 on: January 09, 2013, 10:32:35 PM »
Yes, this is annoying. Your best bet is to unplug and re-plug the things connected to those pins when you re-program. If that ends up being a real problem, you might want to have a simple N-channel MOSFET between those external pieces and the pins, but have the programmer directly connected. Then, have a switch that turns the MOSFET on/off, and flip it when you program.
Another option (which you can combine) is to tie the programmer directly to the pins, but use a 1 kOhm resistor between the pin and whatever that pin is driving or reading. The programmer will then hopefully be able to drive the pins strongly enough.
Finally, if even that doesn't work, keep the same design, but also add a buffer circuit for the programmer pins, so that they have a very strong drive. Just beware that whatever is connected to those pins will also see the programmer signals, unless you implement the off-switch.

Offline redloffTopic starter

  • Jr. Member
  • **
  • Posts: 17
  • Helpful? 0
Re: atmega - using pins used by programmer
« Reply #2 on: January 13, 2013, 01:07:29 PM »
Thanks for clearing that up!


Get Your Ad Here