This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Program Memory Constants

Note: This was originally posted on 22nd July 2013 at http://forums.arm.com

I am using a Cortex-M0 with Keil uVision4.  How are constants located in program memory and how can these program memory constants be changed by code?
Parents
  • Note: This was originally posted on 24th July 2013 at http://forums.arm.com

    What is it that you're trying to accomplish?

    If they change then they are not really constants; if the code is running and you change the constants (say, from a debugger) then there's no guarantee that the code will still work.  For example two functions might share part of a constant literal.  It might be better to store the values in variables.

    The compiler has various ways encoding constants.  A constant might be part of an instruction, a piece of data in the same section as code or as a separate (read only) data section.

    Changing a constant at runtime (once you've located it) might be simple if it's in RAM or tricky if it's in FLASH.
Reply
  • Note: This was originally posted on 24th July 2013 at http://forums.arm.com

    What is it that you're trying to accomplish?

    If they change then they are not really constants; if the code is running and you change the constants (say, from a debugger) then there's no guarantee that the code will still work.  For example two functions might share part of a constant literal.  It might be better to store the values in variables.

    The compiler has various ways encoding constants.  A constant might be part of an instruction, a piece of data in the same section as code or as a separate (read only) data section.

    Changing a constant at runtime (once you've located it) might be simple if it's in RAM or tricky if it's in FLASH.
Children
No data