Constant data to specified ROM address

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Constant data to specified ROM address

ソリューションへジャンプ
2,059件の閲覧回数
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,

ラベル(1)
0 件の賞賛
返信
1 解決策
1,131件の閲覧回数
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 件の賞賛
返信
2 返答(返信)
1,132件の閲覧回数
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 件の賞賛
返信
1,131件の閲覧回数
SZheng
Contributor I
It works well. I appreciate your quick response!
0 件の賞賛
返信