<?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>LPC MicrocontrollersのトピックRe: Save the data in internal flash</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562594#M50902</link>
    <description>Thanks, It's been solved now. There was an issue with memory address only as the address i was reading was illegal.</description>
    <pubDate>Thu, 01 Dec 2022 07:00:58 GMT</pubDate>
    <dc:creator>smishra125</dc:creator>
    <dc:date>2022-12-01T07:00:58Z</dc:date>
    <item>
      <title>Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1561241#M50857</link>
      <description>&lt;P&gt;I want to save the 16-bit integer buffer of size 250 bytes in internal flash of the LPC55S28JBD100 controller. I am using&amp;nbsp;LPCXpresso55S28 Development Board. Please provide some example and links.&lt;/P&gt;&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;</description>
      <pubDate>Tue, 29 Nov 2022 09:51:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1561241#M50857</guid>
      <dc:creator>smishra125</dc:creator>
      <dc:date>2022-11-29T09:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1561261#M50859</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/208808"&gt;@smishra125&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;did you already check the examples which come with the NXP SDK? There is one for the flash programming too:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErichStyger_0-1669717108335.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/202083iD42AF83E73A2DD2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErichStyger_0-1669717108335.png" alt="ErichStyger_0-1669717108335.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErichStyger_1-1669717152118.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/202084i3E15B16CC68C894D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErichStyger_1-1669717152118.png" alt="ErichStyger_1-1669717152118.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise:&lt;/P&gt;&lt;P&gt;I have shared a generic flash programming module on &lt;A href="https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/minIni/McuFlash.c" target="_blank"&gt;https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/minIni/McuFlash.c&lt;/A&gt; , and you can even use MinINI to store data as a file in flash as described in &lt;A href="https://mcuoneclipse.com/2021/12/19/key-value-pairs-in-flash-memory-file-system-less-minini/" target="_blank"&gt;https://mcuoneclipse.com/2021/12/19/key-value-pairs-in-flash-memory-file-system-less-minini/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 10:19:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1561261#M50859</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2022-11-29T10:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1561274#M50860</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;Thanks , I get it.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 10:41:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1561274#M50860</guid>
      <dc:creator>smishra125</dc:creator>
      <dc:date>2022-11-29T10:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1561946#M50885</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;I used the sdk example to save data in flash and it worked. But when I commented all the write and erase function of flash and then try to read the flash data only but it jumps into hardfault_handler file. My s_buffer_rbc variable is not able to get the value from the flash.Why it is showing the error in following code. I am sharing the code snippet.&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;* Copyright 2018 NXP&lt;BR /&gt;* All rights reserved.&lt;BR /&gt;*&lt;BR /&gt;* SPDX-License-Identifier: BSD-3-Clause&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;#include "fsl_debug_console.h"&lt;BR /&gt;#include "pin_mux.h"&lt;BR /&gt;#include "board.h"&lt;BR /&gt;#include "fsl_iap.h"&lt;BR /&gt;#include "fsl_iap_ffr.h"&lt;BR /&gt;#include "fsl_common.h"&lt;BR /&gt;#include "fsl_power.h"&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;// Definitions&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;// Prototypes&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;static void verify_status(status_t status);&lt;BR /&gt;static void error_trap();&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;// Variables&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;#define BUFFER_LEN 512 / 4&lt;BR /&gt;static uint32_t s_buffer_rbc[BUFFER_LEN];&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;// Code&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;flash_config_t flashInstance;&lt;BR /&gt;static uint32_t status;&lt;BR /&gt;uint32_t destAdrss; /* Address of the target location */&lt;BR /&gt;uint32_t failedAddress, failedData;&lt;BR /&gt;uint32_t pflashBlockBase = 0;&lt;BR /&gt;uint32_t pflashTotalSize = 0;&lt;BR /&gt;uint32_t pflashSectorSize = 0;&lt;BR /&gt;uint32_t PflashPageSize = 0;&lt;BR /&gt;const uint32_t s_buffer[BUFFER_LEN] = {12, 32, 13, 84};&lt;BR /&gt;/* Init board hardware. */&lt;BR /&gt;/* set BOD VBAT level to 1.65V */&lt;BR /&gt;POWER_SetBodVbatLevel(kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false);&lt;BR /&gt;/* attach 12 MHz clock to FLEXCOMM0 (debug console) */&lt;BR /&gt;CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);&lt;BR /&gt;/* enable clock for GPIO*/&lt;BR /&gt;CLOCK_EnableClock(kCLOCK_Gpio0);&lt;BR /&gt;CLOCK_EnableClock(kCLOCK_Gpio1);&lt;/P&gt;&lt;P&gt;BOARD_InitBootPins();&lt;BR /&gt;BOARD_BootClockFROHF96M();&lt;BR /&gt;BOARD_InitDebugConsole();&lt;/P&gt;&lt;P&gt;/* Print basic information for Flash Driver API.*/&lt;BR /&gt;PRINTF("\r\nFlash driver API tree Demo Application...\r\n");&lt;BR /&gt;/* Initialize flash driver */&lt;BR /&gt;PRINTF("Initializing flash driver...\r\n");&lt;BR /&gt;if (FLASH_Init(&amp;amp;flashInstance) == kStatus_Success)&lt;BR /&gt;{&lt;BR /&gt;PRINTF("Flash init successfull!!. Halting...\r\n");&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;error_trap();&lt;BR /&gt;}&lt;BR /&gt;/* Get flash properties kFLASH_ApiEraseKey */&lt;BR /&gt;FLASH_GetProperty(&amp;amp;flashInstance, kFLASH_PropertyPflashBlockBaseAddr, &amp;amp;pflashBlockBase);&lt;BR /&gt;FLASH_GetProperty(&amp;amp;flashInstance, kFLASH_PropertyPflashSectorSize, &amp;amp;pflashSectorSize);&lt;BR /&gt;FLASH_GetProperty(&amp;amp;flashInstance, kFLASH_PropertyPflashTotalSize, &amp;amp;pflashTotalSize);&lt;BR /&gt;FLASH_GetProperty(&amp;amp;flashInstance, kFLASH_PropertyPflashPageSize, &amp;amp;PflashPageSize);&lt;/P&gt;&lt;P&gt;/* print welcome message */&lt;BR /&gt;PRINTF("\r\n PFlash Example Start \r\n");&lt;BR /&gt;/* Print flash information - PFlash. */&lt;BR /&gt;PRINTF("\tkFLASH_PropertyPflashBlockBaseAddr = 0x%X\r\n", pflashBlockBase);&lt;BR /&gt;PRINTF("\tkFLASH_PropertyPflashSectorSize = %d\r\n", pflashSectorSize);&lt;BR /&gt;PRINTF("\tkFLASH_PropertyPflashTotalSize = %d\r\n", pflashTotalSize);&lt;BR /&gt;PRINTF("\tkFLASH_PropertyPflashPageSize = 0x%X\r\n", PflashPageSize);&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;PAGE_INDEX_FROM_END = 1 means the last page,&lt;BR /&gt;PAGE_INDEX_FROM_END = 2 means (the last page -1 )...&lt;BR /&gt;*/&lt;BR /&gt;#ifndef PAGE_INDEX_FROM_END&lt;BR /&gt;#define PAGE_INDEX_FROM_END 1U&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;destAdrss = pflashBlockBase + (pflashTotalSize - (PAGE_INDEX_FROM_END * PflashPageSize));&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Verify programming by reading back from flash directly */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;for (uint32_t i = 0; i &amp;lt; BUFFER_LEN; i++)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;s_buffer_rbc[i] = *(volatile uint32_t *)(destAdrss + i * 4);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (s_buffer_rbc[i] != s_buffer[i])&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;error_trap();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PRINTF("\r\n Successfully Programmed and Verified Location 0x%x -&amp;gt; 0x%x \r\n", destAdrss,&lt;BR /&gt;(destAdrss + sizeof(s_buffer)));&lt;/P&gt;&lt;P&gt;/* resume flash memory status */&lt;BR /&gt;status = FLASH_Erase(&amp;amp;flashInstance, destAdrss, PflashPageSize, kFLASH_ApiEraseKey);&lt;/P&gt;&lt;P&gt;PRINTF("Done!\r\n");&lt;/P&gt;&lt;P&gt;while (1)&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void verify_status(status_t status)&lt;BR /&gt;{&lt;BR /&gt;char *tipString = "Unknown status";&lt;BR /&gt;switch (status)&lt;BR /&gt;{&lt;BR /&gt;case kStatus_Success:&lt;BR /&gt;tipString = "Done.";&lt;BR /&gt;break;&lt;BR /&gt;case kStatus_InvalidArgument:&lt;BR /&gt;tipString = "Invalid argument.";&lt;BR /&gt;break;&lt;BR /&gt;case kStatus_FLASH_AlignmentError:&lt;BR /&gt;tipString = "Alignment Error.";&lt;BR /&gt;break;&lt;BR /&gt;case kStatus_FLASH_AccessError:&lt;BR /&gt;tipString = "Flash Access Error.";&lt;BR /&gt;break;&lt;BR /&gt;case kStatus_FLASH_CommandNotSupported:&lt;BR /&gt;tipString = "This API is not supported in current target.";&lt;BR /&gt;break;&lt;BR /&gt;default:&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;PRINTF("%s\r\n\r\n", tipString);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;* @brief Gets called when an error occurs.&lt;BR /&gt;*/&lt;BR /&gt;void error_trap(void)&lt;BR /&gt;{&lt;BR /&gt;PRINTF("\r\n\r\n\r\n\t---- HALTED DUE TO FLASH ERROR! ----");&lt;BR /&gt;while (1)&lt;BR /&gt;{&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;// EOF&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 10:13:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1561946#M50885</guid>
      <dc:creator>smishra125</dc:creator>
      <dc:date>2022-11-30T10:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562106#M50890</link>
      <description>&lt;P&gt;See that McuFlash_InitErase() I have provided.&lt;/P&gt;&lt;P&gt;If you just erase but not verify the memory, it will generate a hard fault accessing it.&lt;/P&gt;&lt;P&gt;The McuFlash_IsAccessible() has a comment about that special memory for the LPC55xx.&lt;/P&gt;&lt;P&gt;I hipe this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 15:38:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562106#M50890</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2022-11-30T15:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562529#M50895</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;I need to read the flash memory in the program that's why i tried this code. I havn't erased anything. I just want to read the what is on the FLASH BUFFER ADDRESS but it fails.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Verify programming by reading back from flash directly */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;for (uint32_t i = 0; i &amp;lt; BUFFER_LEN; i++)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;s_buffer_rbc[i] = *(volatile uint32_t *)(destAdrss + i * 4);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (s_buffer_rbc[i] != s_buffer[i])&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;error_trap();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 04:49:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562529#M50895</guid>
      <dc:creator>smishra125</dc:creator>
      <dc:date>2022-12-01T04:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562536#M50896</link>
      <description>&lt;P&gt;What's the address you are reading from? Check with the debugger, which address causes the hard fault. I suspect it is either a wrong address, points beyond your valid memory range or the page has been erased and not verified, so causing a hard fault.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 05:14:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562536#M50896</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2022-12-01T05:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562560#M50900</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;I used the sdk example to read data from flash. When the default code erase, write and read the data from the memory then it is doing OK. But when in the same code, I remove the erase and write part and try to read the same address then it shows me the hardfault error. Please check may be sdk has some issue.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 06:02:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562560#M50900</guid>
      <dc:creator>smishra125</dc:creator>
      <dc:date>2022-12-01T06:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562573#M50901</link>
      <description>&lt;P&gt;That reading from a memory location is not SDK specific at all. It is just reading from a FLASH memory address.&lt;/P&gt;&lt;P&gt;I assume you have written that part with the SDK example earlier and somehow 'corrupted' it. This is what happened to me as well while developing my own flash programming routines. That's why I implemented all these safeguards in that McuFlash.c I mentioned. I really recommend that you follow that procedure described in there, and please have a look at the application note/forum discussion mentioned in there.&lt;/P&gt;&lt;P&gt;So again: check with the debugger the address your reading from. Use the debugger memory view to check if the memory is valid there. If in doubt: Erase the complete flash with the debugger to get a good state of it, then program again your application.&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 06:24:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562573#M50901</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2022-12-01T06:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Save the data in internal flash</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562594#M50902</link>
      <description>Thanks, It's been solved now. There was an issue with memory address only as the address i was reading was illegal.</description>
      <pubDate>Thu, 01 Dec 2022 07:00:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Save-the-data-in-internal-flash/m-p/1562594#M50902</guid>
      <dc:creator>smishra125</dc:creator>
      <dc:date>2022-12-01T07:00:58Z</dc:date>
    </item>
  </channel>
</rss>

