Capture mode also defines trigger timing by setting trigger target.
Pin input as well as HT 0 can be a trigger target.
Trigger timing means the point of time that HT starts internal counter for capturing signal so it is possible to implement capturing signals even if HT is not triggered and the count values are all zero.
The following example shows setting a trigger target to rising edge event and capturing two count values with falling edge.
<?php $pid = pid_open("/mmap/ht0"); // open HT 0 pid_ioctl($pid, "set div us"); // set unit: microsecond pid_ioctl($pid, "set mode capture fall"); // set mode: capture with falling edge // set trigger target: pin event with rising edge pid_ioctl($pid, "set trigger from pin rise"); pid_ioctl($pid, "set repc 2"); // set repeat count: 2 pid_ioctl($pid, "start"); // start HT 0 while(pid_ioctl($pid, "get state")) ; for($i = 0; $i < 2; $i++) echo "[$i]", pid_ioctl($pid, "get count $i"), "\r\n"; // read count values pid_close($pid); ?>
If two square waves with period of 20㎲ are coming while running an example above, counter values of index 0 and 1 are as follows:
The result is as follows: