element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Freedom development platform
  • Products
  • Dev Tools
  • Freedom development platform
  • More
  • Cancel
Freedom development platform
Forum Freescale Freedom Development Platform (Questions and Answers)
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Freedom development platform to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 42 replies
  • Subscribers 9 subscribers
  • Views 4219 views
  • Users 0 members are here
  • 32bit
  • low_power
  • cortex-m0+
  • freescale
  • freedom_board
  • Cortex-M
  • microcontrollers
  • kinetis
  • arm_cortex_m
  • cortex
  • arm_cortex
  • kinetis-l
  • microcontroller
  • mcu
  • cortex-m0
  • arm
  • arduino
  • freedom
Related

Freescale Freedom Development Platform (Questions and Answers)

FreescaleTools_and_Software
FreescaleTools_and_Software over 12 years ago

Hello FRDM-KL25Z buyer

 

You are already thousands of customers who ordered this board.

In order to make your life easier, with a single place where to find relevant informations concerning this tool, I will try to collect in this post the answered questions concerning FRDM-KL25Z, found in different places like Freescale community, groups from Element14 Community or anywhere on the web ...

 

I will publish regularly (in the document section from this group) some very instructive tutorials produced by my colleague Erich Styger, which should help you to take in hand FRDM-KL25Z and its software tools (Codewarrior 10.3beta, Processor Expert ...).

 

Don't hesitate to post here your new questions that we can answer it and share it with the community.


  • Sign in to reply
  • Cancel
Parents
  • FreescaleTools_and_Software
    FreescaleTools_and_Software over 12 years ago

    QUESTION

    You are writing some datas to flash memory (eeprom emulation) using FRDM-KL25Z.

    You want to check what data you wrote (since you don't have LCD).

    Is there a way to check the data that you wrote using codewarrior IDE ?


     


    ANSWER

    You can use Processor Expert to read and write the flash:

    First, you have to reserve some Flash pages for data storage. Do that in the CPU Build Options, Reduce the Flash for code, for example :

     

    1.bmp

     

    Then, configure those pages to be used by Flash component:

     

    2.bmp

     

     

    Then, enable the Flash methods you need:

    3.bmp

     

     

    Now, you can save the data in the code:

     

    Read:

     

    FLASH1_Read(FLASH1Pointer,0x1F000, &savedData.red, sizeof(savedData));

       do {

                   FLASH1_Main(FLASH1Pointer);

           OpStatus = FLASH1_GetOperationStatus(FLASH1Pointer);

       } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

     

     

     

    Erase one page, in case is not 0xFF the locations to write:

     

    FLASH1_Erase(FLASH1Pointer, 0x1F000, 1024);

                   do {

                                  FLASH1_Main(FLASH1Pointer);

                                  OpStatus = FLASH1_GetOperationStatus(FLASH1Pointer);

                   } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

     

     

     

    And then write the data in Flash:

     

    FLASH1_Write(FLASH1Pointer, FromPtr, 0x1F000, Size);

     

                   do {

                           FLASH1_Main(FLASH1Pointer);

                           OpStatus = FLASH1_GetOperationStatus(FLASH1Pointer);

                   } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to FreescaleTools_and_Software

    I did the same thing but the erase function is not working!

    I did this:

     

    data = 0x11;

      ADDR = ((SHARED_MEM_SPACE << 16) | ALT3CONF_SECTOR<<4| ALT3CONF1); //this is my macro definition for address

      printf("ADDR = 0x%x\n", ADDR);

      ProgramFlash_Write(Program_Flash, &data, ADDR, sizeof(data));

      do {

      ProgramFlash_Main(Program_Flash);

      OpStatus = ProgramFlash_GetOperationStatus(Program_Flash);

      } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

     

      ProgramFlash_Read(Program_Flash, ADDR, &data, sizeof(data));    /* Start reading from the flash memory */

      do {

      ProgramFlash_Main(Program_Flash);

      printf("here\n");

      OpStatus = ProgramFlash_GetOperationStatus(Program_Flash);

      } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

     

      printf("data read is = 0x%x\n", data);

     

      ProgramFlash_Erase(Program_Flash, ADDR, 2048);

      do {

      printf("yes\n");

      ProgramFlash_Main(Program_Flash);

      OpStatus = ProgramFlash_GetOperationStatus(Program_Flash);

      } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

     

     

      ProgramFlash_Read(Program_Flash, ADDR, &dump, sizeof(data));    /* Start reading from the flash memory */

      do {

      ProgramFlash_Main(Program_Flash);

      printf("yes2\n");

      OpStatus = ProgramFlash_GetOperationStatus(Program_Flash);

      } while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));

     

      printf("dump read is = 0x%x\n", dump);

     

     

     

    and I am reading this:

     

     

    ADDR = 0x12811

    here

    here

    data read is = 0x11

    yes

    yes2

    yes2

    dump read is = 0x11

     

     

     

     

    I also set the user space in flash, but not sure if that matters:

    Fullscreen contentimage_175385.html Download
    <html><head><title>Jive SBS</title></head>
    <body><font face="arial,helvetica,sans-serif">
    <b>Error</b><br><font size="-1">
    An general error occurred while processing your request.
    </font></font></body></html>
    

    Fullscreen contentimage_175386.html Download
    <html><head><title>Jive SBS</title></head>
    <body><font face="arial,helvetica,sans-serif">
    <b>Error</b><br><font size="-1">
    An general error occurred while processing your request.
    </font></font></body></html>
    

     

    do you have any idea why mine is not erasing?!!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • FreescaleTools_and_Software
    FreescaleTools_and_Software over 11 years ago in reply to Former Member

    Hi Mehdi,

      I saw you figured out the issue on the Freescale community. I've repasted your answer below for anyone who is also looking for the answer:

     

    Mehdi

    https://community.freescale.com/message/387507#387507

    It is working now, I had to edit my routines, it looks something like this now:

     

    in events.c:

    /* ===================================================================*/

    void ProgramFlash_OnOperationComplete(LDD_TUserData *UserDataPtr)

    {

             uint8_t *OpStatus = (LDD_TUserData*) UserDataPtr;

         *OpStatus = TRUE;

    }

    -----------------------------

    bool ReadFlash(LDD_TDeviceData *DeviceData, LDD_FLASH_TAddress FromAddress, LDD_TData* DataPtr, LDD_FLASH_TDataSize Size, uint8_t* OpStatus)

    {

      LDD_TError Error;

      *OpStatus = FALSE;

      Error = FLASH_Read(DeviceData, FromAddress, DataPtr, Size);

      if (Error) {

        return FALSE;

      }

      do{

        FLASH_Main(DeviceData);

      }

      while(FLASH_GetOperationStatus(DeviceData) != LDD_FLASH_IDLE);

      return TRUE;

    }

     

    bool WriteFlash(LDD_TDeviceData *DeviceData, LDD_TData* DataPtr, LDD_FLASH_TAddress FromAddress, LDD_FLASH_TDataSize Size, uint8_t* OpStatus)

    {

      LDD_TError Error;

      *OpStatus = FALSE;

      Error = FLASH_Write(DeviceData, DataPtr, FromAddress, Size);

      if (Error) {

        return FALSE;

      }

      while(*OpStatus != TRUE); /* Wait while operation done */

      return TRUE;

    }

     

    bool EraseFlash(LDD_TDeviceData *DeviceData, LDD_FLASH_TAddress FromAddress, LDD_FLASH_TDataSize Size, uint8_t* OpStatus)

    {

      LDD_TError Error;

      *OpStatus = FALSE;

      Error = FLASH_Erase(DeviceData, FromAddress, Size);

      if (Error) {

        return FALSE;

      }

      while(*OpStatus != TRUE); /* Wait while operation done */

      return TRUE;

    }

     

    int main(void)

    {

      /* Write your local variable definition here */

      LDD_TDeviceData *FlashDevData;

      uint8_t OpStatus;

      bool err;

      uint8_t data[256];

      uint8_t buffer[256];

      /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

      PE_low_level_init();

      /*** End of Processor Expert internal initialization. ***/

     

      /* Initialization of FLASH controller */

      FlashDevData = FLASH_Init(&OpStatus);

     

      printf("*********************************************************\n\r");

      printf("*** DEMO project for the FLASH component - begin\n\r");

      printf("*********************************************************\n\r");

      printf("\n\r");

      printf("Project description:\n\r");

      printf("Flash memory erase, write, read example.\n\r");

      printf("\n\r");

      /* Step 0 */

      printf("+++ Step 0 - begin +++\n\r");

      printf("Description: Erase FLASH memory sector\n\r");

      err = EraseFlash(FlashDevData, FLASH_USER_AREA0_UserData_ADDRESS, FLASH_USER_AREA0_UserData_SIZE, &OpStatus);

      if (err) {

        printf(" Erase PASSED\n\r");

      }

      else {

        printf(" Erase FAILED\n\r");  

      }

      printf("+++ Step 0 - end +++\n\r"); 

      /* Step 1 */

      printf("+++ Step 1 - begin +++\n\r");

      printf("Description: Write data to FLASH memory sector\n\r");

      memset(&data, '#', sizeof(data)); /* Fill the data[] with '#' characters */

      if (err) {

        err = WriteFlash(FlashDevData, &data, FLASH_USER_AREA0_UserData_ADDRESS, sizeof(data), &OpStatus); /* Write data[] to FLASH */

      }

      if (err) {

        printf(" Write PASSED\n\r");

      }

      else {

        printf(" Write FAILED\n\r");

      }

      printf("+++ Step 1 - end +++\n\r"); 

      /*Step 2 */

      printf("+++ Step 2 - begin +++\n\r");

      printf("Description: Read and verify the written data\n\r");

      if (err) {

        err = ReadFlash(FlashDevData, FLASH_USER_AREA0_UserData_ADDRESS, &buffer, sizeof(buffer), &OpStatus); /* Read FLASH memory */

      }

      if ((err) && (!memcmp(&buffer, &data, sizeof(buffer)))) { /* Verify written data */

        printf(" Read PASSED\n\r");

      }

      else {

        printf(" Read FAILED.\n\r");

      }

      printf("+++ Step 2 - end +++\n\r"); 

      printf("\n\r");

      printf("*********************************************************\n\r");

      printf("*** DEMO project for the Flash component - end\n\r");

      printf("*********************************************************\n\r");

     

    -------------

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • FreescaleTools_and_Software
    FreescaleTools_and_Software over 11 years ago in reply to Former Member

    Hi Mehdi,

      I saw you figured out the issue on the Freescale community. I've repasted your answer below for anyone who is also looking for the answer:

     

    Mehdi

    https://community.freescale.com/message/387507#387507

    It is working now, I had to edit my routines, it looks something like this now:

     

    in events.c:

    /* ===================================================================*/

    void ProgramFlash_OnOperationComplete(LDD_TUserData *UserDataPtr)

    {

             uint8_t *OpStatus = (LDD_TUserData*) UserDataPtr;

         *OpStatus = TRUE;

    }

    -----------------------------

    bool ReadFlash(LDD_TDeviceData *DeviceData, LDD_FLASH_TAddress FromAddress, LDD_TData* DataPtr, LDD_FLASH_TDataSize Size, uint8_t* OpStatus)

    {

      LDD_TError Error;

      *OpStatus = FALSE;

      Error = FLASH_Read(DeviceData, FromAddress, DataPtr, Size);

      if (Error) {

        return FALSE;

      }

      do{

        FLASH_Main(DeviceData);

      }

      while(FLASH_GetOperationStatus(DeviceData) != LDD_FLASH_IDLE);

      return TRUE;

    }

     

    bool WriteFlash(LDD_TDeviceData *DeviceData, LDD_TData* DataPtr, LDD_FLASH_TAddress FromAddress, LDD_FLASH_TDataSize Size, uint8_t* OpStatus)

    {

      LDD_TError Error;

      *OpStatus = FALSE;

      Error = FLASH_Write(DeviceData, DataPtr, FromAddress, Size);

      if (Error) {

        return FALSE;

      }

      while(*OpStatus != TRUE); /* Wait while operation done */

      return TRUE;

    }

     

    bool EraseFlash(LDD_TDeviceData *DeviceData, LDD_FLASH_TAddress FromAddress, LDD_FLASH_TDataSize Size, uint8_t* OpStatus)

    {

      LDD_TError Error;

      *OpStatus = FALSE;

      Error = FLASH_Erase(DeviceData, FromAddress, Size);

      if (Error) {

        return FALSE;

      }

      while(*OpStatus != TRUE); /* Wait while operation done */

      return TRUE;

    }

     

    int main(void)

    {

      /* Write your local variable definition here */

      LDD_TDeviceData *FlashDevData;

      uint8_t OpStatus;

      bool err;

      uint8_t data[256];

      uint8_t buffer[256];

      /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

      PE_low_level_init();

      /*** End of Processor Expert internal initialization. ***/

     

      /* Initialization of FLASH controller */

      FlashDevData = FLASH_Init(&OpStatus);

     

      printf("*********************************************************\n\r");

      printf("*** DEMO project for the FLASH component - begin\n\r");

      printf("*********************************************************\n\r");

      printf("\n\r");

      printf("Project description:\n\r");

      printf("Flash memory erase, write, read example.\n\r");

      printf("\n\r");

      /* Step 0 */

      printf("+++ Step 0 - begin +++\n\r");

      printf("Description: Erase FLASH memory sector\n\r");

      err = EraseFlash(FlashDevData, FLASH_USER_AREA0_UserData_ADDRESS, FLASH_USER_AREA0_UserData_SIZE, &OpStatus);

      if (err) {

        printf(" Erase PASSED\n\r");

      }

      else {

        printf(" Erase FAILED\n\r");  

      }

      printf("+++ Step 0 - end +++\n\r"); 

      /* Step 1 */

      printf("+++ Step 1 - begin +++\n\r");

      printf("Description: Write data to FLASH memory sector\n\r");

      memset(&data, '#', sizeof(data)); /* Fill the data[] with '#' characters */

      if (err) {

        err = WriteFlash(FlashDevData, &data, FLASH_USER_AREA0_UserData_ADDRESS, sizeof(data), &OpStatus); /* Write data[] to FLASH */

      }

      if (err) {

        printf(" Write PASSED\n\r");

      }

      else {

        printf(" Write FAILED\n\r");

      }

      printf("+++ Step 1 - end +++\n\r"); 

      /*Step 2 */

      printf("+++ Step 2 - begin +++\n\r");

      printf("Description: Read and verify the written data\n\r");

      if (err) {

        err = ReadFlash(FlashDevData, FLASH_USER_AREA0_UserData_ADDRESS, &buffer, sizeof(buffer), &OpStatus); /* Read FLASH memory */

      }

      if ((err) && (!memcmp(&buffer, &data, sizeof(buffer)))) { /* Verify written data */

        printf(" Read PASSED\n\r");

      }

      else {

        printf(" Read FAILED.\n\r");

      }

      printf("+++ Step 2 - end +++\n\r"); 

      printf("\n\r");

      printf("*********************************************************\n\r");

      printf("*** DEMO project for the Flash component - end\n\r");

      printf("*********************************************************\n\r");

     

    -------------

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube