Reputation: 1719
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:
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?
Upvotes: 1
Views: 667
Reputation: 19395
I've noticed that when I step over or into in the debugger, it comes to the last line of a specific timer ISR.
So, this timer ISR increments a 4-byte integer variable, and this variable overlaps with your variable. How such overlapping occurs might be revealed by inspecting that ISR or the link map, or it may be that the index register X is not correctly set in the ISR.
Upvotes: 2
Reputation: 57794
The function c_lgadc
looks like part of a runtime library. Suggested by context, it is probably an add carry flag function because it is between the compare and unsigned right shift functions.
The c_l
and c_lg
prefixes for these functions are probably some part of a scheme indicate the types of the operands or their result.
As to your question, adc
occurs in the instruction set of several CPU architectures, namely the intel x86 and motorola 680x. It means:
Upvotes: 1