‎2021-09-21 12:29 AM
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.
Solved! Go to Solution.
‎2021-09-21 02:32 AM
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]
‎2021-09-21 12:59 AM
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
‎2021-09-21 01:58 AM
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.
‎2021-09-21 02:11 AM
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.
‎2021-09-21 02:12 AM
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..
‎2021-09-21 02:28 AM
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.
‎2021-09-21 02:32 AM
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]
‎2021-09-21 02:37 AM
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. :smiling_face_with_smiling_eyes:
‎2021-09-21 02:51 AM
Nice, if i could support you, we are all here to help each other.
And there are no stupid questions - only stupid answers, right?
‎2021-09-21 03:01 AM
Rightly so!
I'm glad to be part of this community.