Constant data to specified ROM address

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

Constant data to specified ROM address

Jump to solution
1,335 Views
SZheng
Contributor I

Hello,

 

I am using MC9S08SG32 and trying to write version number to a specified ROM address, how to do that? e.g. at ROM address 0x800, write version number "1.00", and from 0x8004 to store regular code.

 

Thanks,

Labels (1)
0 Kudos
1 Solution
407 Views
CrasyCat
Specialist III

Hello

 

I assume you are using CodeWarrior for MCU V6.x. Right?

I also assume you want to store the version number as a string (array of char).

 

I also assume there is  a typo in your message and string is expected at address 0x8000.

 

You need to remember that in ANSI C every string need to be terminated by a NULL character(0x00). So you need to reserve at least 5 bytes for your version number.

 

To allocate the version number at address 0x8000, define following object in one of your C source files:

 

const char Version[] @0x8000 = "1.00";

 

Then change your .prm file to ensure the linker does not allocate anything over that memory area.

Change

    ROM                      =  READ_ONLY    0x8000 TO 0xFFAD;
into

    ROM                      =  READ_ONLY    0x8005 TO 0xFFAD;
 

Link your application. That should be it.

 

CrasyCat

View solution in original post

0 Kudos
2 Replies
408 Views
CrasyCat
Specialist III

Hello

 

I assume you are using CodeWarrior for MCU V6.x. Right?

I also assume you want to store the version number as a string (array of char).

 

I also assume there is  a typo in your message and string is expected at address 0x8000.

 

You need to remember that in ANSI C every string need to be terminated by a NULL character(0x00). So you need to reserve at least 5 bytes for your version number.

 

To allocate the version number at address 0x8000, define following object in one of your C source files:

 

const char Version[] @0x8000 = "1.00";

 

Then change your .prm file to ensure the linker does not allocate anything over that memory area.

Change

    ROM                      =  READ_ONLY    0x8000 TO 0xFFAD;
into

    ROM                      =  READ_ONLY    0x8005 TO 0xFFAD;
 

Link your application. That should be it.

 

CrasyCat

0 Kudos
407 Views
SZheng
Contributor I
It works well. I appreciate your quick response!
0 Kudos