Intel 386 User Manual

Page 281

Advertising
background image

Intel386™ EX EMBEDDED PROCESSOR USER’S MANUAL

10-38

Returns:

Counter Value of specified timer

Assumptions:

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

first, then MSB

Syntax:

WORD Counter_Value;

Counter_Value = CounterLatch(TMR_1);

Real/Protected Mode:

No changes required

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

WORD CounterLatch( BYTE Timer )

{

BYTE control_word = 0;

BYTE CounterL, CounterH;

WORD Counter;

control_word = Timer << 6;

control_word &= 0xc0;

_SetEXRegByte(TMRCON, control_word); //Select which counter

switch (Timer) {

case TMR_0:

CounterL = _GetEXRegByte(TMR0);

CounterH = _GetEXRegByte(TMR0);

break;

case TMR_1:

CounterL = _GetEXRegByte(TMR1);

CounterH = _GetEXRegByte(TMR1);

break;

case TMR_2:

CounterL = _GetEXRegByte(TMR2);

CounterH = _GetEXRegByte(TMR2);

break;

}

Counter = (((WORD)CounterH << 8) + CounterL);

return(Counter);

}/* CounterLatch */

Advertising