From 8cd7e118e950d18ec0dd0d716005930ec45fd299 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sat, 26 Dec 2009 05:20:10 +0000 Subject: Fixed ISP mode in the AVRISP programmer project. --- Projects/AVRISP/Lib/ISP/ISPProtocol.h | 19 ++++--------------- Projects/AVRISP/Lib/ISP/ISPTarget.c | 3 +++ 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'Projects/AVRISP/Lib/ISP') diff --git a/Projects/AVRISP/Lib/ISP/ISPProtocol.h b/Projects/AVRISP/Lib/ISP/ISPProtocol.h index abbbf569d..127c8266c 100644 --- a/Projects/AVRISP/Lib/ISP/ISPProtocol.h +++ b/Projects/AVRISP/Lib/ISP/ISPProtocol.h @@ -38,6 +38,7 @@ /* Includes: */ #include + #include #include @@ -66,26 +67,14 @@ #define PROG_MODE_COMMIT_PAGE_MASK (1 << 7) /* Inline Functions: */ - /** Blocking delay for a given number of milliseconds, via a hardware timer. + /** Blocking delay for a given number of milliseconds. * * \param[in] DelayMS Number of milliseconds to delay for */ static inline void ISPProtocol_DelayMS(uint8_t DelayMS) { - OCR2A = ((F_CPU / 64) / 1000); - TCCR2A = (1 << WGM01); - TCCR2B = ((1 << CS01) | (1 << CS00)); - - while (DelayMS) - { - if (TIFR2 & (1 << OCF2A)) - { - TIFR2 = (1 << OCF2A); - DelayMS--; - } - } - - TCCR2B = 0; + while (DelayMS--) + _delay_ms(1); } /* Function Prototypes: */ diff --git a/Projects/AVRISP/Lib/ISP/ISPTarget.c b/Projects/AVRISP/Lib/ISP/ISPTarget.c index 29cb18e62..a3a8b2289 100644 --- a/Projects/AVRISP/Lib/ISP/ISPTarget.c +++ b/Projects/AVRISP/Lib/ISP/ISPTarget.c @@ -122,6 +122,9 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1 break; case PROG_MODE_WORD_VALUE_MASK: case PROG_MODE_PAGED_VALUE_MASK: + TCNT0 = 0; + TIFR0 = (1 << OCF1A); + do { SPI_SendByte(ReadMemCommand); -- cgit v1.2.3