\r
/* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */\r
PDITarget_SendByte(PDI_CMD_KEY); \r
- for (uint8_t i = 0; i < sizeof(PDI_NVMENABLE_KEY); i++)\r
- PDITarget_SendByte(PDI_NVMENABLE_KEY[i]);\r
+ for (uint8_t i = sizeof(PDI_NVMENABLE_KEY); i > 0; i--)\r
+ PDITarget_SendByte(PDI_NVMENABLE_KEY[i - 1]);\r
\r
/* Poll the STATUS register to check to see if NVM access has been enabled */\r
- uint8_t NVMAttemptsRemaining = 200;\r
- while (NVMAttemptsRemaining--)\r
+ uint8_t NVMAttemptsRemaining = 150;\r
+ while (NVMAttemptsRemaining)\r
{\r
_delay_ms(1);\r
- PDITarget_SendByte(PDI_CMD_LDCS | PD_STATUS_REG);\r
\r
+ PDITarget_SendByte(PDI_CMD_LDCS | PD_STATUS_REG);\r
if (PDITarget_ReceiveByte() & PDI_STATUS_NVM)\r
break;\r
+\r
+ NVMAttemptsRemaining--;\r
}\r
\r
Endpoint_Write_Byte(CMD_XPROG);\r