beautypg.com

Rpbasic-52 programming guide, Count – Remote Processing BASIC 52 User Manual

Page 43

background image

RPBASIC-52 PROGRAMMING GUIDE

2-24

COUNT

(function)

Syntax:

A = COUNT(counter)
Where: counter = 0 - 1, or 4 - 11

Function:

Reads a multimode hardware or software counter

Mode:

Comm and, Run

Use:

A = COU NT(0)

Cards:

RPC-320, RPC-330

D E S C R IP T I ON

RPBASIC-52 recognizes a hardware and software counter. The hardware counter is 24 bits wide from a LSI
7166 chip. (Your board may use a different kind. Please check your hardware manual.) The RPC-320 has
one of these and the RPC -330 has two. Additionally, there are 8 software counters on all cards.

counter 0 a nd 1 re t ri e ve a 24 b it (3 b yt e ) n u m be r f ro m th e LS I 71 6 6 m u lt im o d e c o un te r I C . A n um b e r f ro m 0
to 16777215 is returned. See your hardware manual for more information about using the LSI 7166 chip.

Eight software counters, set by the ON COUNT comm and, return a count from 0 to 65535. Software counter
i s 4 t o 11 . A so f tw a r e c o u nt i s i n cr e m e nt e d w h e n a l i ne g o es l ow .

RELATED

C O U N T ( st a te m e n t) , O N C O U N T

E R R O R

BAD ARGUMENT When counter is out of range

EXAMPLE

The following example sets up line 3 as a software counter input. A count is printed once a second. A count
is incre men ted by bringin g line 3 low m ome ntarily .

10 ON COUNT4,3
20 ONTICK 1,1000
30 IDLE
40 GOTO 30

1000 PRINT COUNT(4)
1010 RETI

ON COU NT can be configured to generate an interrupt when a specified number of counts is reached. See
COUNT MULTITASKING under MU LTITA SKING CON STRU CTS a t the beginning of this m anual.