Page 173 of 346 Start Back Next End ZBasic System Library 161 ZBasic Microcontrollers InputCapture Type Subroutine Invocation InputCapture(data, count, flags) InputCapture(data, count, flags, timeout) Parameter Method Type Description data ByRef array of UnsignedInteger The array in which pulse width information will be stored. count ByVal int16 The number of pulse widths to store. This should be no larger than the number of entries in the passed array. flags ByVal Byte A value of zero requests that a falling edge begin the capture process while a value of 1 indicates a rising edge. All other values are reserved. timeout ByVal Integral If non-zero, this parameter specifies a timeout value that, if exceeded, will terminate the input capture process. Discussion Invoking this routine is equivalent to the call InputCaptureEx(pin, data, count, flags) or InputCaptureEx(pin, data, count, flags, timeout) where pin is the default input capture pin for the device as shown in the table below. See the description of InputCaptureEx() for more detailed information. Also, see the section Input Capture Timers for information on the default input capture pin used by this subroutine. The stored values represent the number of I/O Timer ticks (i.e. 1/F_CPU or about 67.8ns for 14.7MHz devices) measured for each segment of the pulse train. However, the value of Register.TimerSpeed1 may be changed to allow longer pulse widths to be measured. See the section on Timers for more information. Example Dim pd(1 to 5) as UnsignedInteger Call PutPin(12, zxInputTriState) Call InputCapture(pd, UBound(pd), 1) Compatibility The BasicX compiler erroneously allows any variable for the first parameter. This implementation requires the data type to be UnsignedInteger or Integer although it needn’t be an array. For practical purposes, an array will almost always be used. In BasicX compatibility mode, the use of the optional fourth parameter is not supported. Also, because the processor runs at twice the speed of the BX-24 processor, the default time unit is one half of that provided for by BasicX.