Hi, I'm new to mpc555.
Are there any sample code available about storing and accessing const data in internal flash of MPC555?
Or any reference stuff that I could check?
Thanks!
Solved! Go to Solution.
Hello Hood.
There is not anything special about storing and accessing constants in CodeWarrior for MPC5xx.
1) if you use default project settings the target "Internal ROM" link all constants into ".rodata" (or "sdata2") section. E.g.:
snippet of .lcf file :
----------------------
MEMORY {
ram : org = 0x003f9800
rom : org = 0x00000000 // desired ROM address (boot address for 555)
}
...
GROUP : {
.text (TEXT) ALIGN(0x1000) : {}
.rodata (CONST) : {
*(.rdata)
*(.rodata)
}
.ctors : {}
.dtors : {}
extab : {}
extabindex : {}
} > rom // for ROM images, this can be 'rom' if you want to execute in ROM
// or 'ram' if you want to execute in RAM
...
main.c:
--------
...
const char my_const_array[]="Hello World!";
const char my_const_char='x';
void main()
{
char i;
i = my_const_array[0];
i = my_const_char;
...
2) if you want to place separate group of constants into specific custom section of Internal flash you should update.lcf and use #pragma section in the source code. E.g.:
snippet of .lcf file :
-----------------------
MEMORY {
ram : org = 0x003f9800
rom : org = 0x00000000, len = 0x10000// desired ROM address (boot address for 555)
my_rom : org = 0x00010000, len = 0x100
}
SECTIONS {
.reset : {} > rom
.init : {} > rom
.my_rom_sect (CONST) : {} >my_rom
...
main.c:
--------
...
#pragma push
#pragma section sconst_type const_type ".my_rom_sect" ".my_rom_sect"
const char my_const_char='x';
const char my_const_array[]="Hello World!";
#pragma pop
void main()
{
Stanish
Hello Hood.
There is not anything special about storing and accessing constants in CodeWarrior for MPC5xx.
1) if you use default project settings the target "Internal ROM" link all constants into ".rodata" (or "sdata2") section. E.g.:
snippet of .lcf file :
----------------------
MEMORY {
ram : org = 0x003f9800
rom : org = 0x00000000 // desired ROM address (boot address for 555)
}
...
GROUP : {
.text (TEXT) ALIGN(0x1000) : {}
.rodata (CONST) : {
*(.rdata)
*(.rodata)
}
.ctors : {}
.dtors : {}
extab : {}
extabindex : {}
} > rom // for ROM images, this can be 'rom' if you want to execute in ROM
// or 'ram' if you want to execute in RAM
...
main.c:
--------
...
const char my_const_array[]="Hello World!";
const char my_const_char='x';
void main()
{
char i;
i = my_const_array[0];
i = my_const_char;
...
2) if you want to place separate group of constants into specific custom section of Internal flash you should update.lcf and use #pragma section in the source code. E.g.:
snippet of .lcf file :
-----------------------
MEMORY {
ram : org = 0x003f9800
rom : org = 0x00000000, len = 0x10000// desired ROM address (boot address for 555)
my_rom : org = 0x00010000, len = 0x100
}
SECTIONS {
.reset : {} > rom
.init : {} > rom
.my_rom_sect (CONST) : {} >my_rom
...
main.c:
--------
...
#pragma push
#pragma section sconst_type const_type ".my_rom_sect" ".my_rom_sect"
const char my_const_char='x';
const char my_const_array[]="Hello World!";
#pragma pop
void main()
{
Stanish