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

Modifying the value of variable declared as constant

Hi, I have declared the constant array for storing the data since I am having a limited RAM in lpc2214 now I want to put in the value in this array how it is possible in Keil UV3 for ARM. I have tried with doing it in,standard C way, but it dosent work. I am giving here the code example.

const int arr[12][900]
void main()
{
int i,j;
for(i=0;i<=12;i++)
{
for(j=0;j<=900;j++)
*(int *)&arr[i][j]=5;
}
}

Parents
  • "Note: that is compiler-specific, so the toolset needs changing back to ARM"

    I saw it just after posting... I really would be nice to be allowed to edit posts after submitting :-)

    Actually, in RVCT, const objects will not always be allocated into code space. For example, if you qualify the const data object as volatile, it will be allocated as a initialized, non-alterable object in RAM.

    Another, more robust approach (albeit more complex) to this would be to force the linker to allocate the array at the flash area, in a specific flash page, to be able to erase the page without destroying program code. That can be done using pragmas to declare named sections, and linker commands to allocate the sections to absolute addresses.

    Besides being very compiler-specific, all this IAP stuff is manufacturer specific, of course.

Reply
  • "Note: that is compiler-specific, so the toolset needs changing back to ARM"

    I saw it just after posting... I really would be nice to be allowed to edit posts after submitting :-)

    Actually, in RVCT, const objects will not always be allocated into code space. For example, if you qualify the const data object as volatile, it will be allocated as a initialized, non-alterable object in RAM.

    Another, more robust approach (albeit more complex) to this would be to force the linker to allocate the array at the flash area, in a specific flash page, to be able to erase the page without destroying program code. That can be done using pragmas to declare named sections, and linker commands to allocate the sections to absolute addresses.

    Besides being very compiler-specific, all this IAP stuff is manufacturer specific, of course.

Children