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

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

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

Jump to solution
1,018 Views
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
Labels (1)
Tags (1)
0 Kudos
1 Solution
313 Views
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

View solution in original post

0 Kudos
1 Reply
314 Views
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 Kudos