Diamond Systems PR-Z32-E-ST, PR-Z32-EA-ST user manual Counter Outpbase+15,0x01 Outpbase+15,0x81

Models: PR-Z32-E-ST PR-Z32-EA-ST

1 74
Download 74 pages 11.09 Kb
Page 61
Image 61

Reading a counter

 

a.

Latch the counter:

 

 

Counter 0

Counter 1

 

outp(base+15,0x40);

outp(base+15,0xC0);

b.

Read the data:

 

The value is returned in 3 bytes, low, middle, and high (2 bytes for counter 1)

Counter 0

Counter 1

low=inp(base+12);

low=inp(base+12);

middle=inp(base+13);

high=inp(base+13);

high=inp(base+14);

 

c.Assemble the bytes into the complete counter value:

Counter 0

Counter 1

val = high * 2^16 + middle * 2^8 + low;

val = high * 2^8 + low;

Enabling the counter gate

 

Counter 0

Counter 1

outp(base+15,0x10);

outp(base+15,0x90);

The counter will run only when the gate input is high.

Disabling the counter gate

 

Counter 0

Counter 1

outp(base+15,0x20);

outp(base+15,0xA0);

The counter will run continuously.

 

Clearing a counter

Clearing a counter is done when you want to restart an operation. Normally you only clear a counter after you have stopped (disabled) and read the counter. If you clear a counter while it is still enabled, it will continue to count incoming pulses, so its value may not stay at zero.

a. Stop (disable) the counter:

 

Counter 0

Counter 1

outp(base+15,0x08);

outp(base+15,0x88);

b.Read the data (optional). See “Reading a counter” above.

c.Clear the counter:

Counter 0

Counter 1

outp(base+15,0x01);

outp(base+15,0x81);

Prometheus CPU User Manual V1.44

Page 61

Page 61
Image 61
Diamond Systems PR-Z32-E-ST, PR-Z32-EA-ST user manual Counter Outpbase+15,0x01 Outpbase+15,0x81