PULSIN pin, state, wordvariable
Pin - is a variable/constant which specifies the i/o pin to use.
State - is a variable/constant (0 or 1) which specifies which edge must occur before beginning the measurement in 10us units (at 4MHz resonator).
Wordvariable - receives the result (1-65535). If timeout occurs (0.65536s at 4MHz) the result will be 0.
Measure the length of an input pulse.
The pulsin command makes a pin an input and then measures the length of a pulse on that pin. If no pulse occurs in the timeout period, the result will be 0. If state = 1 then a low to high transition starts the timing, if state = 0 a high to low transition starts the timing. Use the count command to count the number of pulses with a specified time period.
It is normal to use a word variable with this command.
Effect of Increased Clock Speed:
4MHz 10us unit 0.65536s timeout 8MHz 5us unit 0.32768s timeout 16MHz 2.5us unit 0.16384s timeout 32MHz 1.25us unit 0.08192s timeout 64MHz 0.625us unit 0.04096s timeout
Submit Your Own Code!
You must be logged in to submit code examples. Login now.