Debug code falsely seeing memory as 0 until I break in the debugger
Schrodinger's Memory: In debug my STM32F407VG Discovery code is seeing zeros in an array loaded using DMA (which is working), but if I break and single step, the code suddenly see's the values. Super weird! I´m using STM32CubeIDE which was fully updated 2 days ago.
int16_t in[32]; // Buffer which receives samples from the ADC via DMA (good data values arrive)
int16_t inC[32];
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
uint32_t iC = 0;
// This code runs in debug with >0 values in in[0] and the loop doesn´t break. If I add a break point
// and single step it breaks out immediately. I rebooted but it stays the same.
// If I remove the 0 loop, it runs and sometimes the buffer has zeros but mostly good values.
// HAL_ADC_ErrorCallback() is not called.
while(in[0] == 0) {
iC++; } // Wait for data to appear. Shouldn't be needed.
memcpy((void*)inC, (const void*)in, sizeof(inC)); // Copy to processing buffer
}
