<?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: Flash Protection Violation Flag(FPVIOL) set while clearing CCIF bit  in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-Protection-Violation-Flag-FPVIOL-set-while-clearing-CCIF/m-p/561260#M33820</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jed,&lt;/P&gt;&lt;P&gt;The incorrect launch command sequence and erase execution in protected area will cause the kind of issue.&lt;/P&gt;&lt;P&gt;Regarding to the launch command sequence, you can refer to the figure below and relocate the launch command sequence in the RAM instead of the Flash.In addition, you should check what the value of the program flash protection registers (FTFL_FPROTn) are.&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ping&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Aug 2016 01:36:05 GMT</pubDate>
    <dc:creator>jeremyzhou</dc:creator>
    <dc:date>2016-08-03T01:36:05Z</dc:date>
    <item>
      <title>Flash Protection Violation Flag(FPVIOL) set while clearing CCIF bit</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-Protection-Violation-Flag-FPVIOL-set-while-clearing-CCIF/m-p/561258#M33818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When trying to erase a sector in flash by using "NV_FlashEraseSector", the error "gNV_ERR_PVIOL_c" is returned.&amp;nbsp; After some digging I found that the error is coming from the following snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14701628676156332 jive_text_macro" data-hasrefreshed="true" data-renderedposition="105_50_798_304" jivemacro_uid="_14701628676156332" modifiedtitle="true"&gt;&lt;P&gt;static uint32_t NvFlashCommandSequence&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pNvConfig_t pConfig,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t index,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8_t* pCommandArray&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;/* clear CCIF bit */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gNV_REG_WRITE(pConfig-&amp;gt;ftfxRegBase + gNV_FSTAT_OFFSET_c, gNV_FSTAT_CCIF_c);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;----&amp;nbsp; Issue occurs here&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;//* checking protection error */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if(0 != (registerValue &amp;amp; gNV_FSTAT_FPVIOL_c))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* return an error code gNV_ERR_PVIOL_c */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnCode = gNV_ERR_PVIOL_c;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;----&amp;nbsp; Error "found" and returned here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code above is a snipet of a method from C90TFS that was provided to me by Freescale.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue that I am running into is that the FPVIOL flag is flipped while writing to this location. The address written to is correct for setting the CCIF bit.&amp;nbsp; And the value of gNV_FSTAT_CCIF_c is a correct mask to test the bit needed ( The relevant values can be found below)&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_14701639478437042 jive_macro_code jive_text_macro" data-hasrefreshed="true" data-renderedposition="559_50_798_48" jivemacro_uid="_14701639478437042" modifiedtitle="true"&gt;&lt;P&gt;#define gNV_FSTAT_CCIF_c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x80&lt;/P&gt;&lt;P&gt;#define gNV_FSTAT_OFFSET_c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00000000&lt;/P&gt;&lt;P&gt;#define gNV_FTFX_REG_BASE_c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x40020000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;---- pconfig-&amp;gt;ftfxRegBase is set to this.&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The value of FTFL_FSTAT (0x40020000) goes from 0x0680 to 0x0690 in the issue line.&amp;nbsp; Why does FPVIOL get flagged during this step of the flash command sequence? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a Freescale K21 MCU (Model: MKW21D512VHA5) and IAR Embedded Workbench.&amp;nbsp; I am new to both of these so the solution could be very simple.&amp;nbsp; Thanks! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2016 19:20:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-Protection-Violation-Flag-FPVIOL-set-while-clearing-CCIF/m-p/561258#M33818</guid>
      <dc:creator>jeds</dc:creator>
      <dc:date>2016-08-02T19:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Flash Protection Violation Flag(FPVIOL) set while clearing CCIF bit</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-Protection-Violation-Flag-FPVIOL-set-while-clearing-CCIF/m-p/561259#M33819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this comment incorrect in the code?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* clear CCIF bit */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If this is the command execution it is setting the bit and not clearing it - the code will be running from SRAM (unless acting on a different Flash plane) and interrupts will be disabled.&lt;/P&gt;&lt;P&gt;Errors will be due to incorrect setup of the command - eg. not initially setting valid parameters before issuing the flashing command - or trying to delete a sector that is protected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kinetis for professionals: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2F" rel="nofollow" target="_blank"&gt;http://www.utasker.com/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2016 23:58:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-Protection-Violation-Flag-FPVIOL-set-while-clearing-CCIF/m-p/561259#M33819</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2016-08-02T23:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Flash Protection Violation Flag(FPVIOL) set while clearing CCIF bit</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-Protection-Violation-Flag-FPVIOL-set-while-clearing-CCIF/m-p/561260#M33820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jed,&lt;/P&gt;&lt;P&gt;The incorrect launch command sequence and erase execution in protected area will cause the kind of issue.&lt;/P&gt;&lt;P&gt;Regarding to the launch command sequence, you can refer to the figure below and relocate the launch command sequence in the RAM instead of the Flash.In addition, you should check what the value of the program flash protection registers (FTFL_FPROTn) are.&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ping&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2016 01:36:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-Protection-Violation-Flag-FPVIOL-set-while-clearing-CCIF/m-p/561260#M33820</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2016-08-03T01:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Flash Protection Violation Flag(FPVIOL) set while clearing CCIF bit</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-Protection-Violation-Flag-FPVIOL-set-while-clearing-CCIF/m-p/561261#M33821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After checking the FTFL_FPROTn registers I was able to determine that the issue was from an earlier part of my code instead of the problem line I had outlined above.&amp;nbsp; I was trying to set the flash protection to "gNV_FLASH_NOT_SECURE_c", and this was not unsecuring the flash but rather causing issues with it overall.&amp;nbsp; Thank you for the speedy response! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2016 21:07:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-Protection-Violation-Flag-FPVIOL-set-while-clearing-CCIF/m-p/561261#M33821</guid>
      <dc:creator>jeds</dc:creator>
      <dc:date>2016-08-03T21:07:12Z</dc:date>
    </item>
  </channel>
</rss>

