Reduced guard bit time in the AVRISP project PDI/TPI protocols to reduce the time...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 29 Dec 2009 14:54:52 +0000 (14:54 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 29 Dec 2009 14:54:52 +0000 (14:54 +0000)
Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.h

index 5275cca..1633fb2 100644 (file)
@@ -124,6 +124,10 @@ static void XPROGProtocol_EnterXPROGMode(void)
                XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);     \r
                XPROGTarget_SendByte(PDI_RESET_KEY);\r
 \r
                XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);     \r
                XPROGTarget_SendByte(PDI_RESET_KEY);\r
 \r
+               /* Lower direction change guard time to 8 USART bits */\r
+               XPROGTarget_SendByte(PDI_CMD_STCS | PDI_CTRL_REG);      \r
+               XPROGTarget_SendByte(0x04);\r
+\r
                /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
                XPROGTarget_SendByte(PDI_CMD_KEY);      \r
                for (uint8_t i = sizeof(PDI_NVMENABLE_KEY); i > 0; i--)\r
                /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
                XPROGTarget_SendByte(PDI_CMD_KEY);      \r
                for (uint8_t i = sizeof(PDI_NVMENABLE_KEY); i > 0; i--)\r
@@ -134,10 +138,13 @@ static void XPROGProtocol_EnterXPROGMode(void)
        }\r
        else\r
        {\r
        }\r
        else\r
        {\r
-       #if 0\r
                /* Enable TPI programming mode with the attached target */\r
                XPROGTarget_EnableTargetTPI();\r
                \r
                /* Enable TPI programming mode with the attached target */\r
                XPROGTarget_EnableTargetTPI();\r
                \r
+               /* Lower direction change guard time to 8 USART bits */\r
+               XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG);\r
+               XPROGTarget_SendByte(0x04);             \r
+               \r
                /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
                XPROGTarget_SendByte(TPI_CMD_SKEY);     \r
                for (uint8_t i = sizeof(TPI_NVMENABLE_KEY); i > 0; i--)\r
                /* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
                XPROGTarget_SendByte(TPI_CMD_SKEY);     \r
                for (uint8_t i = sizeof(TPI_NVMENABLE_KEY); i > 0; i--)\r
@@ -145,8 +152,6 @@ static void XPROGProtocol_EnterXPROGMode(void)
 \r
                /* Wait until the NVM bus becomes active */\r
                NVMBusEnabled = TINYNVM_WaitWhileNVMBusBusy();\r
 \r
                /* Wait until the NVM bus becomes active */\r
                NVMBusEnabled = TINYNVM_WaitWhileNVMBusBusy();\r
-       #endif\r
-               NVMBusEnabled = true;\r
        }\r
        \r
        Endpoint_Write_Byte(CMD_XPROG);\r
        }\r
        \r
        Endpoint_Write_Byte(CMD_XPROG);\r
index c1f1a63..a8c798e 100644 (file)
@@ -420,7 +420,7 @@ static void XPROGTarget_SetRxMode(void)
        }\r
        \r
        /* Wait until DATA line has been pulled up to idle by the target */\r
        }\r
        \r
        /* Wait until DATA line has been pulled up to idle by the target */\r
-       while (!(BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK));\r
+       while (!(BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK) && TimeoutMSRemaining);\r
 #endif\r
 \r
        IsSending = false;\r
 #endif\r
 \r
        IsSending = false;\r
index dab41f3..33a5827 100644 (file)
@@ -81,7 +81,7 @@
                #endif\r
                \r
                /** Number of cycles between each clock when software USART mode is used */\r
                #endif\r
                \r
                /** Number of cycles between each clock when software USART mode is used */\r
-               #define BITS_BETWEEN_USART_CLOCKS  100\r
+               #define BITS_BETWEEN_USART_CLOCKS  200\r
                \r
                /** Total number of bits in a single USART frame */\r
                #define BITS_IN_USART_FRAME        12\r
                \r
                /** Total number of bits in a single USART frame */\r
                #define BITS_IN_USART_FRAME        12\r