From e58915344d934395463d69876ab43bef0d93034a Mon Sep 17 00:00:00 2001
From: Dean Camera <dean@fourwalledcubicle.com>
Date: Sun, 18 Mar 2012 16:51:52 +0000
Subject: [PATCH] Fixed error in the AVRISP-MKII programmer when ISP mode is
 used at 64KHz (thanks to Ben R. Porter).

---
 LUFA/DoxygenPages/ChangeLog.txt          | 2 +-
 Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/LUFA/DoxygenPages/ChangeLog.txt b/LUFA/DoxygenPages/ChangeLog.txt
index 2f4c363bc..7d0b63ed1 100644
--- a/LUFA/DoxygenPages/ChangeLog.txt
+++ b/LUFA/DoxygenPages/ChangeLog.txt
@@ -29,7 +29,7 @@
   *   - Fixed compile error for the UC3 architecture when INTERRUPT_CONTROL_ENDPOINT is specified (thanks to Andrus Aaslaid)
   *   - Fixed compile error if LEDs_Disable() is called and BOARD=NONE is set (thanks to Sam Lin)
   *  - Library Applications:
-  *   - None
+  *   - Fixed error in the AVRISP-MKII programmer when ISP mode is used at 64KHz (thanks to Ben R. Porter)
   *
   *  \section Sec_ChangeLog120219 Version 120219
   *  <b>New:</b>
diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
index ac6831611..e2b230166 100644
--- a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
+++ b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
@@ -129,9 +129,12 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
 	{
 		SoftSPI_Data <<= 1;
 
-		if (!(SoftSPI_BitsRemaining--))
-		  TCCR1B = 0;
-
+		if (!(--SoftSPI_BitsRemaining))
+		{
+			TCCR1B = 0;
+			TIFR1  = (1 << OCF1A);
+		}
+		
 		if (PINB & (1 << 3))
 		  SoftSPI_Data |= (1 << 0);
 	}
-- 
GitLab