From 5687ac7316335009160ccd7f56fce5e7746c5889 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Tue, 2 Feb 2010 04:33:58 +0000 Subject: Fix TPI mode chip erase code not properly erasing the target memory space. --- Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c') diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c index e3e43dd503..ca5def27eb 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c @@ -188,18 +188,25 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress, uint8_t* WriteBuffer, uint } /** Erases the target's memory space. + * + * \param[in] Address Address inside the memory space to erase * * \return Boolean true if the command sequence complete successfully */ -bool TINYNVM_EraseMemory(void) +bool TINYNVM_EraseMemory(const uint8_t EraseCommand, const uint16_t Address) { /* Wait until the NVM controller is no longer busy */ if (!(TINYNVM_WaitWhileNVMControllerBusy())) return false; - /* Set the NVM control register to the CHIP ERASE command to erase the target */ + /* Set the NVM control register to the target memory erase command */ TINYNVM_SendWriteNVMRegister(XPROG_Param_NVMCMDRegAddr); - XPROGTarget_SendByte(TINY_NVM_CMD_CHIPERASE); + XPROGTarget_SendByte(EraseCommand); + + /* Write to a location within the target address space to start the erase process */ + TINYNVM_SendPointerAddress(Address); + XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT); + XPROGTarget_SendByte(0x00); /* Wait until the NVM bus is ready again */ if (!(TINYNVM_WaitWhileNVMBusBusy())) -- cgit v1.2.3