2019-02-08 01:08 AM
I can store variables in flash memory location successfully but what is happening is updating that variable in main.c file not happening.I'm posted code what i have done below.
Linker script file :
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 153
MY_VARS (xrw) : ORIGIN = 0x08005000, LENGTH = 1K // storing in flash memory
}
.my_vars :
{
*(.MY_VARS*);
} >MY_VARS
In main.c file :
__attribute__((section(".MY_VARS"),myvars)) uint32_t *value=8;
int main()
{
int a =sum(); //i have a sum function of two numbers and storing in variable 'a'
value =&a; // value should updated to sum but it is not updating
readaddress=(const volatile uint32_t *)0x08005000;// reading flash memory
printf("Read flash address %lu\n",*readaddress);// printing the data which is stored in value ,it is printing everytime 8 but it should print variable data which stored in 'a'.
}
int sum(int a)
{
int a=1, b= 34 ;
a=a+b;
return a;
}
Can anybody help me to figure this out,i hope u understood what im asking.
Thank you
Solved! Go to Solution.
2019-02-17 10:35 PM
You could use a function pointer. The address of the function should be ODD. Confirm it's placement by reviewing the .MAP file
2019-02-17 10:50 PM
@Community member can you elaborate the answer ?
My understand is ,to create a fun pointer in the flash and excess from the project-2.
what do you mean by ODD ? why it should be odd.
2019-02-17 10:56 PM
Odd as in not even. Thumb instruction addresses are designated as odd due to the way the microcontroller decodes them. ie 0x08004001