Disassembly looks funny and doesn't correspond with C code
Edit: Sorry, forgot details.
STM32F042G6
Debugging using ST-LINK V2
Versions (now upgraded):
Ac6 C/C++ Debugging Tools for MCU v.1.11.2 (was v1.80.)
Ac6 C/C++ Embedded Development Tools for MCU v.1.12.0 (was v.1.8.0)
Ac6 Linker Script Editor v.1.11.0 (was v.1.7.0)
GNU Tools ARM Embedded (for windows 32bits) v.1.7.0
Open OCD (for windows 32 bits) v.1.8.0
I’m having issues when debuging, because alltough my project compiles fine and I can load it on the mcu, when I start debugging I notice in the disassembly it looks funny and does not correspond with the C code.
For example it has more than one occurance of code for line 103 and 104:
103 adc_val = HAL_ADC_GetValue(&hadc);
08002e98: movs r0, r7
08002e9a: bl 0x80006f8
08002e9e: ldr r4, pc, #76 ; (0x8002eec )
104 HAL_GPIO_TogglePin(GPIOB, LED_Pin);
08002ea0: movs r1, #1
103 adc_val = HAL_ADC_GetValue(&hadc);
08002ea2: str r0, r4, #0
104 HAL_GPIO_TogglePin(GPIOB, LED_Pin);
08002ea4: ldr r0, pc, #52 ; (0x8002edc )
08002ea6: bl 0x8000d10
while (1) { /* USER CODE END WHILE */ uint16_t rawValue; float temp; adc_val = HAL_ADC_GetValue(&hadc); HAL_GPIO_TogglePin(GPIOB, LED_Pin); HAL_Delay(500); /* USER CODE BEGIN 3 */ HAL_ADC_PollForConversion(&hadc_temp, HAL_MAX_DELAY); HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY); rawValue = HAL_ADC_GetValue(&hadc_temp); adc_val = HAL_ADC_GetValue(&hadc); temp = ((float)rawValue) / 4095 * 3300; temp = ((temp - 760.0) / 2.5) + 25; } /* USER CODE END 3 */ }
When I try to step past what is line 16 here
adc_val = HAL_ADC_GetValue(&hadc);
it jumps back to start of while loop again. It is also true that there is no reference to the code
temp = ((float)rawValue) / 4095 * 3300;
temp = ((temp - 760.0) / 2.5) + 25;
in the disassembly.
I suspect the dissasembly may be from an earlier version of the code where the adc part was not added yet. But it seems to compile fine and generates new output files if I clean the code and rebuild the whole project.
Any insight? Appreciate it, Thanks.
Edit: If I change the delay value the LED blinks faster so the code compiles and is loaded, nothing old about it.