EasyManua.ls Logo

Intel 386

Intel 386
691 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
10-41
TIMER/COUNTER UNIT
/*****************************************************************************
Example of how to write a new initial counter value to a timer
This value can be rewritten at any time without affecting the
Counter’s programmed mode.
Before writing an initial count value, the Control Word must be
configured for the proper R/W and Count formats.
-->This example assumes that Timer1 is in the R/W format of LSB first,
then MSB, and that the Count format is binary.
_SetEXRegByte(TMR1, InitialCountL);
_SetEXRegByte(TMR1, InitialCountH);
*****************************************************************************/
/****************************************************************************/
***Example of how to issue a Read Back command for Timer2, latching
both the status and the counter.
BYTE Status, CountL, CountH, RWmode;
WORD Count;
SetUp_ReadBack(0, 0, 1, 1, 1); //Configure Read Back command for timer2,
latching both status and count
Status = GetEXRegByte(TMR2);
RWmode = Status & 0x30; //Mask off bits that correspond to the Read/Write Mode
switch (RWmode) { //Read Counter Value according to configured R/W format
case 0x10: //Read/Write least significant byte only
Count = _GetEXRegByte(TMR2);
break;
case 0x20: //Read/Write most significant byte only
CountH = _GetEXRegByte(TMR2);
Count = (WORD)CountH << 8;
break;
case 0x30: //Read/Write LSB first, then MSB
CountL = _GetEXRegByte(TMR2);
CountH = _GetEXRegByte(TMR2);
Count = (((WORD)CountH << 8) + CountL);
break;
}
*****************************************************************************/

Table of Contents

Related product manuals