When I try to pass arguments in a function it does not work properly?

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

When I try to pass arguments in a function it does not work properly?

1,776 次查看
jessemayfield
Contributor I

I have a function declared as follows:

void Build_API_Tx_Frame ( unsigned char frame_type, unsigned char *payload, unsigned char, payload_size);

{

Tx_Frame_Type = frame_type;

...

No need to type the rest  of the function here...

...

}

 

When I call this function in my main routine, Tx_Frame_Type does not get passed correctly, it retains a value of zero when I step through in the debugger.

The other arguments being passed, *payload, and payload_size are passing and updating as expected.

 

Any help would be greatly appreciated.

标签 (1)
0 项奖励
回复
3 回复数

1,502 次查看
trytohelp
NXP Employee
NXP Employee

Hello Jesse,

What is the toll version used and the architecture (device) ?

For my understanding it should be linked to an optimization.

Can you check how the Tx_Frame_Type variable is declared ?

      - is it global function or local one ?

      - can you try to defined it as volatile ?

          in some case the volatile keyword breaks the optimization

Have a great day,
Pascal
NXP Technical Support

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,502 次查看
jessemayfield
Contributor I

Tx_Frame_Type is declared as "unsigned char" and is global variable.

I am using Codewarrior IDE v5.9.0.

The processor being used is "MC9S12C128".

I will try to define Tx_Frame_Type as volatile - just for confirmation - the syntax for this would be as follows:

volatile unsigned char Tx_Frame_Type = 0;   ?

Thanks in advance!

0 项奖励
回复

1,502 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi,

if Tx_Frame_Type is global variable, I suggest you add it to ENTRIES section in prm file to avoid optimization. see how does it work?

pastedImage_0.png


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复