Comparing two variables in different ram pages

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

Comparing two variables in different ram pages

ソリューションへジャンプ
1,198件の閲覧回数
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,059件の閲覧回数
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,060件の閲覧回数
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 件の賞賛
返信