Intel386™ EX EMBEDDED PROCESSOR USER’S MANUAL
10-34
• With the readback command:
— If both the status and counter values are latched, the user can read the value of the
Read/Write selection bits from the status register to know what bytes of the counter
value are being latched in the TMRn register.
— If only the counter value is latched, you must know the Read/Write selection before the
counter value can be read correctly.
• When a read-back command is issued to latch both the counter and the status of a timer, the
TMRn register holds both of these values. The first read of TMRn accesses the status byte
and the next one or two reads (depending on the R/W format) of TMRn access the timer’s
counter value.
10.4.1 Timer/Counter Unit Code Examples
The example code contains these software routines:
InitTimer Initializes the specified timer’s mode, counter value, inputs, and outputs
SetUp_ReadBack Configures the specified timer(s) for a read-back command
CounterLatch Latches the counter value of the specified timer
ReadCounter Performs a simple read command on the specified timer’s current counter
value
TimerISR Interrupt Service Routine for timer-generated interrupts
Code is also included that demonstrates how to change the timer’s counter value and issue a read-
back command. See Appendix C for included header files.
#include <conio.h>
#include “80386ex.h”
#include “ev386ex.h”
/*****************************************************************************
InitTimer:
Description:
This function initializes a timer’s inputs, outputs, operating mode,
and initial counter value.
Parameters:
Unit Unit number of the timer. The processor supports 0, 1 or 2
Mode Defines Counter Mode
Inputs Specifies Input sources
Output Specifies Which Output to drive
InitCount Value to be loaded into count register
Enable Enable (1) or disable (0) Timer