intFlash - Destructive write

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

intFlash - Destructive write

1,891 Views
SofTA
Contributor I
Hi experts,
 
Question: when I use destructive write in intFlash bean, will the dustructive write affect only the memory cell (e.g. a byte) that I am going to write, or the action will affect the whole section where is cell located?
 
Currently, I removed a page (8000-2080) in prm file, reserving the section for using intFlash to write a few constants. Since I am running out of memory space, I am thinking define a const byte array (which should be allocated to ROM, or flash memory area) in my code and use intFlash destructive write to update the contents in the array. I tried. It seems working but my program sometimes freezes. I am not sure it is caused by my scheme. Insights and opinions?
 
Many thanks.
 
SofTA
Labels (1)
0 Kudos
4 Replies

506 Views
SofTA
Contributor I
Dear Vojtech,
 
Thank you very much for the insight solution. I tried and it worked great. Now I can verify where the data are saved and now I do not need to reseve a whole page for saving the constants. I hope other visitors also find this solution working for them.
 
Best regards,
SofTA
 
PS. I set my array 514 bytes just for the safe side that my code will not be damaged by the erase operation.
0 Kudos

506 Views
SofTA
Contributor I
Hi experts,
 
I really need you guys opinions. I previously view memory in simulator in page view mode. When I switch to flash view I can see my const data did have been saved to address 0x00000 to 0x0006A. But it seems there is no problem for port A and etc to work correctly. I guess the flash memory address is transparent to PC. So, am I utilizing the flash memory that are normally not used? Any insight about the this phenomena (or whatever)?
 
SofTA
0 Kudos

506 Views
ProcessorExpert
Senior Contributor III
"Destructive write (with erase)" write method erases actual sector if it is necessary (without any data backup) and after that data is written into the FLASH. This information can be found in the
help (pop-up menu) of IntFlash bean on page properties in section "Write method".

The problem may be related to declaration of const variable bytMyFlashPage. If it is not located explicitly to an absolute address, linker will chose the location itself (can be found in the map file). However the location of the variable may be close to the program code and not aligned with the flash sector boundary. Since flash erase sector size is 512 byte, destructive write may erase part of the code or other variables as well. I would recommend to put the bytMyFlashPage variable to an absolute address to control the location, where the flash memory is erased and written.

const byte bytMyFlashPage[256]@0x8000;

best regards
Vojtech Filip
Processor Expert Support Team
UNIS

0 Kudos

506 Views
SofTA
Contributor I
Hi experts,
 
I found what caused my program freeze. It is not related to IntFlash bean. But I also found the IntFlash bean (SetPage) does not save my constants to the const byte array I created. In fact I don't know where it saves the constants now. My statement is "err=MyFlash_SetPage(MyFlash_DataPtr2Addr(bytMyFlashPage)". bytMyFlashPage[256] is a const byte array. when I step through the code, I found the Addr passed is 0 (not the 0x6FEB the array resides), and the start address for writing to/reading from flash is LPA2=0, LPA1=0, LPA0=0. I checked the memory window in simulator and found nothing changed at address 0x00. But both SavePage and GetPage do work. I can save my constants and retrieve them. So, my question is where the data are saved?
 
PS. In my previous scheme, I reserved page 0 (0x8000-0x2080) from compiling and used SetPage(0x8000) to save data. in that scheme I could see the data had been saved to 0x8000. Now with my new scheme, I could not find where the data were saved. Can someone give me a suggestion to find out the location? I will not feel comfortable to run my code without knowing where the data are saved.
 
Thanks!
0 Kudos