The code below might be put into your iniscl() function:
If pModule is a null pointer, this code constructs a scaler object at base address 0x38000000 in crate 0 (the default crate) and assigns the pointer to the address of the module.
Note that the module constructor calls CSIS3820::Reset.
CSIS3820* pModule(0); ... void iniscl() { ... if(!pModule) pModule=new CSIS3820(0x38000000); pModule->setOperatingMode(CSIS3820::LatchingScaler); ... }
The valid input modes are described by the enumerated constants CSIS3820::InputMode. The valid input modes are:
Input 1 - External latch signal Input 4 - Inhibit the external latch signal.
Input 1 - External latch signal Input 3 - Inhibit all scalers. Input 4 - Inhibit the external latch.
Input 1 - External latch signal. Input 4 - Inhibits all scalers.
Input 1 - Inhibit scalers 0-7 Input 2 - Inhibit scalers 8-15 Input 3 - Inhibit scalers 16-23 Input 4 - Inhibit scalers 24-31
Continuing with the examples in Constructing a module object. and Setting the operating mode., To set the module so that it has a Latch external input and an inhibit input for all channels, you might choose input mode CSIS3820::InputLatchInhibitAll as shown in the extended example below:
CSIS3820* pModule(0); ... void iniscl() { ... if(!pModule) pModule=new CSIS3820(0x38000000); pModule->setOperatingMode(CSIS3820::LatchingScaler); pModule->setInputMode(CSIS3820::InputLatchInhibitAll); ... }
By default, the module will clear its countesr when it is latched. This setting can be manipulated by the functions:
Non clear mode is useful when the scaler is used to provide a timebase (real time clock e.g.). To set up the module in this mode (continuing the the example we have been studying thus far):
CSIS3820* pModule(0); ... void iniscl() { ... if(!pModule) pModule=new CSIS3820(0x38000000); pModule->setOperatingMode(CSIS3820::LatchingScaler); pModule->setInputMode(CSIS3820::InputLatchInhibitAll); pModule->DisableClearOnLatch(); ... }
The code below shows the use of the CSIS3820::Arm and CSIS3820::Enable functions to enable the module.
CSIS3820* pModule(0); ... void iniscl() { ... if(!pModule) pModule=new CSIS3820(0x38000000); pModule->setOperatingMode(CSIS3820::LatchingScaler); pModule->setInputMode(CSIS3820::InputLatchInhibitAll); pModule->DisableClearOnLatch(); // RT Clock mode e.g. pModule->Arm(); pModule->Enable(); ... }
Once enabled, the module can be disabled via CSIS3820::Disable. A disabled module does not count. There is no way to disarm a module other than by resetting it (CSIS3820::Reset).