X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/1aeb5056d6943331ee2d11807bcc0a6480ad1ca0..75d27f8ef0873157c4ca14dc41d1eb4139e0180d:/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c?ds=inline diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c index 140642869..843bf5a7d 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c @@ -96,7 +96,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK) } /** ISR to manage the TPI software USART when bit-banged TPI USART mode is selected. */ -ISR(TIMER1_COMPB_vect, ISR_BLOCK) +ISR(TIMER1_CAPT_vect, ISR_BLOCK) { /* Toggle CLOCK pin in a single cycle (see AVR datasheet) */ BITBANG_TPICLOCK_PIN |= BITBANG_TPICLOCK_MASK; @@ -152,9 +152,11 @@ void XPROGTarget_EnableTargetPDI(void) DDRD |= (1 << 5) | (1 << 3); DDRD &= ~(1 << 2); - /* Set DATA line high for at least 90ns to disable /RESET functionality */ + /* Set DATA line high for at least 90ns to disable /RESET functionality (note: too long will enable it again, + * so a fixed number of NOPs are used here */ PORTD |= (1 << 3); - _delay_ms(1); + asm volatile ("NOP"::); + asm volatile ("NOP"::); /* Set up the synchronous USART for XMEGA communications - 8 data bits, even parity, 2 stop bits */ @@ -166,9 +168,11 @@ void XPROGTarget_EnableTargetPDI(void) BITBANG_PDIDATA_DDR |= BITBANG_PDIDATA_MASK; BITBANG_PDICLOCK_DDR |= BITBANG_PDICLOCK_MASK; - /* Set DATA line high for at least 90ns to disable /RESET functionality */ + /* Set DATA line high for at least 90ns to disable /RESET functionality (note: too long will enable it again, + * so a fixed number of NOPs are used here */ BITBANG_PDIDATA_PORT |= BITBANG_PDIDATA_MASK; - _delay_ms(1); + asm volatile ("NOP"::); + asm volatile ("NOP"::); /* Fire timer compare channel A ISR to manage the software USART */ OCR1A = BITS_BETWEEN_USART_CLOCKS; @@ -209,10 +213,10 @@ void XPROGTarget_EnableTargetTPI(void) /* Set DATA line high for idle state */ BITBANG_TPIDATA_PORT |= BITBANG_TPIDATA_MASK; - /* Fire timer capture channel B ISR to manage the software USART */ - OCR1B = BITS_BETWEEN_USART_CLOCKS; - TCCR1B = (1 << WGM12) | (1 << CS10); - TIMSK1 = (1 << OCIE1B); + /* Fire timer capture channel ISR to manage the software USART */ + ICR1 = BITS_BETWEEN_USART_CLOCKS; + TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS10); + TIMSK1 = (1 << ICIE1); #endif /* Send two BREAKs of 12 bits each to enable TPI interface (need at least 16 idle bits) */