Constant data to specified ROM address

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Constant data to specified ROM address

跳至解决方案
2,021 次查看
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,093 次查看
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,094 次查看
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,093 次查看
SZheng
Contributor I
It works well. I appreciate your quick response!
0 项奖励
回复