Accessing variables from X- Gate

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

Accessing variables from X- Gate

跳至解决方案
1,284 次查看
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.

标签 (1)
0 项奖励
回复
1 解答
739 次查看
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 项奖励
回复
4 回复数
739 次查看
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 项奖励
回复
739 次查看
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 项奖励
回复
740 次查看
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 项奖励
回复
739 次查看
Nycil
Contributor I

Thanks Kef ... It worked ...

0 项奖励
回复