This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CPU cycle random changing

Hello, i have an issue that seems to be from the compiler but i am not 100% sure. First of all the project was not made by me, but the company i work bought it from another company. As this project is related to a company i am not able to share many specific information and share a code. So i need a quide and if anyone faced a similar situation ever.

The project is running on STM32F767 and created with CubeMX. Then the main automation (application) is migrated from Cortex M4.

The problem is that randomly by a code change the cpu speed is decreased by 7-10 times. For this application this is big issue, because there are many functions and read/write to peripherals made in a full cycle of while(1) loop. To be more specific about speed decreased, i place a variable to increase in while(1) loop. In normal behaviour at 10sec the counter is at ~4000, but with speed decreased behaviour is ~500-700. Systick is running withount any problem. Also there is no Handler error. Watchdog is disabled.

The way this decreased speed is "produced", is random and the solution back to normal speed is also random. For example, the last software change i made and this problem appeared again was to add an extra check of two uint8_t variables to an if statement.

Before it was :   if(z==2)  and after change is : if( x && y && (z==2)) . This change does not affect the code execuation, as it is a part of a function that is not running yet.The solution to this "decreased speed" is either to remove this part and the code will go back to the previous version or to add a code, so the compiler build something new. For example i add : HAL_Delay(1); in main() before get to the while(1) and the problem is solved.Also this issue can occur by adding a global variable (and never use it).

I am using Keil MDK-ARM Essential Version : 5.27.1.0. Compiler/Assembler/Linker : V5.06 update 6.

STM32F767 is at 216MHz. Prefetch and ART are enabled. Optimization is zero. I Checked if any task is running in "decreased speed" version and there is not. There is also at software delay in us. This also does not produce the value that is calculated to do in "decreased speed" and produce a very big value. This is a reason that all the code is not running at normal speed, but not the main reason. I measured with DWT execution of some code where the is not delay (just if,else, for loop) and there is big difference also there.

void delay_us(int DelayValue){
uint32_t i;
i=DelayValue;

i*=70;
while(i--);
}

Has anyone faced a similar issue or can guide me in any way to search more?

Thank you.