AN2090 Freescale Semiconductor / Motorola, AN2090 Datasheet - Page 7

no-image

AN2090

Manufacturer Part Number
AN2090
Description
Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
typedef enum { EONCE_SECOND, EONCE_MILLISECOND, EONCE_MICROSECOND } tunit;
unsigned long Convert_clock2time(unsigned long clock_ext, unsigned long clock_val, short
option)
{
}
2.5 Putting it All Together
Example 5 shows the stopwatch timer using the routines described so far.
The calls to the stopwatch timer functions can be made from different locations in the application code, not
necessarily from within one subroutine. The
EOnCE_stopwatch_timer_stop
modules as desired.
Freescale Semiconductor
unsigned long result;
switch(option)
{
}
return result;
case EONCE_SECOND:
case EONCE_MILLISECOND:
case EONCE_MICROSECOND:
default: result=0;
result= clock_ext*MAX_32_BIT/CLOCK_SPEED + clock_val/CLOCK_SPEED;
break;
result= clock_ext*MAX_32_BIT/(CLOCK_SPEED/1000)
break;
result= clock_ext*MAX_32_BIT/(CLOCK_SPEED/1000000)
break;
break;
long clock_ext,clock_val,clock_cycle,time_sec;
EOnCE_stopwatch_timer_init(); /* Execute once per program execution */
EOnCE_stopwatch_timer_start();
/*
EOnCE_stopwatch_timer_stop(&clock_ext, &clock_val);
time_sec = Convert_clock2time(clock_ext, clock_val, EONCE_SECOND);
EOnCE_stopwatch_timer_start();
/*
EOnCE_stopwatch_timer_stop(&clock_ext, &clock_val);
time_sec = Convert_clock2time(clock_ext, clock_val, EONCE_SECOND);
* Code whose execution time is measured goes here
*/
* Code whose execution time is measured goes here
*/
Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer, Rev. 1
...
...
...
...
...
+ clock_val/(CLOCK_SPEED/1000);
+ clock_val/(CLOCK_SPEED/1000000);
Example 4. C Code for Clock-Cycle-to-Time Conversion
() can be called more than once to measure the time consumed in different
...
Example 5. Use of Stopwatch Timer Functions
EOnCE_stopwatch_timer_start
/* error condition */
Setting Up the Stopwatch Timer In an Application
() and
7

Related parts for AN2090