AN2090 Freescale Semiconductor / Motorola, AN2090 Datasheet - Page 3

no-image

AN2090

Manufacturer Part Number
AN2090
Description
Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
2
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 cycles to actual time and put
all the application code together. Finally, this section explains how to adapt the stopwatch timer code to other
SC140-based devices.
2.1 Initializing the Stopwatch Timer
The C code to set up the stopwatch timer is shown in Example 1. This code contains the definitions of the emulator
memory-mapped address registers.
/*
* Header file contains definitions of EOnCE memory-mapped register addresses,
* and definition of the WRITE_IOREG() macro.
*/
#include “EOnCE_registers.h”
static volatile long EOnCE_stopwatch_timer_flag;
void EOnCE_stopwatch_timer_init()
{
}
The EOnCE_registers.h header file contains the macro definitions, such as EDCA1_MASK, which provides
each memory-mapped register’s memory address. This header file also defines the C macros: READ_IOREG() and
WRITE_IOREG(). These macros simplify the read and write operations on these registers.
To initialize the stopwatch timer, set up the Address Event Detection Channel (EDCA), which triggers the cycle
countdown. The emulator supports six EDCAs. The implementation presented in this application note uses
EDCA1, though this choice is arbitrary. To set up the EDCA, you must initialize the following four registers:
Freescale Semiconductor
Setting Up the Stopwatch Timer In an Application
32-bit EDCA reference value register A (EDCAi_REFA).
32-bit EDCA reference value register B (EDCAi_REFB).
WRITE_IOREG(EDCA1_REFA,(long)&EOnCE_stopwatch_timer_flag);
WRITE_IOREG(EDCA1_REFB,(long)&EOnCE_stopwatch_timer_flag);
WRITE_IOREG(EDCA1_MASK,MAX_32_BIT);
WRITE_IOREG(EDCA1_CTRL,0x3f06);
Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer, Rev. 1
Example 1. Event Detector Set-up Code
Figure 1. Sequence of Operations
/* Address to snoop for on XABA */
/* Address to snoop for on XABB */
/* No masking is performed in address comparison */
/* Detect writes on both XABA and XABB */
Sequence Instructions
Initialize Stopwatch
Disable Stopwatch
Enable Stopwatch
to be Timed
Setting Up the Stopwatch Timer In an Application
/*Global dummy variable*/
3

Related parts for AN2090