Häufig gestellte Fragen

FAQ

Why is the observed variable displayed as “not in scope” in Debug mode under the Keil development environment?  Issue Date:2015-11-02

When interrupted in Debug mode, the user wants to check the variable value but see ”not in scope” on the Watch window, as shown below:

This is because the compiler would put variables into R1 registers after optimization, but the Watch window could only get the value from the internal memory. Therefore, “not in scope” will be displayed.

 

There are three solutions:

  1. Set the variable as a global variable.
  2. Set the variable as volatile.
  3. Set ”Optimization“ of ”C/C++” in the ”Options for Target…” as ”Level 0 (-O0)”, as shown below:

Products: Microcontrollers ,Arm Cortex-M0 MCUs ,M051 Base Series ,M0518 Series ,M0519 Series ,Mini51 Base Series ,Nano100/102 Base Series ,Nano110/112 LCD Series ,Nano120 USB Series ,Nano130 Advanced Series ,NUC029 Series ,NUC100/200 Advanced Series ,NUC120/122/123/220 USB Series ,NUC130/230 CAN Series ,NUC131/NUC1311 CAN Series ,NUC140/240 Connectivity Series ,Arm Cortex-M4 MCUs ,M451 Base Series ,M451M Series ,M452 USB Series ,M453 CAN Series ,NUC442/472 Series ,NUC505 Series
Applications:
Function: Software and Tools,Development-Environment,Keil