Hello!
I'm used to work with .prm file to define segments. But now I'm working with MCF51QE, since it's a ColdFire MCU, it has no longer a .prm files instead it's got a .lcf file.
I can't understand it....
If some could explain me it would be great because I'd like to learn about it. If you don't want to waste time explaining I just need to know how to define a new FLASH segment.
What I want to do is save data into this new FLASH segment. I'm using routines from AN3942SW. I want this segment to be 1024bytes long.
And one more question... I just want to be sure about this: When erasing flash, it is erased by blocks of 512bytes, right?
Thanks!!!! Best Regards!
Hello
Please use separate posts when you have different questions,
Some people may only have answer to one question and will not answer a post where you encapsulate multiple questions.
On .lcf file syntax, you can find some documentation on linker file syntax in {Install\MCU\Help|PDF\MCU_ColdFire_Compiler.pdf in chapter ELF Linker and Command Language.
Basically you define a new flash area by adding a new line in the MEMORY block.
For example:
MEMORY { ... my_flah (RX) : ORIGIN = 0x20000000, LENGTH = 0x00020000 }
This defines a block of memory starting at address 0x20000000 and which has a length of 0x20000 bytes.
Then you can place some sections in that segment in the SECTIONS block.
SECTIONS { ... .myCode : {} > my_flash }
CrasyCat
Thanks for your replay CrasyCat.
Sorry about the other question, I was thinking about that and didn't realize that it's got nothing to do with the post.
I thought it would be "harder" to define a new section, because in the .lcf file, inside each section there are many things I don't understand. I'll try what you say and if I find another question, I'll let you know.
Thanks again!
Here am I again!
Well, I still couldn't accomplish what I want to do.
All I want is to define a segment in FLASH where I can store constant data.
This is what I've done:
MEMORY { myflash (RX) : ORIGIN = 0x00000410, LENGTH = 0x00000400 code (RX) : ORIGIN = 0x00000810, LENGTH = 0x00007AF0 userram (RWX) : ORIGIN = 0x00800000, LENGTH = 0x00002000}SECTIONS { .userram : {} > userram .code : {} > code .myDATA : {} > myflash
Then I want a constant named const1 inside .myDATA and I do this:
#pragma CONST_SEG myDATA const word const1;#pragma CONST_SEG DEFAULT
But const1 appears at and address in RAM. Why's that???
The only way I managed to put it in flash is by setting its address as:
#pragma CONST_SEG myDATA const word const1 @0x00000410;#pragma CONST_SEG DEFAULT
Thanks a lot in advance!!!!
Hello
First if you are defining a constant you better define it with an initialization value.
Otherwise the compiler does not consider it is a constant.
Then using following notation you can place the variable in user defined section named myData:
#pragma define_section myDataSec "myData" far_absolute R__declspec(myDataSec) const word const1 =6;
Then you should get the constant const1 allocated in section myData.
CrasyCat
Well after a loooooot of reading and breaking my head against the wall with trial and error, I've manage to accomplish my task.
this post was very very useful!!!
Thanks for your reply CrasyCat!
Well, I couldn't still make it work.... I guess I may be missing something.
I'll explain a little more what I want to do. Please, excuse my english. I've got an application that needs to store some data in FLASH, I'm working with MCF51QE96. As code is also in flash, I want to define an area where I will later store data, so I can erase it and not erase the code.
I went to the LCF file and found this:
MEMORY { code (RX) : ORIGIN = 0x00000410, LENGTH = 0x00007AF0 userram (RWX) : ORIGIN = 0x00800000, LENGTH = 0x00002000} .... other stuff ..... .userram : {} > userram .code : {} > code
This was my first time dealing with LCF. And I changed it to be like this:
MEMORY { myflash (RX) : ORIGIN = 0x00000410, LENGTH = 0x00000400 code (RX) : ORIGIN = 0x00000810, LENGTH = 0x00007AF0 userram (RWX) : ORIGIN = 0x00800000, LENGTH = 0x00002000} .... other stuff .... .userram : {} > userram .code : {} > code .myDATA : {} > myflash
I've not idea if this is right... What I ment to do is define a new memory section called "myDATA" wich starts at address 0x410 and it contains 0x400 bytes (two FLASH blocks of 512bytes)
then inside one of my files I did as you said:
#pragma define_section myDataSec "myflash" far_absolute R__declspec(myDataSec) const dword FLASH_CODE = 0xFFFFFFFF;
And I found 2 things:
1- on .xMAP files FLASH_CODE does not appear (it is used in several parts of my code)
2- when debugging FLASH_CODE appears at address 0x00
Further infromation, all I want to do is erase/write flash area so I can store data using burst_prog and page_erase routines.
As I said before, the strange thing is that if I define as:
const dword FLASH_CODE @0x410;
I can perfectly used burst_prog and page_erase. Then go to address 0x410 (in debugger) and data is written. But if I enter "FLASH_CODE" in the Data component, it appears as UNDEFINED. Also not appearing in .xMAP
But I don't want to used it this way because I've got to keep track of address and size, in order to not overlap with other constatns
Please, help!
There is some info in this thread:
https://community.freescale.com/message/23661#23661
And also my experience here: