From a7880ac1cdbfe8ddaf957173bc08f334aad8bca7 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 15 Dec 2009 00:14:17 +0000 Subject: Fix error in AVRISP programmer when repeatedly using PDI mode via the hardware USART due to the SendByte routine not clearing the Transmit Complete USART flag. --- Projects/AVRISP/Lib/PDITarget.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Projects/AVRISP/Lib/PDITarget.c') diff --git a/Projects/AVRISP/Lib/PDITarget.c b/Projects/AVRISP/Lib/PDITarget.c index c774fdab8..28df55021 100644 --- a/Projects/AVRISP/Lib/PDITarget.c +++ b/Projects/AVRISP/Lib/PDITarget.c @@ -102,7 +102,7 @@ void PDITarget_EnableTargetPDI(void) /* Set up the synchronous USART for XMEGA communications - 8 data bits, even parity, 2 stop bits */ - UBRR1 = 10; + UBRR1 = (F_CPU / 1000000UL); UCSR1B = (1 << TXEN1); UCSR1C = (1 << UMSEL10) | (1 << UPM11) | (1 << USBS1) | (1 << UCSZ11) | (1 << UCSZ10) | (1 << UCPOL1); @@ -167,15 +167,16 @@ void PDITarget_SendByte(uint8_t Byte) PORTD |= (1 << 3); DDRD |= (1 << 3); - UCSR1B &= ~(1 << RXEN1); UCSR1B |= (1 << TXEN1); + UCSR1B &= ~(1 << RXEN1); IsSending = true; } /* Wait until there is space in the hardware Tx buffer before writing */ while (!(UCSR1A & (1 << UDRE1))); - UDR1 = Byte; + UCSR1A |= (1 << TXC1); + UDR1 = Byte; #else /* Switch to Tx mode if currently in Rx mode */ if (!(IsSending)) -- cgit v1.2.3