We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
The IAP is driving me crazy. When I single step my code using ulink it works, but when I just let it run the micro reboots itself and the IAP hasn't worked. I've read the manual, AN10256, searched the forums and looked at the sample code.
Here's my code:
ErrorCode_t writeBufToOneFlashSector(uint8_t secNum) { BOOL good = TRUE; ErrorCode_t retCode = ERR_NO_ERROR; unsigned int enables; BOOL pllStat; // Disable interrupts during erase and write operations // Keep a copy of what was enabled enables = VICIntEnable; command[0] = IAP_PrepareSectors; command[1] = (uint32_t)secNum; command[2] = (uint32_t)secNum; waitTXComplete(); pauseTX(TRUE); pllStat = usePLL(FALSE); iap_entry(command, result); good = (BOOL)(IAP_CMD_SUCCESS == result[0]); if(!good) { usePLL(pllStat); retCode = ERR_IAP_ERASE_PREPARE | ERR_NUM_USED; errVal = (ParamType)result[0]; } else { command[0] = IAP_EraseSectors; command[1] = (uint32_t)secNum; command[2] = (uint32_t)secNum; command[3] = XTAL_OSC_KHZ; // Disable interrupts during erase VICIntEnable = 0; iap_entry(command, result); VICIntEnable = enables; good = (BOOL)(IAP_CMD_SUCCESS == result[0]); if(!good) { usePLL(pllStat); retCode = ERR_IAP_ERASE | ERR_NUM_USED; errVal = (ParamType)result[0]; } } // See about doing the write if(good) { command[0] = IAP_PrepareSectors; command[1] = (uint32_t)secNum; command[2] = (uint32_t)secNum; iap_entry(command, result); good = (BOOL)(IAP_CMD_SUCCESS == result[0]); if(!good) { usePLL(pllStat); retCode = ERR_IAP_WRITE_PREPARE | ERR_NUM_USED; errVal = (ParamType)result[0]; } } // Ready to write at last if(good) { command[0] = IAP_CopyRAMtoFlash; command[1] = SectorStartAddr[secNum]; command[2] = (unsigned int)nvBuf; command[3] = FLASH_NV_PAGE_SIZE8; command[4] = XTAL_OSC_KHZ; // Disable interrupts during erase VICIntEnable = 0; iap_entry(command, result); usePLL(pllStat); VICIntEnable = enables; good = (BOOL)(IAP_CMD_SUCCESS == result[0]); if(!good) { retCode = ERR_IAP_WRITE | ERR_NUM_USED; errVal = (ParamType)result[0]; } } pauseTX(FALSE); return retCode; }
So, do you still encounter the IAP problem?
Bad of it to not generate an error about incorrect parameter.
God, this is soooo frustrating. After I fixed the sector calculation algorithm, the example IAP project appears to work. I can't say that it works with 100% confidence because you can only observe it's behaviour with the debugger, and I know the debugger makes a difference. Anyway, the next step is obviously to add my code, piece by piece, until I figure out what breaks it. The problem now is that the ULink seems to have stopped working, as it keeps reporting that it can't stop the target. I remember this happening to me before, and I had to use Flashmagic to recover the target, but that doesn't seem to do the trick now. Flashmagic claims to reprogram the target, but the ULink still doesn't work.
Have you done a full chip erase with Flash Magic?
try this: * reduce JTAG clock speed. * disable "cache code", "cache memory" in driver setup menu.