How to view the Executing time of MCU within the Debug Enviornment

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to view the Executing time of MCU within the Debug Enviornment

跳至解决方案
2,528 次查看
Harlen_CHen
Contributor I

HI Every,

I am debuging Freescale S08AW with  Codewarrior V6.2.

But, Under Debug environment, I dont know the CPU exectuing time and cycle.

SO, anyone, Know about this,

How to view the Executing time of MCU, such as ,xxms , xxus .????

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,493 次查看
bigmac
Specialist III

Hello,

 

If you can test your code using full chip simulation, this does progressively count and display the number of CPU cycles.  This can be very useful if you are attempting to reduce the number of cycles required by a function, by experimenting with different versions of the function.

 

As Lundin has indicated, external events would not be taken into account, whether within the function you are testing (perhaps as a wait loop), or the execution of ISR code within the function.  However, regular timer interrupts (overflow or output compare), will be taken into account if the timer module uses the bus clock.

 

Since the timing is in CPU cycles, the corresponding amount of time will depend on the bus frequency you are using, but can be readily calculated.  Divide the number of cycles by the bus frequency (in MHz), and you will have the time duration (in microseconds).

 

Regards,

Mac

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,493 次查看
Harlen_CHen
Contributor I

thanks your help.

0 项奖励
回复
1,493 次查看
Lundin
Senior Contributor IV
As far as I know there is no feature in the CW debugger for counting the number of instructions executed and their cycles. That would be the only way to do this since you can't measure time through a program running on Windows, Windows is not a RTOS. Also, the BDM pods have no support for time measurement.

The problem is that counting the cycles for all op-codes executed may not be accurate. For example, this doesn't take interrupt latency in account.

Instead you should set a pin to 1 when entering the code, set it to 0 when leaving. Trigger on this pin with an oscilloscope and measure the time. This way you can also measure code speed at different temperatures, voltages etc. Also, oscillator (and PLL filter) accuracy may or may not be an issue, depending on your requirements.

1,494 次查看
bigmac
Specialist III

Hello,

 

If you can test your code using full chip simulation, this does progressively count and display the number of CPU cycles.  This can be very useful if you are attempting to reduce the number of cycles required by a function, by experimenting with different versions of the function.

 

As Lundin has indicated, external events would not be taken into account, whether within the function you are testing (perhaps as a wait loop), or the execution of ISR code within the function.  However, regular timer interrupts (overflow or output compare), will be taken into account if the timer module uses the bus clock.

 

Since the timing is in CPU cycles, the corresponding amount of time will depend on the bus frequency you are using, but can be readily calculated.  Divide the number of cycles by the bus frequency (in MHz), and you will have the time duration (in microseconds).

 

Regards,

Mac

0 项奖励
回复