Setting global variable in debugger appears to have no effect

I am unsuccessful in running dosomething(); in the following extract when using breakpoints on analogRead() and if and then setting the global variable val to 1000:

int val = 0;
val = analogRead(C4);
if (val > 900) {

A breakpoint on dosomething() never triggers.

What am I missing?

What kind of board are you using?

platform = ststm32
board = genericSTM32F103C8
board_build.f_cpu = 36000000L
framework = arduino
upload_protocol = stlink
debug_tool = stlink

I never really experienced any problems with debugging an STM32 (other than an ESP32). As in all MCUs, the number of breakpoints is limited. I think the STM32F103 has 6 breakpoints, one of which is used for single stepping and similar.

After reading your question again, I’m unsure what you are trying to do and what really happens:

  • What’s the story with setting val to 1000? Are you setting it in the debugger? Or what exactly are you doing?
  • Do breakpoints work but they don’t work when you change the value of val?
  • Or do breakpoints not work at all?

I am attempting to have the program branch into the if condition by setting val > 900 manually in the debugger (i.e. Run / Variables sidebar), overwriting the value set by analogRead().
Breakpoints work.

I’ve tried it myself and it’s working without problem.

For my test, I set two breakpoints: one on the if statement line and one on the doSomething() line. When the debugger stopped on the if statement line, I set val to 1000. Then I clicked the Continue icon and the debugger stopped on doSomething() as expected.

Does your setup look the same? At what line is your debugger stopped when you change the variable?