<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: MK20DN32VLF : Rewrite flash data issues in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1300424#M60944</link>
    <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/188557"&gt;@TCazala&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you share your code for writing a sector in Flash?&amp;nbsp; I'm not sure what you mean by functions generated by CodeWarrior.&amp;nbsp; When I worked with CodeWarrior, the APIs provided were quite rudimentary although there are some basic Flash IO functions available.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have Flash writing code written under CodeWarrior for the MK20DN512VLLL10 and runs with MQX.&amp;nbsp; I must point out that I had to create my own BSP for CodeWarrior and it was a lot of work which leads me to the question...&lt;/P&gt;&lt;P&gt;Why are you working with CodeWarrior and not MCUXpresso?&amp;nbsp; CodeWarrior should really be considered out of date.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Jun 2021 12:52:13 GMT</pubDate>
    <dc:creator>myke_predko</dc:creator>
    <dc:date>2021-06-30T12:52:13Z</dc:date>
    <item>
      <title>MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1300269#M60942</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I am trying to save datas in flash data emplacement using fonctions generated by the tool (I am using codewarrior). It works fine for the first save but I can not erase et rewrite while I do not reflash the microcontroller. Is there a way to rewrite without reflashing systematically ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Titouan Cazala&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 08:20:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1300269#M60942</guid>
      <dc:creator>TCazala</dc:creator>
      <dc:date>2021-06-30T08:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1300424#M60944</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/188557"&gt;@TCazala&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you share your code for writing a sector in Flash?&amp;nbsp; I'm not sure what you mean by functions generated by CodeWarrior.&amp;nbsp; When I worked with CodeWarrior, the APIs provided were quite rudimentary although there are some basic Flash IO functions available.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have Flash writing code written under CodeWarrior for the MK20DN512VLLL10 and runs with MQX.&amp;nbsp; I must point out that I had to create my own BSP for CodeWarrior and it was a lot of work which leads me to the question...&lt;/P&gt;&lt;P&gt;Why are you working with CodeWarrior and not MCUXpresso?&amp;nbsp; CodeWarrior should really be considered out of date.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 12:52:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1300424#M60944</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-06-30T12:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1300811#M60947</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I also want to know how you operate the flash. Do you disable the global interrupt when you doing flash operation?&lt;/P&gt;
&lt;P&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;
&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 days after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 02:20:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1300811#M60947</guid>
      <dc:creator>nxf56274</dc:creator>
      <dc:date>2021-07-01T02:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302390#M60958</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is an example of the routine i'm using to rewrite a part of the flash.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;do
{
  Error = FLASH1_EraseBlock(MyFLASH_Ptr, CalibrationDataAdress);
   do 
   {	FLASH1_Main(MyFLASH_Ptr);
        OpStatus = FLASH1_GetOperationStatus(MyFLASH_Ptr);						
   } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));
	
   DataWrittenFlg = FALSE;
   Error = FLASH1_Write(MyFLASH_Ptr, InpData, CalibrationDataAdress, 0x15);   	  	
					
   do 
   {	FLASH1_Main(MyFLASH_Ptr);
        OpStatus = FLASH1_GetOperationStatus(MyFLASH_Ptr);
   } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));	
} while(OpStatus == LDD_FLASH_FAILED);
				
HowManyFlashWrites++;
DataWrittenFlg = FALSE;
if (FLASH1_GetOperationStatus(MyFLASH_Ptr) == LDD_FLASH_FAILED) {}
				
Error = FLASH1_Read(MyFLASH_Ptr, CalibrationDataAdress, FlashCopy, 0x15);    
do 
{	FLASH1_Main(MyFLASH_Ptr);
        OpStatus = FLASH1_GetOperationStatus(MyFLASH_Ptr);
} while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));
if (OpStatus == LDD_FLASH_FAILED) {};	
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I have delays between each operation)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Folowing functions are those I were refere to in my initial text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;FLASH1_EraseBlock (component FLASH_LDD)
FLASH1_Write (component FLASH_LDD)
FLASH1_Read (component FLASH_LDD)
FLASH1_Main (component FLASH_LDD)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I link to this message the generated file containing function description for using the flash.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 12:25:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302390#M60958</guid>
      <dc:creator>TCazala</dc:creator>
      <dc:date>2021-07-05T12:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302426#M60959</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I do not know the state of global interrupts. There are no trace of any kind of interrupt settings in the whole program.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;It seems like it is drived directly into functions I refered to such as&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;/*
** ===================================================================
**     Method      :  FLASH1_Main (component FLASH_LDD)
**
**     Description :
**         This method is used to perform one batch of a flash memory
**         operation operation. This method is used to perform batches
**         of all flash memory operations (Write, Read, Erase,
**         EraseBlock, VerifyErasedBlock) when the component works in
**         the polled mode (interrupt service is disabled - property
**         &amp;lt;Interrupt service&amp;gt;). This method performs batches of the
**         read flash memory operation, when the component works in the
**         interrupt triggered mode (interrupt service is enabled).
**         This method is enabled only if the component works in the
**         polled mode or if the Read method is enabled.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * DeviceDataPtr   - Device data structure
**                           pointer returned by &amp;lt;Init&amp;gt; method.
**     Returns     : Nothing
** ===================================================================
*/
#define UNLIMITED_BATCH_SIZE 0U
#define WRITE_BATCH_SIZE 1U
#define ERASE_BATCH_SIZE 1U
#define READ_BATCH_SIZE UNLIMITED_BATCH_SIZE
#define READ_1S_BLOCK_NORMAL_MARGINE_LEVEL 0U
#define WRITABLE_UNIT_MASK 3U

void FLASH1_Main(LDD_TDeviceData *DeviceDataPtr)
{
  FLASH1_TDeviceDataPtr DeviceDataPrv = (FLASH1_TDeviceDataPtr)DeviceDataPtr; /* Auxiliary variable - pointer to an internal state structure */
  uint32_t DataToPrg = 0xFFFFFFFFLU;   /* Auxiliary variable - current data to be proceeded */
  uint32_t DataToPrgMask = 0U;
  uint32_t CurrentFlashPrgUnitData;    /* Current flash location content */
  uint8_t PrgBytesCount;               /* Auxiliary variable - Current data counter - number of data to be proceeded (in bytes) */
  uint8_t MaxPossiblePrgBytes = 0U;
  uint8_t DstAddrOffset = 0U;          /* Offset of the desired flash location to be written from the begging of the smallest writable unit the desired location belongs to */
  uint8_t i;
  LDD_FLASH_TAddress FlashPrgUnitAddr;
  uint16_t StepsOfBatch = 0U;          /* Number of batch cycles to be proceeded */
  bool NextBatchCycle;                 /* Unlimited batch flag */
  uint8_t CurrentFlags;                /* Auxiliary variable - current hw flags */

  if ((DeviceDataPrv-&amp;gt;CurrentOperationStatus != LDD_FLASH_RUNNING) &amp;amp;&amp;amp; /* If there is not an operation in progress or pending then end */\
     (DeviceDataPrv-&amp;gt;CurrentOperationStatus != LDD_FLASH_START) &amp;amp;&amp;amp; \
     (DeviceDataPrv-&amp;gt;CurrentOperationStatus != LDD_FLASH_STOP_REQ)) {
    return;
  }
  if ((FTFL_PDD_GetFlags(FTFL_BASE_PTR) &amp;amp; FTFL_PDD_COMMAND_COMPLETE) == 0U){ /* If there is some flash operation in progress then end */
    return;
  }
  if (DeviceDataPrv-&amp;gt;CurrentOperationStatus == LDD_FLASH_START) { /* Is this run the first run of the Main method in this operation? */
    FTFL_PDD_ClearFlags(FTFL_BASE_PTR, /* If yes, clear hw flags */
                        FTFL_PDD_READ_COLLISION_ERROR | \
                        FTFL_PDD_ACCESS_ERROR | \
                        FTFL_PDD_PROTECTION_VIOLATION);
    DeviceDataPrv-&amp;gt;CurrentErrorFlags = 0U; /* Clear Current SW error flags */
  } else {                             /* If this is not the first run of the operation, checks the error flags */
    CurrentFlags = FTFL_PDD_GetFlags(FTFL_BASE_PTR);
    DeviceDataPrv-&amp;gt;CurrentErrorFlags |= CurrentFlags &amp;amp; /* Save current hw flags */\
    (FTFL_PDD_READ_COLLISION_ERROR | \
     FTFL_PDD_ACCESS_ERROR | \
     FTFL_PDD_PROTECTION_VIOLATION);
    if ((DeviceDataPrv-&amp;gt;CurrentOperation == LDD_FLASH_VERIFY_ERASED_BLOCK) &amp;amp;&amp;amp; (CurrentFlags &amp;amp; FTFL_PDD_COMMAND_COMPLETION_STATUS)) { /* Was the verification of erased block successfull? */
      DeviceDataPrv-&amp;gt;CurrentErrorFlags |= LDD_FLASH_ERASE_VERIFICATION_ERROR; /* if no, set the Erase verification error flag */
    }
    if (DeviceDataPrv-&amp;gt;CurrentErrorFlags != 0U) { /* Has some error occurred? */
      DeviceDataPrv-&amp;gt;CurrentOperationStatus = LDD_FLASH_FAILED; /* If yes, set the operation state to FAILED */
      if (DeviceDataPrv-&amp;gt;CurrentOperation != LDD_FLASH_READ) {
        FMC_PDD_InvalidateFlashCache(FMC_BASE_PTR);
        PE_NOP();
        PE_NOP();
        PE_NOP();
      }
      return;                          /* End */
    }
    if (DeviceDataPrv-&amp;gt;DataCounter == 0U) { /* If all the data has been successfully proceeded, finish the operation */
      DeviceDataPrv-&amp;gt;CurrentOperationStatus = LDD_FLASH_IDLE; /* If yes, change the operation state to IDLE */
      if (DeviceDataPrv-&amp;gt;CurrentOperation != LDD_FLASH_READ) {
        FMC_PDD_InvalidateFlashCache(FMC_BASE_PTR);
        PE_NOP();
        PE_NOP();
        PE_NOP();
      }
      FLASH1_OnOperationComplete(DeviceDataPrv-&amp;gt;UserDataPtr); /* Invoke the OnOperationComplete event */
      return;                          /* End */
    }
  }
  switch (DeviceDataPrv-&amp;gt;CurrentOperation) { /* Define the batch counter's initial value according to the current operation */
    case LDD_FLASH_WRITE:              /* The current operation is Write */
      StepsOfBatch = WRITE_BATCH_SIZE; /* Initialize the batch counter */
      break;                           /* Break of the case */
    case LDD_FLASH_ERASE:              /* The current operation is Erase */
      StepsOfBatch = ERASE_BATCH_SIZE; /* Initialize the batch counter */
      break;                           /* Break of the case */
    case LDD_FLASH_READ:               /* The current operation is Read */
      StepsOfBatch = READ_BATCH_SIZE;  /* Initialize the batch counter */
      break;                           /* Break of the case */
    case LDD_FLASH_ERASE_BLOCK:        /* The current operation is Erase block */
      StepsOfBatch = 1U;               /* Initialize the batch counter */
      break;                           /* Break of the case */
    case LDD_FLASH_VERIFY_ERASED_BLOCK: /* The current operation is Verify erased block */
      StepsOfBatch = 1U;               /* Initialize the batch counter */
      break;                           /* Break of the case */
    default:
      break;
  }
  if (StepsOfBatch == UNLIMITED_BATCH_SIZE) { /* Is the unlimited batch of size selected for the current operation? */
    NextBatchCycle = TRUE;             /* If the unlimited batch of size is used, set the NextCycle force variable to TRUE */
  } else {
    NextBatchCycle = FALSE;            /* If the unlimited batch of size is used, set the NextCycle force variable to FALSE */
  }
  while ((StepsOfBatch &amp;gt; 0U) || (NextBatchCycle)) { /* Should another batch of the current operation be proceeded in this Main method processing? */
    CurrentFlags = FTFL_PDD_GetFlags(FTFL_BASE_PTR); /* Read current hardware flags */
    if ((CurrentFlags &amp;amp; (FTFL_PDD_READ_COLLISION_ERROR /* Check the error flags */\
                     | FTFL_PDD_ACCESS_ERROR \
                     | FTFL_PDD_PROTECTION_VIOLATION)) != 0U) {
      return;                          /* If there has some error occurred then end. The error will be analyzed in the next call of the Main method */
    }
    if (DeviceDataPrv-&amp;gt;CurrentOperationStatus == LDD_FLASH_START) { /* Is this step the first step of the operation? */
      DeviceDataPrv-&amp;gt;CurrentOperationStatus = LDD_FLASH_RUNNING; /* If yes, change Current operation status to RUNNING */
    } else {
      DeviceDataPrv-&amp;gt;CurrentFlashAddress += DeviceDataPrv-&amp;gt;CurrentDataSize; /* If no, define of an address of a step of the current operation (address of the first step of the operation is defined by a operational method, which defines the operation */
      if ((DeviceDataPrv-&amp;gt;CurrentOperation == LDD_FLASH_READ) || (DeviceDataPrv-&amp;gt;CurrentOperation == LDD_FLASH_WRITE)) {
        DeviceDataPrv-&amp;gt;CurrentDataPtr += DeviceDataPrv-&amp;gt;CurrentDataSize; /* Update of the Current data pointer */
      }
    }
    switch(DeviceDataPrv-&amp;gt;CurrentOperation) { /* Perform needed actions for the next step of the operation (for the next flash operation command) according to the current operation type */
      case LDD_FLASH_READ:             /* Read operation */
        *DeviceDataPrv-&amp;gt;CurrentDataPtr = *(uint8_t *)DeviceDataPrv-&amp;gt;CurrentFlashAddress; /* Read data from flash */
        DeviceDataPrv-&amp;gt;DataCounter--;  /* Update of the Data counter */
        break;
      case LDD_FLASH_ERASE:            /* Erase operation */
        DeviceDataPrv-&amp;gt;DataCounter -= (uint32_t)(FLASH1_ERASABLE_UNIT_SIZE); /* Update of the Data counter */
        break;
      case LDD_FLASH_ERASE_BLOCK:      /* Erase block operation */
        DeviceDataPrv-&amp;gt;DataCounter--;  /* Update of the Data counter (the unit is a block not a byte) */
        break;
      case LDD_FLASH_VERIFY_ERASED_BLOCK:
        DeviceDataPrv-&amp;gt;DataCounter--;  /* Update of the Data counter (the unit is a block not a byte) */
        FTFL_PDD_WriteFCCOB4Reg(FTFL_BASE_PTR, READ_1S_BLOCK_NORMAL_MARGINE_LEVEL); /* Set the Read margin level for the Read 1s block operation */
        break;
      case LDD_FLASH_WRITE:
        DstAddrOffset = (uint8_t)DeviceDataPrv-&amp;gt;CurrentFlashAddress &amp;amp; WRITABLE_UNIT_MASK; /* Compute the address of the writable unit */
        MaxPossiblePrgBytes = (WRITABLE_UNIT_MASK - DstAddrOffset) + 1U; /* Compute number of bytes from the destination address to the end of the writable unit */
        if (DeviceDataPrv-&amp;gt;DataCounter &amp;lt; MaxPossiblePrgBytes) {
          PrgBytesCount = (uint8_t)DeviceDataPrv-&amp;gt;DataCounter;
        } else {
          PrgBytesCount = MaxPossiblePrgBytes;
        }
        for (i = 0U; i &amp;lt; PrgBytesCount; i++)  {
          ((uint8_t *)(void *)&amp;amp;DataToPrg)[DstAddrOffset + i] = ((uint8_t *)(void *)(DeviceDataPrv-&amp;gt;CurrentDataPtr))[i];
          ((uint8_t *)(void *)&amp;amp;DataToPrgMask)[DstAddrOffset + i] = 0xFFu;
        }
        FlashPrgUnitAddr = DeviceDataPrv-&amp;gt;CurrentFlashAddress - DstAddrOffset;
        CurrentFlashPrgUnitData = *(uint32_t *)FlashPrgUnitAddr;
        if(((DataToPrg &amp;amp; DataToPrgMask) &amp;amp; (~CurrentFlashPrgUnitData)) &amp;gt; 0U) {
          DeviceDataPrv-&amp;gt;CurrentErrorFlags |= LDD_FLASH_MULTIPLE_WRITE_ERROR;
          return;
        }
        DataToPrg = DataToPrg ^ (~CurrentFlashPrgUnitData);
        DeviceDataPrv-&amp;gt;CurrentDataSize = PrgBytesCount;
        DeviceDataPrv-&amp;gt;DataCounter -= PrgBytesCount;
        FTFL_PDD_WriteFCCOBLongWordData(FTFL_BASE_PTR, DataToPrg);
        break;
      default:
        break;
    } /* switch(DeviceDataPrv-&amp;gt;CurrentOperation) */
    StepsOfBatch -= 1U;
    if (DeviceDataPrv-&amp;gt;DataCounter == 0U) {
      NextBatchCycle = FALSE;
      StepsOfBatch = 0U;
    }
    if (DeviceDataPrv-&amp;gt;CurrentOperation != LDD_FLASH_READ) {
      FTFL_PDD_SetFCCOBCommand(FTFL_BASE_PTR, DeviceDataPrv-&amp;gt;CurrentCommand); /* Set the desired flash operation command */
      FTFL_PDD_SetFCCOBAddress(FTFL_BASE_PTR, ((uint32_t)(DeviceDataPrv-&amp;gt;CurrentFlashAddress - DstAddrOffset))); /* Set an address of the flash memory location for the current flash operation command */
      /* {Default RTOS Adapter} Critical section begin, general PE function is used */
      EnterCritical();
      ((LDD_FLASH_TSafeRoutinePtr)((uint32_t)(DeviceDataPrv-&amp;gt;SafeRoutinePtr) | 1U))(); /* Run the Safe routine */
      /* {Default RTOS Adapter} Critical section end, general PE function is used */
      ExitCritical();
    }
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe, I did not understood your questions ?&amp;nbsp;If I do, please tell me I will try to find something else which can match.&lt;BR /&gt;&lt;BR /&gt;Thanks for your help.&lt;BR /&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 11:18:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302426#M60959</guid>
      <dc:creator>TCazala</dc:creator>
      <dc:date>2021-07-05T11:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302463#M60960</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/188557"&gt;@TCazala&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, the APIs that I am using are completely different.&amp;nbsp; Where did you get this code?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/71004"&gt;@nxf56274&lt;/a&gt;&amp;nbsp;is asking about disabling global interrupts, it is calling&amp;nbsp;(in the SDK) "__disable_irq()" before doing the write and "__enable_irq()" after which are defined as:&lt;/P&gt;&lt;PRE&gt;__attribute__((always_inline)) __STATIC_INLINE void __disable_irq(void)&lt;BR /&gt;{&lt;BR /&gt;__ASM volatile ("cpsid i" : : : "memory");&lt;BR /&gt;}&lt;/PRE&gt;&lt;PRE&gt;__attribute__((always_inline)) __STATIC_INLINE void __enable_irq(void)&lt;BR /&gt;{&lt;BR /&gt;__ASM volatile ("cpsie i" : : : "memory");&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;You may want to try disabling interrupts before calling "FLASH1_Main" and then enabling them upon return.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 13:01:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302463#M60960</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-07-05T13:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302506#M60961</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I am using Codewarrior for MCU version 11.1. I were contrained to use this API because I heritated this project from one of my collegue that can not support me on those issues ...&lt;BR /&gt;The code I sent you was directly in the project my collegue gave to me and in the heading, it is written that was "generated by the tool". &lt;BR /&gt;Moreover, in the description, lower in heading, there is a settings list where is this line : "Interrupt service : Disabled". I assume that iterrupts are already disabled when calling functions from this library.&lt;BR /&gt;&lt;BR /&gt;It seems like I do not have any functions to enable/disable interrupts or I can not find which are they... Based to overs questions on forums it should be define in ProcessorExpert but there are not any trace of those.&lt;/P&gt;
&lt;P&gt;Should I try to define it by myself, following your code ?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is the Project explorer, maybe it can be more usefull to understand my problem...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="TCazala_0-1625496407518.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/148811i972C73D398570107/image-size/large?v=v2&amp;amp;px=999" role="button" title="TCazala_0-1625496407518.png" alt="TCazala_0-1625496407518.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help !&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 14:47:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302506#M60961</guid>
      <dc:creator>TCazala</dc:creator>
      <dc:date>2021-07-05T14:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302524#M60963</link>
      <description>&lt;P&gt;&amp;nbsp;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/188557"&gt;@TCazala&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;About the interrupts: this depends if you are using the interrupt flash driver method or the non-interrupt one. I prefer the non-interrupt on.&lt;/P&gt;&lt;P&gt;You can see in &lt;A href="https://mcuoneclipse.com/2014/05/31/configuration-data-using-the-internal-flash-instead-of-an-external-eeprom/" target="_blank"&gt;https://mcuoneclipse.com/2014/05/31/configuration-data-using-the-internal-flash-instead-of-an-external-eeprom/&lt;/A&gt; how I'm using this with KL25Z and Processor Expert. I don't have the MK20DN32, but things worked the same for me for the K20DN128.&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 15:18:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302524#M60963</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-07-05T15:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302577#M60969</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/188557"&gt;@TCazala&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you try putting the disable_irq before the call to "FLASH1_Main" and enable them afterwards.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;that you should use IRQ disabled Flash writes.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I read the comment in the source code:&lt;/P&gt;&lt;PRE&gt;/*
** ===================================================================
**     Method      :  FLASH1_Main (component FLASH_LDD)
**
**     Description :
**         This method is used to perform one batch of a flash memory
**         operation operation. This method is used to perform batches
**         of all flash memory operations (Write, Read, Erase,
**         EraseBlock, VerifyErasedBlock) when the component works in
**         the polled mode (interrupt service is disabled - property
**         &amp;lt;Interrupt service&amp;gt;). This method performs batches of the
**         read flash memory operation, when the component works in the
**         interrupt triggered mode (interrupt service is enabled).
**         This method is enabled only if the component works in the
**         polled mode or if the Read method is enabled.
**     Parameters  :
**         NAME            - DESCRIPTION
**       * DeviceDataPtr   - Device data structure
**                           pointer returned by &amp;lt;Init&amp;gt; method.
**     Returns     : Nothing
** ===================================================================
*/&lt;/PRE&gt;&lt;P&gt;I take it to mean that interrupts are disabled when this method is called.&amp;nbsp; It's a bit ambiguous and poorly written.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jul 2021 20:01:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1302577#M60969</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-07-05T20:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1303226#M60983</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/58763"&gt;@myke_predko&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;It did not work with the FLASH1 component.&lt;BR /&gt;&lt;BR /&gt;I undertook to the&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;method. I am having some type troubles right now but his tutorial lead me to options I was looking for. I hope when I solved type issues it will work fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tanks.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:05:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1303226#M60983</guid>
      <dc:creator>TCazala</dc:creator>
      <dc:date>2021-07-06T14:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1303232#M60984</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;I am trying to use your solution in my project but I have some type issues like.&lt;BR /&gt;Did you encountered something like "illegal implicit conversion from int to void*" when you were using&amp;nbsp;&lt;EM&gt;NVMC_GetSumoData() ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;I also had troubles whith "uintX_t", did it happened to you as well ?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:15:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1303232#M60984</guid>
      <dc:creator>TCazala</dc:creator>
      <dc:date>2021-07-06T14:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1303250#M60987</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/188557"&gt;@TCazala&lt;/a&gt; ,&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Did you encountered something like "illegal implicit conversion from int to void*" when you were using&amp;nbsp;&lt;EM&gt;NVMC_GetSumoData() ?&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This sounds like you did not properly use/include the interface/header file.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;I also had troubles whith "uintX_t", did it happened to you as well ?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Did you include &amp;lt;stdint.h&amp;gt;?&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:37:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1303250#M60987</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2021-07-06T14:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1303254#M60988</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/188557"&gt;@TCazala&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry it didn't work out for you.&amp;nbsp; I never found PE to be able to generate great code - the current SDK is a lot better.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sure&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;has the right approach for you.&lt;/P&gt;&lt;P&gt;myke&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:39:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1303254#M60988</guid>
      <dc:creator>myke_predko</dc:creator>
      <dc:date>2021-07-06T14:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: MK20DN32VLF : Rewrite flash data issues</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1304074#M61002</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;You were right, I feel so dumb !&lt;BR /&gt;Thank you.&lt;BR /&gt;&lt;BR /&gt;I will let you know if your method works for me as soon as I retablished the communication with my device.&lt;BR /&gt;It seems that all those changement fucked up something, I have to find a way to fix it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your time.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 15:14:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MK20DN32VLF-Rewrite-flash-data-issues/m-p/1304074#M61002</guid>
      <dc:creator>TCazala</dc:creator>
      <dc:date>2021-07-07T15:14:50Z</dc:date>
    </item>
  </channel>
</rss>

