| aDig_ReadTmr | Index |
Definition:
Parameters:
| index | - | The index of the digital I/O pin to be used for a time measurement. |
Return Value:
Description:
This routine times an event on a digital I/O pin. The pin must be configured as an input and be a valid timer pin otherwise an I/O error will occur. Only pins 1-4 may be used as timers on the BrainStem GP 1.0 Module. The type of timed event depends on the configuration of the digital I/O pin. An event is a state transition on a digital input pin. Two event timing modes are possible: edge mode and pulse mode. The target state and mode may be selected with the aDig_Config statement.
In edge mode, an internal timer measures the elapsed time until a transition from the non-target state to the target state occurs on the specified digital input pin. The elapsed time is a 2-byte value in units of 1.6us. The maximum time interval is 104ms. A timeout is represented by a value of 0. A timeout will occur if not 104ms elapse before a transition occurs.
In width mode, the internal timing logic waits until a transition occurs from the non-target state to the target state on the specified digital input pin. Then it measures the elapsed time until the input pin returns to the non-target state. The elapsed time is a 2-byte value in units of 1.6us. The maximum time interval is 104ms. A timeout is represented by a value of 0. A timeout will occur if 104ms elapse before the start transition and end transition occur.
Example:
t = aDig_ReadTmr(1);
This would time an event on digital I/O pin 1.
Related: