cancel
Showing results for 
Search instead for 
Did you mean: 

Some code is not compiled with STM32CubeIDE

Jiannong Zhou
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Chief III

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.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
AScha.3
Chief III

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.

If you feel a post has answered your question, please click "Accept as Solution".
Jiannong Zhou
Associate II

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