IAR variable "l" was set but never used error analysis, iarvariable
Variable "l" was set but never used
Warning [Pe550]: variable "xxxx" was set but never used
For example:
Void fx (void)
{
UINT8I;
I =P;
........................
}
If you define a local variable, a warning "variable definition, but not used" will be reported !, And the variable is not assigned a value. It is easy to confuse people. If you do not carefully read the warning, debugging may be poor for half a day.
UINT8I;
Void fx (void)
{
I =P;
........................
}
After you change the variable to a global variable, no warning will be given.
Or addVolatileAfter that, the compilation will pass. This is related to the compiler library.
UINT8I;
Void fx (void)
{
VolatileUINT8I;
I =P;
........................
}
I am unable to receive the result because the serial receive is processed during the interruption.
Is it because this variable is still being searched.
I don't know why.
The development and debugging environment provided by IAR, Embedded Workbench, supports the C language or assembly language program debugging of MSP430 single chip microcomputer, and can perform software and hardware simulation. It is a powerful weapon for developing the application of MSP430 single chip microcomputer, however, some problems are also found.
Variables in function or macro calls in IAR Embedded Workbench must be defined as global variables. For example, the following program calls the float area floating point variable of macro S (r, the program must be defined as a global variable to run properly.
# Include "io430.h"
// Macro definition with Parameters
# Define PI 3.14
# Define S (r) PI * (r)
Float area;// Global variable
Void main ()
{
Int r;
R = 3;
Area = S (r); // call a macro
}
If the variable is defined as a local variable as in the following program, the following prompt appears:
Warning [Pe550]: variable "area" was set but never used F: \ MSP430 program \ test \ main. c 10
At the same time, the program cannot run normally.
# Include "io430.h"
// Macro definition with Parameters
# Define PI 3.14
# Define S (r) PI * (r)
Void main ()
{
Int r;
Float area;// Local variable
R = 3;
Area = S (r );// Call the macro
}
Similarly, when calling a function as an expression, the variables used must also be defined as global variables. For example, the variable k in the following program calls the int GetMax (int x, int y) function ), if you define it as a local variable, the above prompt will also appear, and the program cannot run normally.
// Call a function as an expression
Int GetMax (int x, int y );
Int k;
Int main (void)
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
Int m, n;
M = 9;
N = 10;
K = GetMax (m, n );// Call a function
}
Int GetMax (int x, int y)
{
If (x> = y) return x;
Else return y;
}
I tested two versions of IAR Embedded Workbench, V7.4 and V7.1.