Comparing two variables in different ram pages

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Comparing two variables in different ram pages

Jump to solution
535 Views
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


Labels (1)
Tags (2)
0 Kudos
1 Solution
396 Views
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


View solution in original post

0 Kudos
1 Reply
397 Views
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 Kudos