AN2090 Freescale Semiconductor / Motorola, AN2090 Datasheet - Page 5

no-image

AN2090

Manufacturer Part Number
AN2090
Description
Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
#include “EOnCE_registers.h”
void EOnCE_stopwatch_timer_start()
{
}
The counter registers must be initialized before the stopwatch timer is triggered. Initializing the event counter
requires set up of the following three 32-bit registers:
When these initialization are complete, the C code triggers the stopwatch timer and cycle counting commences.
2.2.1 Event Counter Control
This section describes the initialization of the event counter registers. The ECNT_CTRL register controls the
behavior of the event counter. The fields of the ECNT_CTRL register are shown in Figure 3.
Table 2 describes the settings of these fields in the stopwatch timer implementation.
2.2.2 Counter Registers
ECNT_VAL is a countdown counter, and ECNT_EXT is a count-up counter. ECNT_VAL decrements on each
occurrence of an event, as specified in the control register. ECNT_EXT increments each time there is an underflow
in ECNT_VAL. For maximum cycle counting capacity, the stopwatch timer implementation initializes
ECNT_VAL to the largest possible value, which is 4294967295, or 0xFFFFFFFF. ECNT_EXT is initialized to
zero.
Freescale Semiconductor
EXT
ECNTEN
ECNTWHAT
WRITE_IOREG(ECNT_VAL,MAX_32_BIT);
WRITE_IOREG(ECNT_EXT,0);
WRITE_IOREG(ECNT_CTRL,0x12c);
EOnCE_stopwatch_timer_flag = 0;
Field
Event counter value register (ECNT_VAL)
Extension counter value register (ECNT_EXT)
Event counter control register (ECNT_CTRL)
Setting (binary
Using the SC140/SC1400 Enhanced On-Chip Emulator Stopwatch Timer, Rev. 1
value)
0010
1100
1
Figure 3. Event Counter Control Register (ECNT_CTRL)
Example 2. C Code to Start the Stopwatch Timer
Event counter operates as a 64-bit counter.
The event counter is disabled and is enabled when EDCA1 detects an event.
The counter advances on each core clock cycle.
/* Counting will be triggered by detection on EDCA1 */
/* This write to the flag triggers the counter */
Table 2. ECNT_CTRL Settings
/* Countdown will start at (2**32)-1 */
/* Extension will count up from zero */
Setting Up the Stopwatch Timer In an Application
Description
5

Related parts for AN2090