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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
1,475件の閲覧回数
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 解決策
770件の閲覧回数
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 返信
771件の閲覧回数
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 件の賞賛
返信