Electronics > Electronics

atmega - using pins used by programmer

(1/1)

redloff:
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: ---$ 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.

--- End code ---

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.

Thanks.

jwatte:
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.

redloff:
Thanks for clearing that up!

Navigation

[0] Message Index

Go to full version