cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103xE execution problem depending of the global variables declared. Adding some new variables, depending the types, the execution is not more identical. I am using STM32F103xE device with STM32CubeIDE.

jgost.1
Associate

My problem is the following, when I declare new globales variables depending the types, there are some executions as an ADC convertion for example, which make more time to be executed and the result is incorrect (65535).

I wonder if there is limitation on the data embeded into an application, on the stack of execution and how to find out the problem.

I have tried to declare long or unsigned long and the behaviour is different! With the signed long the behaviour is correct and with the unsinged long I am in front of the problem.

I have tried to compare .map file to see if the memory allocation is changing. Of course it is changing but I am not able to understand the difference and how to interprete the issue. 

I have not compilation problem at all.

The memory use show me :

0693W000000UHPwQAO.png

So I am a bit confuse why this such behaviour happens!

Should I configure something in my settings in order to avoid such behaviour?

Your comments are welcome. Thank you in advance.

Julien

1 REPLY 1
berendi
Principal

Using DMA requires correct volatile and memory barrier usage. The HAL library does neither, so the results are unpredictable when any compiler optimization is in effect.

Switching all optimizations off (-O0) might help, but severely impact performance.

Check every line of your software for possible buffer overflows, incorrect volatile or pointer usage.

Check all interrupt handlers and callbacks that they do only atomic variable accesses, and call only functions that are explicitly documented as safe to call from interrupt handlers (HAL functions except the handlers are not).