From 6f8adf7abcf8c5a1f3235452783ff10904190b0e Mon Sep 17 00:00:00 2001
From: "Brian S. Dean" <bsd@bsdhome.com>
Date: Sat, 23 Nov 2002 00:47:29 +0000
Subject: [PATCH] When getting ready to initiate communications with the AVR
 device, first pull /RESET low for a short period of time before enabling the
 buffer chip.  This sequence allows the AVR to be reset before the buffer is
 enabled to avoid a short period of time where the AVR may be driving the
 programming lines at the same time the programmer tries to.  Of course, if a
 buffer is being used, then the /RESET line from the programmer needs to be
 directly connected to the AVR /RESET line and not via the buffer chip.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@156 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 avrdude/main.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/avrdude/main.c b/avrdude/main.c
index a476bb8b..6eeddfe9 100644
--- a/avrdude/main.c
+++ b/avrdude/main.c
@@ -839,10 +839,24 @@ int main(int argc, char * argv [])
   LED_OFF(fd, pgm->pinno[PIN_LED_PGM]);
   LED_OFF(fd, pgm->pinno[PIN_LED_VFY]);
 
+
+  /*
+   * Prepare to start talking to the connected device - pull reset low
+   * first, delay a few milliseconds, then enable the buffer.  This
+   * sequence allows the AVR to be reset before the buffer is enabled
+   * to avoid a short period of time where the AVR may be driving the
+   * programming lines at the same time the programmer tries to.  Of
+   * course, if a buffer is being used, then the /RESET line from the
+   * programmer needs to be directly connected to the AVR /RESET line
+   * and not via the buffer chip.
+   */
+
+  ppi_setpin(fd, pgm->pinno[PIN_AVR_RESET], 0);
+  usleep(1);
+
   /*
    * enable the 74367 buffer, if connected; this signal is active low
    */
-  /*ppi_setpin(fd, pgm->pinno[PIN_AVR_BUFF], 0);*/
   ppi_clr(fd, PPIDATA, pgm->pinno[PPI_AVR_BUFF]);
 
   /*