Struggling with what is probably a simple command to define and initialise a flash variable in main.c (IAR Embedded Workbench / TI MSP430F)
I have a flash routine In a separate C file (Battery_Store.c) which takes in a variable (from main) and stores it in a set location. The flash routines function.
void Set_Battery_Store( unsigned int Battery_Status )
{
Flash_Start() ;
Flash_Erase_Segment( (unsigned int *)&Battery_Status ) ;
Flash_Write_Word( (unsigned int *)&Battery_Status, Battery_Status ) ;
Flash_Finish() ;
}
I define the variable and initialise it in the same C file
const volatile unsigned int Battery_Status @ 0x1070 = 1 ;
and in the .h
extern const volatile unsigned int Battery_Status ;
But of course every time I call Battery_Store from main (System_Flags.Battery_Status is a different variable handled in main). i.e.
Set_Battery_Store (System_Flags.Battery_Status) ;
Battery_Status becomes 1 again, presumably because of the
const volatile unsigned int Battery_Status @ 0x1070 = 1 ;
How do I set and initialise Battery_Status from within main.c (and not within Battery_Store.c and Battery_Store.h) and have Battery_Store.c refer to it?