Download RT-DAC/USB2
Transcript
InTeCo 5.6 Counter/timer RT-DAC/USB2 contains two 32-bit timer/counter channels. Both counter/timer channels can operate either in the counter or timer modes. In the timer mode the timer/counter channels count pulses of the internal board clock. The frequency of the clock corresponds to the board version (20 MHz is the default frequency value). In the counter mode the timer/counter channels count external pulses respectively from the CNT0 and CNT1 inputs. In the timer mode the blocks does not use any external signals. In the counter mode the counter inputs are named: DIO24/CNT0 and DIO25/CNT1 and are located at the CN1 connector at pins 35 and 36. The inputs of the counters CTN0 and CNT1 are shared with the general purpose digital I/Os DIO24 and DIO25. If the DIO24/CNT0 or DIO25/CNT1 signals are defined to be the inputs, their states can be read (typically as the digital inputs) and simultaneously they excite the respective counter block. If the signals are set to be outputs, their states are determined by software (typically as the digital outputs) and simultaneously they excite the respective counter block (this operating mode can be applied to test the blocks in a programming manner). The configuration of the timer/counter block is shown below. The Mode flag selects between counter and time modes. The Reset flag is applied to reset the counter. 32-bit counter stores a number of the internal clock periods or a number of the external pulses (the rising edges of the pulses are counted). Reset Cnt 0 Counter 40 MHz 1 Internal Clock Mode I/O signal Parameter Fig. 5.8. Configuration of the timer/counter block In the C language interface the features of the channels are controlled by the TmrCntType structure. The main structure contains the array: TmrCntType TmrCnt[ 2 ]; that is applied to communicate with the timer/counter blocks In the .NET interface the state of the timer/counter blocks are described in the dedicated TmrCntClass class. 5.6.1 Mode C interface .NET interface Simulink interface unsigned int Mode TmrCntClass.ModeState Mode TmrCntMode output of the read S-function SetTmrCntMode input of the send S-function DESCRIPTION The field sets/means the operating mode of the timer/counter. In the C and Simulink interfaces the value equal to 0 sets/means the counter mode; the value equal to 1 means the timer mode. In the .NET interface the value equal to CounterMode sets/means the counter mode; TimerMode means that the block operates as a timer. RT-DAC/USB2 - User’s Manual page 31