Comparing two variables in different ram pages

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

Comparing two variables in different ram pages

跳至解决方案
1,297 次查看
lucianopalacios
Contributor I

Hello,

 

for my project with MC9S12XF512, I'm trying to compare two variables which are in different ram pages. When I debug it I can see in Data window that the value of both variables are equal but the comparison results false.

 

Here a code example of this problem

 

#pragma DATA_SEG PAGED_RAM

uint8 variable1 = 0xff;

 

#pragma DATA_SEG DEFAULT

uint8 variable2 = 0xff;

 

void main(void)

{

  volatile uint8 aux = 0;

 

  while(1)

  {

    if( variable1 == variable2 )

    {

      aux = 1;

    }

    else

    {

      aux = 2;

    }

  }

}

 

 

The result is always "aux = 2". What would be the right way to compare these variables?

 

Many thanks in advance.

Best regards


标签 (1)
标记 (2)
0 项奖励
回复
1 解答
1,158 次查看
lucianopalacios
Contributor I

I read AN3784 and I have to do the following:

"

Variables in Banked RAM

Before accessing a banked RAM location, the compiler needs to insert instructions that write an appropriate

value into the RPAGE register. The syntax to instruct the compiler to do this is:

#pragma DATA_SEG __RPAGE_SEG PAGED_RAM

"

I tried with this correction and it's working now.

Regards


在原帖中查看解决方案

0 项奖励
回复
1 回复
1,159 次查看
lucianopalacios
Contributor I

I read AN3784 and I have to do the following:

"

Variables in Banked RAM

Before accessing a banked RAM location, the compiler needs to insert instructions that write an appropriate

value into the RPAGE register. The syntax to instruct the compiler to do this is:

#pragma DATA_SEG __RPAGE_SEG PAGED_RAM

"

I tried with this correction and it's working now.

Regards


0 项奖励
回复