asm ("nop") instruction execution efficiency in XMC series

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Kris_Ke
Level 1
Level 1
Distributor - WPG(GC)
5 replies posted 25 sign-ins 5 questions asked

Dear 

I use XMC4200 to verify the execution efficiency of "NOP".

But I'm seeing a gap in execution time. For example, I using Dave's way of doing 2 NOPs instruction.

All settings are optimized using -Os.

optimiz.PNG


The first one uses the For loop

07.png

It's need take 5.767us.

Tek007.jpg

 

The second uses ten nop instructions.

 

08.png

 

It's need take 727.689ns.

 

Tek008.jpg

 

 

 

I also use Keil to do same test.

The first one uses the For loop

02.png

It's need take 2.078us.

Tek002.jpg

 

The second uses ten nop instructions.

03.png

It's need take 430.206ns.

Tek003.jpg

 

 

Dave and Keil may be the difference caused by the compiler, but will the NOP instruction also have such an impact?

The difference of the same 10 nop instructions is nearly 300ns

I didn't change the setting of SystemInit(void) in startup, so it should use the highest frequency of 80Mhz.

 

I also use Nuvoton's ARM M4 NUC480 series to do the same experiment.

https://www.nuvoton.com/products/microcontrollers/arm-cortex-m4-mcus/m487-ethernet-series/

And I had modify the CPU clock frequency PLL to 80Mhz

Kris_Ke_0-1672286363910.png

 

I use Keil to do same test. 

The first one uses the For loop

09.png

It's need take 727.689ns.

Tek009.jpg

 

The second uses ten nop instructions.

10.png

 

It's need take 187.643ns.

Tek010.jpg

 

 Tool   Dave Keil
  Frequency  FOR loop Ten nop instructions FOR loop Ten nop instructions
XMC4200 80MHz 5.767us 727.689ns 2.078us 430.206ns
M487 80Mhz - - 728.689ns 187.643ns

 

What kind of restrictions are there, thank you.

I have not compared the time difference of addition, subtraction, multiplication and division at present, but the instruction time of NOP will be different at the same frequency. And I haven't compared the difference between moving the NOP instruction to ram for execution.

 

Thanks,

Kris

0 Likes
1 Solution
jsmith678x
Level 4
Level 4
100 sign-ins 25 replies posted First solution authored

Check your 'arm instruction cycle count' in your code . You have two code both are required different instruction cycles. Also note on Cortex-M you cannot have exact delay with instructions.

Check your assembly codes and add the instruction cycles. Both sums are different.

 

View solution in original post

0 Likes
2 Replies
jsmith678x
Level 4
Level 4
100 sign-ins 25 replies posted First solution authored

Check your 'arm instruction cycle count' in your code . You have two code both are required different instruction cycles. Also note on Cortex-M you cannot have exact delay with instructions.

Check your assembly codes and add the instruction cycles. Both sums are different.

 

0 Likes
Owen_Su
Moderator
Moderator
Moderator
250 solutions authored 500 replies posted 50 likes received

    This thread will be closed due to long time no reply, you can create a new one if you have any other questions, thanks for your understanding.

Regards,

Owen

0 Likes