problem with compiler and pass-parameter - 9S08AW48 - USB multilink - CW6.2

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

problem with compiler and pass-parameter - 9S08AW48 - USB multilink - CW6.2

跳至解决方案
1,478 次查看
girmauro
Contributor I
Hi,
I'm working with 9S08AW48 micro with CodeWarrior 6.2, USB multilink interface for HCS08 and my embedded target.

I've a problem with the compiler options (I think) and the parameter passed to / from a function; the instructions, for example, are:

    Key = CheckKeyPressed();
    SendDataToLCD(Key);
    SerialPC_SendChar(Key);

(I've already tried to declare the variable "Key" static and file global, function-internal, but nothing)

The function "CheckKeyPressed" calculates the correct value: this value will be returned by "return KeyPressed", but the value I will see after the returning, is different from that one that i see in the function just before exiting.

The code for CheckKeyPressed() is:

function CheckKeyPressed() {
  // variable declaration ...

  index = getReg8(PTGD) & 0x0F;
   
  KeyPressed = Keyboard[index];

  return KeyPressed;    //KeyPressed has the correct value...
 
}

Key = CheckKeyPressed();  //"Key" receives a wrong value...

I've tried to check the "Disable Optimizations" flag in the Compiler tab of the "Edit->Standard Setting" menu, but no change in the simulation occurs.
Can anyone help me? I think there are some problems related to compiler optimisation and parameter-passing.

Thanks in advance for any suggestion.

Girmauro
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
773 次查看
CompilerGuru
NXP Employee
NXP Employee
Make sure you do not have any implicit parameter declarations. The compiler issues a warning for those, so make sure you do not ignore the warning.
Passing characters around is only possible with proper function prototypes.
So in your sample code, show the complete signatures of the functions.

Daniel

在原帖中查看解决方案

0 项奖励
回复
1 回复
774 次查看
CompilerGuru
NXP Employee
NXP Employee
Make sure you do not have any implicit parameter declarations. The compiler issues a warning for those, so make sure you do not ignore the warning.
Passing characters around is only possible with proper function prototypes.
So in your sample code, show the complete signatures of the functions.

Daniel
0 项奖励
回复