Hey guys,
I think I finally figured out that reset/programming circuit I was working on.
This circuit is designed to allow an XMEGA to be reset into programming mode with a single button press.
Normally, if you have the board powered from the USB port, you'd have to press and hold reset, then press and hold a program button, then release reset, and finally release the program button. Or you'd need a switch or jumper on the board to enable programming mode.
With this setup, you just push the button, the board resets, and assuming you don't release the button faster than the reset occurs, the program line will be pulled low when that happens, and the board will enter programming mode.
In addition, because the programming pin by default is on one of the SPI lines, and I didn't want to lose an SPI port, I needed to find a way to ensure that SPI on the programming pin wouldn't reset the board, that it would still be possible to reset the board if the programming line were being pulled high or low, and that pressing the button while SPI was active would not short the pin to ground.
This circuit does all of the above:
Java simulation: Circuit Simulator Applet
Note that the forward voltage drop on the diodes (well, the one on the reset pin at least) needs to be below 400mv or the capacitor discharge will cause the voltage to spike above the 3.8v max on the MEGA's reset pin. It isn't tolerant of high voltage like the Atmega and 32U4.
Also, the 25K capacitor by the reset pin is the internal 25K pullup on that pin, so the final part count is 2 resistors, 2 diodes, and a capacitor.
I have not tested this circuit myself yet, so buyer beware.
It should be possible to add an additional reset button that performs a normal reset with the addition of another diode, but I never end up using those things, I just reprogram. It's easy enough to unplug the board to reset it anyway.
Anyway, if anyone has any thoughts on the circuit let me know. The only thing I'm not certain about is that the reset line is pulled low for long enough to trigger the reset, but I think the timing is the same as the Uno here, so it should be okay. The Mega requires a maximum of 1000ns low I think to trigger it which is a really small amount of time.
[edit]
Oh, and in the above circuit, the resest pin is the dot on the right side of the schematic, and the programming pin is the white dot at the top left. The switch highlighted in blue is the pushbutton that triggers the reset and programming mode. Above it is a switch to test what effect spi communication via the programming pin would have. It's the miso line, and without that diode there, going low would trigger the board to reset. There's also a switch next to it which disconnects that other switch from the circuit so the programming pin will be as it would be in its normal input state.
Also, the scope on the left is the reset pin, and the scope on the right is the program pin.