cancel
Showing results for 
Search instead for 
Did you mean: 

How to watch variables in CubeMX

tohru-sagayama
Associate II
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
2 REPLIES 2
takahasi
Associate II
Posted on March 23, 2015 at 09:57

Use optimization level 0 (-O0).

joe
Associate II
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.