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
Solved! Go to Solution.
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
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