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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
1,534 Views
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 .????

Labels (1)
Tags (1)
0 Kudos
1 Solution
499 Views
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

View solution in original post

0 Kudos
3 Replies
499 Views
Harlen_CHen
Contributor I

thanks your help.

0 Kudos
499 Views
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.

500 Views
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 Kudos