Tool/software: Code Composer Studio
Hi Everybody,
I want to save parameters into main memory and/or info memory.
i tried both memories
in main memory:, in debug mode, i've managed to write and read into the memory.
but, at runtime the data isn't change or isn't correct (can't write and can't read)
in info memory, in both debug and runtime i can't write and read.
maybe it's configuration problem?
for now, i'm saving one char, but i'll need to save more chars and shorts parameters.
here's the code for this problem (with information memory):
void LoadParameters()
{
short m1,m2;
ReadFromFlash((char*)0x1040,(char*)&cnt_by_idx);// Count_By
if( cnt_by_idx < 0 || cnt_by_idx > COUNT_BY_ARR_LEN - 1)
cnt_by_idx = 3;
}
void SaveParameters()
{
WriteToFlash((char*)0x1040,(char)cnt_by_idx);// Count_By
}
void WriteToFlash(char* address, char val)
{
char* flash_ptr;
FCTL3 = FWKEY;
flash_ptr = address; // Initialize Flash pointer
while(FCTL3 & BUSY);
FCTL1 = FWKEY + WRT;
*flash_ptr = val;
while(FCTL3 & BUSY);
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
}
void ReadFromFlash(char* address, char* val)
{
char* flash_ptr;
flash_ptr = address;
while(FCTL3 & BUSY);
*val = *flash_ptr;
}