Diamond Power Products MM-48-AT user manual Command Sequences, Counter

Page 42

16.3 Command Sequences

Diamond Systems provides Universal Driver software to control the counter/timers on Diamond-MM-48-AT. The information here is intended as a guide for programmers writing their own code in place of the driver and also to give a better understanding of the counter/timer operation.

The counter control register is shown below.

Base + 15

Write

Counter/Timer Control Register

 

 

 

 

 

 

 

 

 

 

 

 

Bit No.

7

6

5

4

3

2

1

0

 

 

 

 

 

 

 

 

 

Name

CTRNO

LATCH

GTDIS

GTEN

CTDIS

CTEN

LOAD

CLR

 

 

 

 

 

 

 

 

 

To make a counter run (load and enable a counter)

1.Load the desired initial value into the counter.

2.If you want to use the gate function, enable the gate.

3.Enable the counter.

To read a counter

1.Latch the counter. The counter continues to operate.

2.Read the value from the data registers.

A counter may be enabled or disabled at any time. If disabled, the counter will ignore incoming clock edges.

The gating may be enabled or disabled at any time. When gating is disabled, the counter will count all incoming edges. When gating is enabled, if the gate is high the counter will count all incoming edges, and if the gate is low the counter will ignore incoming clock edges.

Loading and enabling a counter

For counter 0, three bytes are required to load a 24-bit value. For counter 1, two bytes are needed for a 16-bit value. The value is an unsigned integer.

a. Write the data to the counter:

Break the load value into 3 bytes, low, middle, and high (two bytes for counter 1). Then write the bytes to the data registers in any sequence.

Counter 0

Counter 1

outp(base+12,low);

outp(base+12,low);

outp(base+13,middle);

outp(base+13,high);

outp(base+14,high);

 

b. Load the counter:

 

Counter 0

Counter 1

outp(base+15,0x02);

outp(base+15,0x82);

c.Enable the gate if desired:

Counter 0

Counter 1

 

outp(base+15,0x10);

outp(base+15,0x90);

 

d. Enable the counter:

 

 

Counter 0

Counter 1

 

outp(base+15,0x04);

outp(base+15,0x84);

 

 

Diamond-MM-48-AT User Manual V1.01

Page 42

Image 42
Contents DIAMOND-MM-48-AT Table of Contents Description DIAMOND-MM-48-AT Board Drawing Signal Name Definition O Header Pinout and PIN DescriptionJ3 Analog and Digital I/O Signal Name Definition Relay output contacts J4 Relays and OptocouplersOptoisolated input contacts Base Address Jumper Position Hex Decimal Board ConfigurationBase Address Interrupt Level SelectionOptocoupler Polarity ReservedAnalog Input Range Overview Base + Write Function Read FunctionLSB MSB DA7 DA6 DA5 DA4 DA3 DA2 DA1 DA0 Register Map Bit AssignmentsWrite operations Read operationsDefinitions Register DefinitionsBase + Write Base + ReadAD9 AD8 Base + Read/Write A/D Channel RegisterHIGH3 HIGH2 HIGH1 HIGH0 LOW3 LOW2 LOW1 LOW0 RELAY7 RELAY6 RELAY5 RELAY4 RELAY3 RELAY2 RELAY1 RELAY0 Base + Read/Write Digital I/O Configuration RegisterBase + Read/Write Relay Control Port DIR3 DIR2 DIR1 DIR0DEDGE3 DEDGE2 DEDGE1 DEDGE0 DIO3 DIO2 DIO1 DIO0 DIO3 DIO2 DIO1 DIO0Base + Read Digital I/O Data and Edge Status OEN3 OEN2 OEN1 OEN0 POL3 POL2 POL1 POL0Base + Write Channel and Control Register Daupdt DACH2 DACH1 DACH0OEDGE3 OEDGE2 OEDGE1 OEDGE0 OPTO3 OPTO2 OPTO1 OPTO0 Base + Write Command Register Dapre Daprld Reset Fiforst AdstartBase + Read Status Register POL ADCH3 ADCH2 ADCH1 ADCH0Base + Write Configuration Register CKSEL1 CKFRQ1 CKFRQ0 Scnint Clken ClkselBase + Read Configuration & Status Register Adbusy Dabusy CKSEL1 CKFRQ1 CKFRQ0 Scnint Clken ClkselBase + Read Fifo Status Register Base + Write Fifo Control RegisterFifoth Fifoen Scanen OVF Fifoth Fifoen ScanenBase + Write Interrupt Control Register Clrt Clrd Clro Clra Tinte Dinte Ointe AinteBase + Read Interrupt Status Register Tint Dint Oint Aint Tinte Dinte Ointe AinteBase + Read/Write Counter/Timer D7 Base + Read/Write Counter/Timer D15Base + Read/Write Counter/Timer D23 Base + Write Counter/Timer Control Register Ctrno Latch Gtdis Gten Ctdis Cten Load CLRCtrno Base + Read/Write Eeprom / TrimDAC Data Register Base + Read/Write Eeprom / TrimDAC Address RegisterBase + Read Calibration Status Register Base + Write Eeprom Access Key RegisterBase + Write Calibration Control Register Base + Read Fpga Revision CodeInput Ranges Analog Input Ranges and ResolutionResolution Single Ended and Differential InputsPerforming AN A/D Conversion Trigger an A/D conversion on the current channel LSB = readbase MSB = readbase+1 Data = MSB * 256 + LSBInput voltage = A/D value / 32768 * Full-scale voltage Clken Clksel D SCAN, FIFO, and Interrupt OperationTrigger Conversion or ScanFifoen Fifoth Scanen Fifo OperationInterrupt Operation Fifoen =Guidelines for Selecting Fifo Use Fifoen and Fifoth Operation TableAinte Fifoen Scanen Analog Output Overview Generating AN Analog Output 12.2 A/D calibration Autocalibration OperationReference Voltages 12.3 D/A CalibrationDigital I/O Operation Procedure for enabling interrupts on selected edges Optocoupler OperationEdge detection assumes OENn = 1 to enable edge detection Polarity and logic readbackRelay Operation COUNTER/TIMER Operation Counter 0 A/D Sample ControlCounter 1 Counting/Totalizing Functions Command Sequences CounterCounter Outpbase+15,0x01 Outpbase+15,0x81 Specifications AutocalibrationGeneral