cancel
Showing results for 
Search instead for 
Did you mean: 

TrueSTUDIO reports unbelievable variable values. Yet code behaves as if variable values were as expected. Why? [SOLVED]

Rstua.1
Senior

I have been using TrueSTUDIO for about 2 months and so far when I hover over a variable in stopped code the value is reported as expected. But today I had a bout with TrueSTUDIO where many of the checked variables contained unbelievable values. However, the code written to make decisions based on these variables continued to work as expected. As if only TrueSTUDIO was "out of the loop" with respect to the actual variable values.

What is going on?

I switched to using STMStudio. While I can not debug using STMStudio I can see the affected variable. While in TrueSTUDIO these variables contained Unbelievable data. But in STMStudio these variables contained the expected values.

Why?

The variables which continued to contain values as expected in TrueSTUDIO were part of my own code directly called from main(). Most if not all the variables which contained unbelievable data were part of the USB communication code. I am not sure, but data in those variables might be traceable back to interrupt driven code.

1 ACCEPTED SOLUTION

Accepted Solutions
Rstua.1
Senior

Hi @Community member​ ,

Thanks for you ideas.

It turned out a watch dog timer continued to run while TrueSTUDIO had stopped at a break in my code. I assume the watch dog timer reset and / or affected the USB variables in unexpected ways. This also explains why STMStudio was able to display the expected USB values as the watch dog timer would have been kicked during normal code execution. To verify, I temporarily commented out the code to start the watch dog timer and was able to debug the USB code using TrueSTUDIO without issue.

View solution in original post

3 REPLIES 3

Optimizer may hold the variables' values in registers, or they may be optimized out altogether. The debugger is not perfect.

JW

Rstua.1
Senior

Hi @Community member​ ,

Thanks for you ideas.

It turned out a watch dog timer continued to run while TrueSTUDIO had stopped at a break in my code. I assume the watch dog timer reset and / or affected the USB variables in unexpected ways. This also explains why STMStudio was able to display the expected USB values as the watch dog timer would have been kicked during normal code execution. To verify, I temporarily commented out the code to start the watch dog timer and was able to debug the USB code using TrueSTUDIO without issue.

Makes sense.

Thanks for coming back with the solution. Please select your post as "Best" so that the thread is marked as solved.

JW