Intel 386 User Manual

Page 282

Advertising
background image

10-39

TIMER/COUNTER UNIT

/*****************************************************************************

ReadCounter:

Description:

This function performs a simple read operation on the specified

timer. However, because the counter value is not latched, the timer

must be disabled, read, and then re-enabled.

Parameters:

Timer

Unit number of Timer whose count is being read

Returns:

Counter value that was read

Assumptions:

This function assumes that the R/W format is configured to be LSB

first, then MSB

Syntax:

WORD Counter_Value;

Counter_Value = ReadCounter(TMR0);

Real/Protected Mode:

No changes required

*****************************************************************************/

WORD ReadCounter(BYTE Timer)

{

BYTE CountL, CountH;

WORD Count = 0;

DisableTimer();

switch (Timer) {

case TMR_0:

CountL = _GetEXRegByte(TMR0);

CountH = _GetEXRegByte(TMR0);

break;

case TMR_1:

CountL = _GetEXRegByte(TMR1);

CountH = _GetEXRegByte(TMR1);

break;

Advertising