I'm programming an STM8S microcontroller using STVD IDE. It uses the COSMIC compiler.
I found that there is a veriable that is increased unexpectedly. When debugging I found that there is a line in the assembly code that causes this variable to increase its value. It's a function named c_lgadc
. Sometimes this assembly line is called while there is no ADC
related function is shown in the call stack.
I don't understand where this code comes from and what is this c_lgadc
? I have no function in my C code named c_lgadc
Here is a screenshot of the disassembly.
UPDATE:
- I don't know what C code should I examine as the call stack is different every time this disassembly line is called.
- I've noticed that when I step over or into in the debugger, it comes to the last line of a specific timer ISR.
- I've also noticed that the line with the second breakpoint is the one that causes addition to my variable. The line with first breakpoint is called always 5 times then the line with second breakpoint is called once and so on.
- I'd like to know how should I debug this further to prevent the unexpected addition to my variable.
UPDATE2:
I found the following in the map file
:
c_lgadc 0000f39c defined in (C:\Users\xxxxxxxx\CXSTM8\Lib\libm0.sm8)lgadc.o section .text
used in Debug\stm8s_it.o
I'm not sure if this would help in clarifying the problem?