variable allocated in paged RAM & its unprecented behaviour

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

variable allocated in paged RAM & its unprecented behaviour

1,742 次查看
rubykrishna
Contributor III

Hi All,

 

We are using  MC9S12XHY controller.  Controller permits 8K  non paged ram and 4k  paged ram. Since  ouyrram consumption is more than 8K,  we used paged ram.

We referred the following documents for proper implementation

TN238.pdf TN240.PDF( From freescale)

 

#pragma DATA_SEG __GPAGE_SEG PAGED_RAM

static unsigned int a=23;

static unsigned int b=35;

#pragma DATA_SEG DEFAULT

 

We verified from the .map file and variables are allocated in the Paged RAM  segment.

we also faced problem while copying values between two paged ram variables

 

While using this variables in runtime, we observed unprecedented behavior in these RAM variables.  To sum it up, if we allocate these variables  in non paged ram, we didnt face any issue.

标签 (1)
标记 (1)
0 项奖励
回复
6 回复数

1,578 次查看
RadekS
NXP Employee
NXP Employee

Hi ruby,

please be aware, there is compiler/linker optimization.

When two variables are located in the same banked non default segment, Compiler/Linker suppose that they are in the same page and remove paging operations.

You could disable this optimization.

Go to project settings (Alt+F7), Compiler for HC12, Code Generation, check “Assume object are in same page for” and change settings to “never for different ojects”. Or you could simply add “-PSegObj” into Compiler Command Line Arguments.

PSegObj.png


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,578 次查看
kef2
Senior Contributor V

Radek,

since Ruby is using __GPAGE_SEG and all RAM fits the same GPAGE segment, there's no need to worry about -PSegxxx switch, all settings must be fine. Ruby's issue must be somewhere else.

Regards,

Edward

0 项奖励
回复

1,578 次查看
RadekS
NXP Employee
NXP Employee

Hi Edward,

You are right, I missed that point.

Ruby,

Could you please share with us your code for operations with these variables (copy,..)?

Best Regards,
RadekS

0 项奖励
回复

1,578 次查看
kef2
Senior Contributor V

Are these variables used in more than one C file? If so, then in your header file you need to surround these variables with the same #pragma DATA_SEG 's. This is necessary to make compiler aware about required addressing mechanism.

Are you using __RPAGE_SEG variables? These may need changing compiler's "Code Generation"->"Assume object are in same page for"  setting.

0 项奖励
回复

1,578 次查看
rubykrishna
Contributor III

Hi Edward,

They are are static variables and they are not used  as extern more than one .c file.

but we pass  those variables by value or  reference(Address of the variables)  via functions to other.c files.

we are using __GPAGE_SEG as per guidelines TN238.PDF!

0 项奖励
回复

1,578 次查看
kef2
Senior Contributor V

Then perhaps required far pointer qualifier is missing?

void foo(int * far aa);

Paged variables are fine in CW.

0 项奖励
回复