2023-04-16 02:56 AM
I am using STM32CubeIDE to develop a small project. But I do not know why some code if(Motor_PullBack_Enable == 1) {} statement is not compiled.
if(Motor_Extend_Enable == 1)
{
....
}
if(Motor_PullBack_Enable == 1)
{
...
}
if(SPI_Receive_Buffer[2] != 0)
{
}
Checked project.list file. there is no this if (){} statement.
if(Motor_Extend_Enable == 1)
8000632: 4b61 ldr r3, [pc, #388] ; (80007b8 <main+0x2e0>)
8000634: 781b ldrb r3, [r3, #0]
8000636: 2b01 cmp r3, #1
8000638: d136 bne.n 80006a8 <main+0x1d0>
{
}
// there is no if(Motor_PullBack_Enable == 1)
if(SPI_Receive_Buffer[2] != 0)
Please refer to attached source code. there is no compile error. Why not compile ?
Jiannong
Solved! Go to Solution.
2023-04-16 04:44 AM
maybe the compiler/optimizer finds , this code will never be called - then it kicks it away.
+ example:
if((Movement_distance_pulse < 0) ...
but you set: uint32_t Movement_distance_pulse;
so it will never be negative...code can be removed, because if.. can never be true.
2023-04-16 04:44 AM
maybe the compiler/optimizer finds , this code will never be called - then it kicks it away.
+ example:
if((Movement_distance_pulse < 0) ...
but you set: uint32_t Movement_distance_pulse;
so it will never be negative...code can be removed, because if.. can never be true.
2023-04-16 08:08 AM
Hi AScha.3,
Yes. you are right. The code should be never implemented, it's removed.
After I re-code, the code can be seen in list file.
Thank you very much for your help!
Jiannong