Fixed AVRISP project not extending the command delay after each successful page/word/byte program.
* do not adversely affect the code operation (currently only the LEDs driver)\r
* - Added keyboard modifier masks (HID_KEYBOARD_MODIFER_*) and LED report masks (KEYBOARD_LED_*) to the HID class driver and\r
* Keyboard demos\r
+ * - Added .5MHz recovery clock to the AVRISP programmer project when in ISP programming mode to correct mis-set fuses\r
*\r
* <b>Changed:</b>\r
* - Slowed down software USART carried PDI programming in the AVRISP project to prevent transmission errors\r
* - Fixed SerialStream driver blocking while waiting for characters to be received instead of returning EOF\r
* - Fixed SerialStream driver not setting stdin to the created serial stream\r
* - Fixed USB_GetHIDReportSize() returning the number of bits in the specified report instead of bytes\r
+ * - Fixed AVRISP project not extending the command delay after each successful page/word/byte program\r
*\r
* \section Sec_ChangeLog091223 Version 091223\r
*\r
* </tr>\r
* </table>\r
*\r
+ * In addition, the AVR's XCK pin will generate a .5MHz clock when SPI programming is used, to act as an external\r
+ * device clock if the fuses have been mis-set. To use the recovery clock, connect XCK to the target AVR's XTAL1\r
+ * pin, and set the ISP programming speed to 125KHz or below.\r
+ *\r
* <b><sup>1</sup></b> <i>Optional, see \ref SSec_Options section - for USB AVRs with ADC modules only</i> \n\r
* <b><sup>2</sup></b> <i>See AUX line related tokens in the \ref SSec_Options section</i>\r
*\r
uint8_t ResponseStatus = STATUS_CMD_FAILED;\r
\r
CurrentAddress = 0;\r
+ \r
+ /* Set up the synchronous USART to generate the recovery clock on XCK pin */\r
+ UBRR1 = (F_CPU / 500000UL);\r
+ UCSR1B = (1 << TXEN1);\r
+ UCSR1C = (1 << UMSEL10) | (1 << UPM11) | (1 << USBS1) | (1 << UCSZ11) | (1 << UCSZ10) | (1 << UCPOL1);\r
+ DDRD |= (1 << 5);\r
\r
+ /* Perform execution delay, initialize SPI bus */\r
ISPProtocol_DelayMS(Enter_ISP_Params.ExecutionDelayMS); \r
SPI_Init(ISPTarget_GetSPIPrescalerMask() | SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING | SPI_MODE_MASTER);\r
\r
SPI_ShutDown();\r
ISPProtocol_DelayMS(Leave_ISP_Params.PostDelayMS);\r
\r
+ /* Turn off the synchronous USART to terminate the recovery clock on XCK pin */\r
+ UBRR1 = (F_CPU / 500000UL);\r
+ UCSR1B = (1 << TXEN1);\r
+ UCSR1C = (1 << UMSEL10) | (1 << UPM11) | (1 << USBS1) | (1 << UCSZ11) | (1 << UCSZ10) | (1 << UCPOL1);\r
+ DDRD &= ~(1 << 5);\r
+\r
Endpoint_Write_Byte(CMD_LEAVE_PROGMODE_ISP);\r
Endpoint_Write_Byte(STATUS_CMD_OK);\r
Endpoint_ClearIN();\r
ProgrammingStatus = ISPTarget_WaitWhileTargetBusy();\r
break;\r
}\r
+ \r
+ if (ProgrammingStatus == STATUS_CMD_OK)\r
+ TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
\r
return ProgrammingStatus;\r
}\r
}\r
while ((SPI_ReceiveByte() & 0x01) && TimeoutMSRemaining);\r
\r
- if (!(TimeoutMSRemaining))\r
- return STATUS_RDY_BSY_TOUT;\r
- else\r
- return STATUS_CMD_OK;\r
+ return ((TimeoutMSRemaining) ? STATUS_CMD_OK : STATUS_RDY_BSY_TOUT);\r
}\r
\r
/** Sends a low-level LOAD EXTENDED ADDRESS command to the target, for addressing of memory beyond the\r
/* Send the SLDCS command to read the TPI STATUS register to see the NVM bus is active */\r
XPROGTarget_SendByte(TPI_CMD_SLDCS | TPI_STATUS_REG);\r
if (XPROGTarget_ReceiveByte() & TPI_STATUS_NVM)\r
- return true;\r
+ {\r
+ TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
+ return true;\r
+ }\r
}\r
- \r
+\r
return false;\r
}\r
\r
\r
/* Check to see if the BUSY flag is still set */\r
if (!(XPROGTarget_ReceiveByte() & (1 << 7)))\r
- return true;\r
+ {\r
+ TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
+ return true;\r
+ }\r
}\r
- \r
+\r
return false;\r
}\r
\r
\r
while (WriteLength)\r
{\r
+ /* Wait until the NVM controller is no longer busy */\r
+ if (!(TINYNVM_WaitWhileNVMControllerBusy()))\r
+ return false;\r
+\r
/* Write the low byte of data to the target */\r
XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);\r
XPROGTarget_SendByte(*(WriteBuffer++));\r
XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);\r
XPROGTarget_SendByte(*(WriteBuffer++));\r
\r
- /* Wait until the NVM controller is no longer busy */\r
- if (!(TINYNVM_WaitWhileNVMControllerBusy()))\r
- return false;\r
-\r
/* Need to decrement the write length twice, since we read out a whole word */\r
WriteLength -= 2;\r
}\r
/* Send the LDCS command to read the PDI STATUS register to see the NVM bus is active */\r
XPROGTarget_SendByte(PDI_CMD_LDCS | PDI_STATUS_REG);\r
if (XPROGTarget_ReceiveByte() & PDI_STATUS_NVM)\r
- return true;\r
+ {\r
+ TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
+ return true;\r
+ }\r
}\r
\r
return false;\r
\r
/* Check to see if the BUSY flag is still set */\r
if (!(XPROGTarget_ReceiveByte() & (1 << 7)))\r
- return true;\r
+ {\r
+ TimeoutMSRemaining = COMMAND_TIMEOUT_MS;\r
+ return true;\r
+ }\r
}\r
\r
return false;\r