PDI NVM enable is fast enough that bare polling is enough without a fixed delay in...
[pub/USBasp.git] / Projects / AVRISP / Lib / PDITarget.c
index 22a4d01..eb16e0a 100644 (file)
@@ -173,6 +173,7 @@ void PDITarget_EnableTargetPDI(void)
        /* Set up the synchronous USART for XMEGA communications - \r
           8 data bits, even parity, 2 stop bits */\r
        UBRR1  = 10;\r
+       UCSR1B = (1 << TXEN1);\r
        UCSR1C = (1 << UMSEL10) | (1 << UPM11) | (1 << USBS1) | (1 << UCSZ11) | (1 << UCSZ10) | (1 << UCPOL1);\r
 \r
        /* Send two BREAKs of 12 bits each to enable PDI interface (need at least 16 idle bits) */\r
@@ -182,9 +183,10 @@ void PDITarget_EnableTargetPDI(void)
 \r
 void PDITarget_DisableTargetPDI(void)\r
 {\r
-       /* Turn of receiver and transmitter of the USART, clear settings */\r
-       UCSR1B = 0;\r
-       UCSR1C = 0;\r
+       /* Turn off receiver and transmitter of the USART, clear settings */\r
+       UCSR1A |= (1 << TXC1) | (1 << RXC1);\r
+       UCSR1B  = 0;\r
+       UCSR1C  = 0;\r
 \r
        /* Set all USART lines as input, tristate */\r
        DDRD  &= ~((1 << 5) | (1 << 3));\r