beautypg.com

Description, Programming – Remote Processing RPC-330 User Manual

Page 43

background image

MULTI-MODE COUNTER

SECTION 13

Page 13-1 RPC-330

DESCRIPTION

Both 24 bit multimode counters are capable of up/down,
binary, divide-by-n, and quadrature inputs. C ount
frequency is DC to 20 M hz. The R PC-330 uses an LSI
Com puter Syste ms LS 7166. Its data sheet is foun d in
Appendix C.

The COU NT function and statements are used to read
from and wr ite to the counters. COU NT(0) and
COU NT 0 are used to read and write from P 2.
COU NT( 1) and C OUN T 1 ar e used to re ad and wr ite
from P3. LINEB is used to program the chips for
various oper ating modes.

Interrupts, using ON ITR, may be detected on a carry,
borr ow, or either event. The eve nt is jumper selectable
through H2 or H3. When the counter is used, external
interrupts (see SECTION 12 ) may not be used.

H 2 a nd H 3

Description

Pins

1-2

Carry pulse from counter

3-4

Borrow pulse from counter

5-6

Exter nal interr upt

7-8

Carry or borr ow pulse from counter

9-10

Pulse latch using quadrature input

Jumper header H 2 is used for counter 0 and INT 0.
H e a de r H 3 i s u s ed f or c o un te r 1 an d IN T 1 . T h e L I N E
function may be used to read the status of a jumper on
H2 or H 3. LIN E(8) reads INT 0 and LINE(9) r eads
INT 1.

The pulse latch (pins [9-10]) must be cleared before
another interrupt is generated and should be cleared
before the first interrupt is generated. See
PROGRAMMING below for further inform ation.

Signals connect to the counter via P2 or P 3. The
following table defines signal inputs to the LS7166.

N a m e

Function

An IN

Counter input A

Bn IN

Counter input B

G N D

Ground

L D n

L o a d c o un te r / la t ch ( LC T R / L L T C )

GT n

Gate/reset counter (ABGT/RCTR)

INT n

External TTL interrupt input

Input lines (An IN), (Bn IN), LOAD n, and GATE n are
pulled to + 5V through a 10K resistor.

PROGRAMMING

The LS7166 is capable of several operating modes, all of
which are not discussed here. See Appendix C for this
chips operating modes. W hat are shown are exam ples of
how to program this chip.

NOTE: Be sure to initialize the counter chip before

using COU NT com mands. Failure to do so
returns m eaningless results.

The COU NT function returns the current counter value.
Specifically, RPBASIC w rites a 2 to the MCR (M aster
Control Register), reads the 3 counter bytes from the OL
(Output latch), and converts it to the proper internal
BASIC form at.

100 A = COUNT(0)

COUNT statement writes a 24 bit number to the PR
(Preset r egister) only. Its syntax is:

150 D = 95000
200 COUNT 0,D

A n um b e r c o ul d b e us e d i n p la c e o f va r ia b le ' D ' .

LINEB is used to program and access specific registers
in the LSI7166 chip. In all cases, the bank number is 6.
The address depends upon the specific chip. Use an
address of 1 for counter 0 and 3 for counter 1.

To transfer this number to the counter, execute the
f o ll ow i ng in th e pr o g ra m :

LINEB 6,1,8

Line 100 reads the output status register.

100 A = LINEB(6,1)
200 LINEB6,1,X

L i ne 2 00 w r it e s t o O C C R , I C R , Q R, M C R , a n d IC R
registers in counter 0. The value ' X' selects a register
determined by bits 6 and 7 in the byte written to the
chip.

When H2[9-10] or H 3[9-10] is jumpered, the output
from a latch is connected to the interrupt line. When the
7166 chip is configured for quadrature encoder and
interrupt when the count reaches a preset number, a very