AN2090 Freescale Semiconductor / Motorola, AN2090 Datasheet

no-image

AN2090

Manufacturer Part Number
AN2090
Description
Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
© Freescale Semiconductor, Inc., 2000, 2005. All rights reserved.
Freescale Semiconductor
Application Note
Using the SC140/SC1400 Enhanced
On-Chip Emulator Stopwatch Timer
By Kim-Chyan Gan and Yuval Ronen
A stopwatch timer is an apparatus for measuring the exact
duration of an event. Measuring code execution time on a DSP
is useful to identify opportunities for code optimization, to
understand system loading, and to compare execution speeds of
different processors.
This application note presents techniques for implementing a
stopwatch timer on DSPs based on the StarCore™
SC140/SC1400 cores using the built-in features of the enhanced
on-chip emulation module (known as EOnCE or OCE10),
hereafter referred to as the emulator.
Although many devices with embedded DSPs provide
application-specific timer blocks, these timers cannot be used
for debugging without interference from the application itself.
The ability to use the enhanced emulator as a stopwatch timer
gives us non-intrusive timing capabilities. This application note
describes how to set up the stopwatch timer using the SC140
code in an application or using the Metrowerks®
CodeWarrior® debugger.
Code examples illustrate the use of the stopwatch timer on the
SC140 Software Development Platform (SDP). Minor
configuration changes are needed to apply the techniques to
other SC140-based devices. The necessary modifications are
also described in this application note.
1. This application note was written for the Beta v.1.0 release
of Metrowerks CodeWarrior. Screen captures of
CodeWarrior tools may vary in future versions.
1
CONTENTS
1
1.1
1.2
1.3
2
2.1
2.2
2.3
2.4
2.5
2.6
3
3.1
3.2
4
4.1
4.2
5
5.1
5.2
6
7
Stopwatch Timer Basics ..........................................2
Features ...................................................................2
Resources ................................................................2
Implementation .......................................................2
Setting Up the Stopwatch Timer In an Application 3
Initializing the Stopwatch Timer .............................3
Starting the Stopwatch Timer .................................4
Stopping the Stopwatch Timer ................................6
Converting Cycles to Actual Time ..........................6
Putting it All Together ............................................ 7
Adapting Stopwatch Timer Code to
SC140 Devices ........................................................8
Setting Up the Stopwatch Timer In the
Debugger................................................................. 8
Initializing the Stopwatch Timer .............................8
Stopping the Stopwatch Timer ..............................11
Setting Up the System Clock Speed .....................12
Setting Up the PLL in Software ............................13
Setting Up the PLL in Hardware ...........................14
Verifying Correct Set-up .......................................14
Using the LED on the SDP ...................................14
Testing the Stopwatch Timer ................................15
Conclusion ............................................................ 16
References .............................................................16
Rev. 1, 1/2005
AN2090

Related parts for AN2090

AN2090 Summary of contents

Page 1

... Debugger................................................................. 8 Initializing the Stopwatch Timer .............................8 3.1 Stopping the Stopwatch Timer ..............................11 3.2 Setting Up the System Clock Speed .....................12 4 Setting Up the PLL in Software ............................13 4.1 Setting Up the PLL in Hardware ...........................14 4.2 Verifying Correct Set-up .......................................14 5 Using the LED on the SDP ...................................14 5.1 Testing the Stopwatch Timer ................................15 5.2 Conclusion ............................................................ 16 6 References .............................................................16 7 AN2090 ...

Page 2

Stopwatch Timer Basics 1 Stopwatch Timer Basics This section presents the features of the emulator stopwatch timer and the resources required for implementation. The capabilities of the stopwatch timer are also explained. 1.1 Features The emulator stopwatch timer provides the ...

Page 3

Setting Up the Stopwatch Timer In an Application This section describes how to initialize, start, and stop the stopwatch timer within an application. The sequence of operations is shown in Figure 1. Additionally, this section discusses how to convert ...

Page 4

Setting Up the Stopwatch Timer In an Application • 32-bit EDCA mask register (EDCAi_MASK). • 16-bit EDCA control register (EDCAi_CTRL). 2.1.1 Event Detector Control The EDCA1_CTRL register controls the behavior of the EDCA. The fields of the EDCA1_CTRL register are ...

Page 5

Example 2. C Code to Start the Stopwatch Timer #include “EOnCE_registers.h” void EOnCE_stopwatch_timer_start() { WRITE_IOREG(ECNT_VAL,MAX_32_BIT); WRITE_IOREG(ECNT_EXT,0); WRITE_IOREG(ECNT_CTRL,0x12c); /* Counting will be triggered by detection on EDCA1 */ EOnCE_stopwatch_timer_flag = 0; /* This write to the flag triggers the counter */ ...

Page 6

Setting Up the Stopwatch Timer In an Application 2.3 Stopping the Stopwatch Timer The C code to stop the stopwatch timer is shown in Example 3. Example 3. C Code to Stop the Stopwatch Timer #include “EOnCE_registers.h” void EOnCE_stopwatch_timer_stop(unsigned long ...

Page 7

Example 4. C Code for Clock-Cycle-to-Time Conversion typedef enum { EONCE_SECOND, EONCE_MILLISECOND, EONCE_MICROSECOND } tunit; unsigned long Convert_clock2time(unsigned long clock_ext, unsigned long clock_val, short option) { unsigned long result; switch(option) { case EONCE_SECOND: result= clock_ext*MAX_32_BIT/CLOCK_SPEED + clock_val/CLOCK_SPEED; break; case EONCE_MILLISECOND: ...

Page 8

Setting Up the Stopwatch Timer In the Debugger 2.6 Adapting Stopwatch Timer Code to SC140 Devices The stopwatch timer implementation controls the emulator by writing to its memory-mapped registers. The addresses of these registers are determined in the memory map ...

Page 9

... E NABLE NABLED AFTER Figure 5 shows the event detection settings after these steps are performed. For details on emulator configuration in the CodeWarrior tools, refer to [3]. Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer, Rev. 1 Freescale Semiconductor Setting Up the Stopwatch Timer In the Debugger > ...

Page 10

Setting Up the Stopwatch Timer In the Debugger 3.1.2 Setting Up the Event Counter The event counter is configured to the mode described in Section 2.2.1, Event Counter Control, on page 5, except that this time the configuration occurs in ...

Page 11

Stopping the Stopwatch Timer The stopwatch timer stops when execution of the application halts at a breakpoint. Set up the breakpoint at the point in the application where you want such halts to occur. When the breakpoint is in ...

Page 12

Setting Up the System Clock Speed Figure 7. Event Counter Dialog Box When Debugger Halts at Breakpoint 4 Setting Up the System Clock Speed Every SC140-based device contains a phase lock loop (PLL) to control operating frequency. The frequency of ...

Page 13

Setting Up the PLL in Software The clock frequency of the SC140/SC1400 core can be set up in either software or hardware. This section describes how to set up the core in the Software Development Platform (SDP) to operate ...

Page 14

Verifying Correct Set-up With these configurations, the F chip Fchip The PLL should be configured so that the resulting PLL output frequency is in the range specified in the device’s technical data sheet. 4.2 Setting Up the PLL in Hardware ...

Page 15

EOnCE_LED_init() { *((long *)EE_CTRL) &= ~(3<<2); /* Toggle EE1 when event1 happens */ } 5.1.2 Toggling EE1 The initialization previously discussed the set up of EE1 to toggle each time an event is detected by EDCA1. The same channel ...

Page 16

Conclusion cycle_req = CLOCK_SPEED*10; EOnCE_stopwatch_timer_start(); do { READ_IOREG(ECNT_VAL,clock_cycle); clock_cycle = MAX_32_BIT - clock_cycle;/* Minus max value due to count down */ } while (clock_cycle <= cycle_req); EOnCE_stopwatch_timer_stop(&clock_ext, &clock_val); /* Stop timer, return bit 63-0 EOnCE_LED_off(); time_sec = Convert_clock2time(clock_ext, clock_val, EONCE_SECOND); ...

Page 17

NOTES: Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer, Rev. 1 Freescale Semiconductor References 17 ...

Page 18

References NOTES: Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer, Rev Freescale Semiconductor ...

Page 19

NOTES: Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer, Rev. 1 Freescale Semiconductor References 19 ...

Page 20

... P.O. Box 5405 Denver, Colorado 80217 1-800-441-2447 or 303-675-2140 Fax: 303-675-2150 LDCForFreescaleSemiconductor@hibbertgroup.com Document Order No.: AN2090 Rev. 1 1/2005 Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document ...

Related keywords