Accessing variables from X- Gate

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

Accessing variables from X- Gate

Jump to solution
1,102 Views
Nycil
Contributor I

Hello All,

Am using an S12Xep100 processor. I  want to do a certain functionality on the Xgate processor to relieve the main CPU off its load. I have declared a structure which has two members one an unsigned char and another an unsigned long int(declared in the Xgate.h file). In one of the ISRs in the Xgate(written in the .cxgate file) I want to update the values of the members in the structure. The value of the unsigned char is updated ok, but the value of the unsigned int is not updated and thus an illegal breakpoint comes when debugging the true time simulator.

 

Please Help.

Thanks in Advance

 

struct mystruct{

unsigned char var1;

unsigned long int var2;

}; this is my  structure.

Labels (1)
0 Kudos
1 Solution
557 Views
kef
Specialist I

Yes, this struct should be fine without #pragma align on.

Of course all shared variables should be placed in segments with ALIGN 2[1:1] in prm file. Like this:

 

      RAM_FC        = READ_WRITE  0xFC1900 TO 0xFC1FFF ALIGN 2[1:1]; /* is also mapped to XGATE:  0xC900..0xCFFF */

View solution in original post

0 Kudos
4 Replies
557 Views
kef
Specialist I

XGATE physically can't access misaligned word. Thus XGATE compiler inserts padding bytes to align struct fields. HC12 compiler by default doesn't align struct fields. You should either swap struct fields, so that even sized field comes first. Or in HC12 part use align pragma

 

#pragma align on

.. shared variables and typedef's

#pragma align off

0 Kudos
557 Views
Nycil
Contributor I

Thanks Kef.

This is my structure.

 

struct mystruct{

unsigned char var1;

unsigned char var2;

unsigned int var3;

}

In this case is the alignment problem solved. If not, How do I solve it , so as to access the members of the structure in an ISR in the X-Gate. I would have problem accessing the var3. Is it anyway related to the prm file.

 

Please Help.

0 Kudos
558 Views
kef
Specialist I

Yes, this struct should be fine without #pragma align on.

Of course all shared variables should be placed in segments with ALIGN 2[1:1] in prm file. Like this:

 

      RAM_FC        = READ_WRITE  0xFC1900 TO 0xFC1FFF ALIGN 2[1:1]; /* is also mapped to XGATE:  0xC900..0xCFFF */

0 Kudos
557 Views
Nycil
Contributor I

Thanks Kef ... It worked ...

0 Kudos