do-while loop leads to false disassembly and hanging in release-mode
STM32L052C8T3/ STM32CubeIDE:
In search of the causes of excessive power consumption, I had the firmware compiled for release mode. This caused the program to hang in the first while loop.
The cause is an incorrect compilation. I cannot resolve this and would like to know what I am doing wrong.
Written in C
...
intcontent=0;
do
{
intcontent=adcdone;
}
while (intcontent==0);
...
Disassambly in debug mode:
...
intcontent=adcdone;
08000eb2: ldr r3, [pc, #204] ; (0x8000f80 <MainMeasureVoltage+304>)
08000eb4: ldrb r3, [r3, #0]
121 while (intcontent==0);
08000eb6: cmp r3, #0
08000eb8: beq.n 0x8000eb2 <MainMeasureVoltage+98>
...
Disassambly in release mode:
...
08000e3e: ldr r3, [pc, #168] ; (0x8000ee8 <MainMeasureVoltage+264>)
08000e40: ldrb r3, [r3, #0]
08000e42: cmp r3, #0
08000e44: bne.n 0x8000e48 <MainMeasureVoltage+104>
08000e46: b.n 0x8000e46 <MainMeasureVoltage+102>
...
Result:
Programming is hanging in: 08000e46: b.n 0x8000e46 <MainMeasureVoltage+102>
