cancel
Showing results for 
Search instead for 
Did you mean: 

Getting "Error: Target not available" in Value column in live expressions in StmcubeIDE in debug mode when i press Resume(F8)

Alden Kuljici
Associate III

I created a simple GPIO program with the code generated from StmCubeMX. When i build the program there are no errors and warnings, but when i connect my Nucleo-F411RE and try to debug it, i get this message in Expressions.

The program is supposed to make LED2 go off when i press the Blue button (LED2 is on by default by this code) and it works, i see LED2 turn off when i press the button, and goes back on when i release it, but in Expressions i don't see this. When i press Resume the value should be 1 and when i press the button to go to 0. Instead i get the error.0693W00000DnuFCQAZ.png0693W00000DnuEsQAJ.png

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

I don't know his course, but you can easily solve it by using Live Expressions:

First of all, the explanation: you added the variable to the Expressions window, probably with Add Watch Expression. However, as previously mentioned, this only shows the status at a breakpoint, i.e. when the program run has been stopped.

If you want to see variables at runtime, you have to add them to the Live Expressions window, which you can make visible with

Window > Show View > Live Expressions

There you then insert the variable using copy'n'paste. After starting the debugger with F11, you switch to this window and start with F8. The current value of the variable should now be visible.

[edit]Forgot to mention, that this only works with global variables, i.e. declared outside of main(), as you already did in your program.[/edit]

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

9 REPLIES 9
Peter BENSCH
ST Employee

This happens if you add the variable while the program is running without being stopped by breakpoints.

Please note that the variables in the Expressions window are only updated when the debugger has the opportunity to update them. However, F8 continues to run the program and does not return control to the debugger.

Please set a breakpoint on e.g. line 18, start debugging with F11 and, as soon as HAL_Init () is visible, the program with F8. If you have not already done so, add the variable and execute the program step by step with F6 (Step Over), which should update the variable.

Good luck!

If the problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Alden Kuljici
Associate III

So i added the variable, i added the breakpoint to line18, pressed F11 and now the Current Instruction Pointer is on HAL_Init () and the value is 1, then i press F8 the Instruction Pointer is on line 18 but when i press the blue button LED2 doesn't go off and the value doesn't toggle to 0.0693W00000Dnv8gQAB.png

Please note: the CPU has stopped at the breakpoint and is waiting for the next command.

When the breakpoint is reached, the button has not yet been queried. The next time you press F8, the status is read in again in your program and then output on the LED.

So you first have to press and hold the user button and then press F8 to read in the new button status.

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Alden Kuljici
Associate III

Btw, i'm taking a course from Israel Gbati and in the lecture he doesn't use any breakpoints. He enters debug mode, the pointer reaches the function HAL_Init (), he adds the value buttonStatus, presses the Resume(F8) button and he toggles the blue button, and so does the value, switching from 1(default) to zero when releasing the button.

I'm following all the steps he makes yet something is wrong, and it bothers me quite..

Did this but now my LED2 remains off and it doesn't react to me pressing the blue button, nor does the value switch to zero, while the Intruction pointer staying at the breakpoint on line 18.

Another thing, when i press the reset button then LED2 goes back on and reacts to toggling of the blue button but the value doesnt switch.

It behaves like the Value in expressions isn't linked to the commands of the blue button.

Peter BENSCH
ST Employee

I don't know his course, but you can easily solve it by using Live Expressions:

First of all, the explanation: you added the variable to the Expressions window, probably with Add Watch Expression. However, as previously mentioned, this only shows the status at a breakpoint, i.e. when the program run has been stopped.

If you want to see variables at runtime, you have to add them to the Live Expressions window, which you can make visible with

Window > Show View > Live Expressions

There you then insert the variable using copy'n'paste. After starting the debugger with F11, you switch to this window and start with F8. The current value of the variable should now be visible.

[edit]Forgot to mention, that this only works with global variables, i.e. declared outside of main(), as you already did in your program.[/edit]

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thanks a lot, this was my mistake all the time, i should have used Live Expressions.

I'm sorry for bothering you, i'm new to this, so hope you won't mind. 😊

Nice, if i could support you, we are all here to help each other.

And there are no stupid questions - only stupid answers, right?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Rightly so!

I'm glad to be part of this community.