Home > other >  About the keil optimization level
About the keil optimization level

Time:12-13

Use of the chip is stm32f407ve ucos_iii, keil5

I in the program so that several assignment statement
The # define Speed 6400
Speed1=Speed;
Vx1=Speed1;

Program, vx1 Speed1 data types is uint32_t data type is float,
Encountered such a problem now, it is after the assignment vx1 has a value of 0.5;
Appear this phenomenon because, I have a few global variables in the procedure by uint16_t type changed to uint32_t,
Later I try casts vx1=(float) Speed1; No effect
Try to direct assignment vx1=6400; Vx1=6400.0 f; No effect


But the following several attempts to get the correct value
1, the data type of the vx1 instead uint32_t
2, the optimized level to optimize in the keil
3, assign a value of the other, 6399, 800 and other values are not problems,

The third try the above let me confused, so why not only 6400 this value? (not may also have other values, but I don't have each experiment)
Thinking should be due to the application problem of the space, be optimized result, but is not very understand, any predecessors to solve

Thank you very much

CodePudding user response:

Can't just look at this a few words, but also see the vx1 behind ever used, the principle of optimization is not to change the o as a result, only each other assignment of words is sometimes hard to understand how he optimization
  • Related