Skip to main content
tohru-sagayama
Associate
March 23, 2015
Question

How to watch variables in CubeMX

  • March 23, 2015
  • 2 replies
  • 677 views
Posted on March 23, 2015 at 08:53

Hello.

I'd like to know how to refer values of variables.

My understanding is all of variables are seen in a variable scope when I stop a program, but at the moment, I can't look at some variables I defined.

Could someone teach me how to figure out the problem ?

Regards
    This topic has been closed for replies.

    2 replies

    takahasi
    Visitor II
    March 23, 2015
    Posted on March 23, 2015 at 09:57

    Use optimization level 0 (-O0).

    joe
    Associate III
    March 27, 2015
    Posted on March 27, 2015 at 11:07

    If using optimization Level 0(-O0) doesn't work you can try making the variables you want to watch volatile.

    /*declaration*/

    volatile uint8_t var;

    You could also have a define specifically for debugging:

    #define _DEBUGGING_

    #ifdef _DEBUGGING_

    volatile uint8_t var;

    #else

    uint8_t var;

    #endif

    Level 0 shouldn't optimize out variables but I have seen it happen.