Timer/Counter Unit Code Examples - Intel 386 User Manual

Embedded microprocessor
Table of Contents

Advertisement

Intel386™ EX EMBEDDED PROCESSOR USER'S MANUAL
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
Mode
Inputs
Output
InitCount
Enable
10-34
Unit number of the timer. The processor supports 0, 1 or 2
Defines Counter Mode
Specifies Input sources
Specifies Which Output to drive
Value to be loaded into count register
Enable (1) or disable (0) Timer

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Intel386 exIntel386 extbIntel386 extc

Table of Contents