AnsweredAssumed Answered

FLASH_LDD FTFE_PDD_DisableInterrupts issue

Question asked by David Schroeder on Dec 5, 2013
Latest reply on Dec 19, 2013 by Petr_H

I'm having an issue with FLASH_LDD driver on a MK20FX512. When completing an erase followed by a write operation (through IntFLASH's SetFlash method) the Command Compete interrupt handler attempts to disable the command complete interrupt by calling FTFE_PDD_DisableInterrupts.

 

if (DeviceDataPrv->DataCounter == 0U) { /* If all the data has been successfully proceeded, finish the operation */
      DeviceDataPrv->CurrentOperationStatus = LDD_FLASH_IDLE; /* If yes, change the operation state to IDLE */
      FMC_PDD_InvalidateFlashCache(FMC_BASE_PTR);
      PE_NOP();
      PE_NOP();
      PE_NOP();
      FTFE_PDD_DisableInterrupts(FTFE_BASE_PTR, FTFE_PDD_COMMAND_COMPLETE_INT); /* Disable the Command complete interrupt */
      IntFlashLdd2_OnOperationComplete(DeviceDataPrv->UserDataPtr); /* Invoke the OnOperationComplete event */
      return;                          /* End */
    }

 

 

However it appears that most of the time it doesn't work, but every once in a while the operation completes successfully. When it doesn't work the application gets stuck with the interrupt handler being continuously called.

 

Stepping with the debugger and watching the FTFE_FCNFG register, if I break on line 8 above, I can see that the interrupt enable flags are still set. If I break on line 7, and step through the assembly code it works correctly and I don't encounter the problem.

 

As this suggests a timing issue, or a race condition, I modified the code to disable interrupts ( asm("cpsid.n i");)before calling FTFE_PDD_DisableInterrupts. This seams to resolve the issue, however I'm not sure if this is a real fix or if I'm just shifting timing enough to avoid the issue.

 

**     Processor   : MK20FX512VLQ12

**     Component   : FLASH_LDD

**     Version     : Component 01.099, Driver 01.12, CPU db: 3.00.000

 

Thanks,

   ~Dave

Outcomes