1

On a STM8S, using the config files, on one hand I have (stm8s.h file)

typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus, BitStatus, BitAction;

and, in one of my functions (fonctions.c file), I have

BitStatus minutes = RESET;

Yet, when I run the code in Debug mode and watch minutes, it shows me the value "3" at this point (where it should show RESET or at least "0". I don't understand why, and since I use this value for a test later I can't guarantee the result.

This happens for every other types defined there, with the exception of one flag which is a global variable. I've tried declaring the variable as static, changing the place of .h inclusion, didn't seem to work and I have no idea what to do to correct the problem.

EPikk
  • 11
  • 1
  • 1
    Does it change something if you change `SET=1` instead of `SET=!RESET`? – mch Jul 16 '20 at 08:43
  • Might be optimization interfering with your debugging. I would say don't worry about it and don't trust the values the debugger shows you too much. If you want to be really sure, try declaring the variable you are watching as `volatile` and see if it behaves as you expect. – th33lf Jul 16 '20 at 08:48
  • Can you print the value to make sure it's not the debugger that tricks you? – Support Ukraine Jul 16 '20 at 08:50
  • does the startup code set the .data segment correctly? – 0___________ Jul 16 '20 at 08:51
  • Are those variables actually used in the code? If you don't use them and only watch in a debugger, the compiler and/or debugger can do funny things to confuse you. – Gerhardh Jul 16 '20 at 10:01

0 Answers0