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.

Need example code for writing data to flash in TM4C123GH6PGE

Other Parts Discussed in Thread: TM4C123GH6PGE

Hi All,

Is there any example code for writing the data into flash in Tiva controllers. Kindly share.

Regards,

Aravind

  • Hello Aravind,

    To write the data into flash there is no example explicitly to do that. The reason being that most of the code examples are meant to run from Flash and the debugger does that. However of you still want to write to the flash, then you have to do the following steps

    1. Write the Address to write to into the FLASH_FMA register

    2. Write the Data to write to the address into the FLASH_FMD register

    3. Then start the actual write by writting to the FLASH_FMC register 0xA4420001 where 0xA442 is the Key and 0x1 is the Write bit. To check the completion poll the FLASH_FMC.WRITE bit. if it is 0 then the operation has completed.

    More information about this is in the Internal memory section of the Data Sheet

    Regards

    Amit

  • Thanks for answering my query Amit. Let me check this first and in case of any query will get back to you.

    Regards,

    Aravind

  • I would like to join the conversation Amit.


    I am interested in rewriting the Flash with a new software. Thus, I would like running version to load a new version from an SD card, in bin/hex format.


    Questions:


    1. Is that possible to do on the tm4c123gh6pge?

    2. Is there any example that you are aware of showing how to write the hex/bin into micro-controller?

    Thank you in advance.

    Elad

  • Hello Elad

    To understand what you are saying:

    1. You need to reflash the TM4C123x device with a new software that is loaded in a SD Card
    2. When you press a switch, the image from sd-card is copied into the TM4C123x and flashed, subsequently causing the TM4C123x to run the new program.
  • Dear Amit,

    1. You are correct, I would like to reflash the TM4C123x device with a new software that is load in an SD card on my OEM board.
    2. Yes, when the software is instructed, by entering a code through keypad for example, the software will reflash itself and run the new software.

    Any examples you can provide as starting point?

    Thanks in advance.

    Elad
  • Hello Elad

    Thanks for the confirmation. The closest I have is a TM4C129x reference design where the image is copied from a SD Card to SDRAM and executed. But in principle the same can be used for internal Flash update.

    www.ti.com/.../TIDM-TM4C129SDRAMNVM

    In TivaWare there is usb_stick_demo and usb_stick_update which uses USB stick to perform the same task

    D:\ti\TivaWare_C_Series-2.1.3.156\examples\boards\dk-tm4c123g\usb_stick_demo
    D:\ti\TivaWare_C_Series-2.1.3.156\examples\boards\dk-tm4c123g\usb_stick_update
  • The USB Stick Update example is very close to what I had in mind. I will go through it and implement it into my software.

    Thanks a million for the help.

    Elad
  • Hello Elad

    Glad the resource was useful.