This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Can't write data into flash memory of LM3S8962.

Other Parts Discussed in Thread: EK-LM3S8962, LM3S8962

Hi all,

I am using the EK-LM3S8962. I want to store some bytes in its on chip flash memory. The problem is bytes are written at different location then mentioned in FMA register, so I can't read it back.

Anyone with any idea??

Thanks,

Harsh.

 

  • Hi,

    I can give you an example program from TI to emulate an EEPROM - works OK on LM3S8962 and other micros.7331.Eeprom-Emulation..ZIP

    Petrei

  • Hi Petrei,

    Thanks for the help. I am trying above example but is there any other way to do??

    I've attached my program. As per datasheet, I've used Flash Control registers (FMA and FMD etc..).

    What is going wrong with it???

    Thanks again..

    Harsh..

      void write_flash(void)
      {
         FLASH_USECRL_R = 19;         // I am using 20 MHz clock
         FLASH_FMA_R = 0x4;           // offset = 0x4
         FLASH_FMD_R = 0x44444444;    // data to write in flash = 0x44444444
         FLASH_FMC_R = (FLASH_FMC_WRKEY | FLASH_FMC_WRITE);  // WRITE bit = 1 in FMC register
         
         while(FLASH_FMC_R & FLASH_FMC_WRITE);       // polling WRITE bit of FMC register
        
      }

  • Hi,

    I gave you that AN and the code to be examined and used as you wish -  and learn how to do it your way. Important things to note however is the initialization code where you must set the clock for flash, correlated with system clock (and this is most important to get a working program). Also, other useful routines are ready, such as erasing a page, aligning for a page and of coarse execution timing to be known, especially as function of time (this was important to me since I used this for production). 

    I will examine your code later and come back.

    Petrei

  • Hi,

    I have read your code - but suggest to use the routines provided by TI in driverlib/flash.c file  - mainly it is wise to plan to write to a page at the top of the flash and first step is to use this function to initialize your flash internal hardware:

    FlashUsecSet(SysClockGet()/1000000); // seems you have done that

    and then use the function FlashProgram(*pulData, ulAddress, ulCount) - or at least read carefully the source code of this function in flash.c file - take care of waiting loop needed to accomplish the programming time.

    As for reading - read as this:

    *pulData = (*(unsigned long*)pulAddress);

    Petrei