AnsweredAssumed Answered

S32 compiler problem?different code running time with different optimization options

Question asked by Blade Zhang on May 8, 2018
Latest reply on May 9, 2018 by Jiri Kral

I pulled up a pin level and set a idle loop(1200 times)  and then pull down the pin level. The pin level is measured by a scope. I found a problem of code running time which might be relevant to S32 optimation options.

 

Here are the code:

 

      SIU.GPDO[73].R=1;      //pull up the pin 73

 

      

      for(ticker2=0;ticker2<1200;ticker2++)
      {

      

      }   //idle loop for 1200 times

 

      SIU.GPDO[73].R=0;      //pull down the pin 73

 

The system clock was set to 120MHz, so I thought the high level should be longer than 10us. However, when the optimization was chosed to None(-o0) the high level time of pin73 is about 330us! And when the optimization was chosed to Optimize(-o1) the high level time of pin73 is about 36us which I think is rational. And when the optimization was chosed to Optimize most(-o3) the high level time of pin73 is about 50ns which I think the idle is totally ignored by the compiler.

 

Question: The same code was also tested by CodeWarrior and the result is OK. So I think it might be relevant to the S32 compiler. 

 

Outcomes