AN2090 Freescale Semiconductor / Motorola, AN2090 Datasheet
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 ...