Adds a new command called CountUntil
Syntax
Variable = CountUntil Port1, Pin1, Port2, Pin2, StopPinLevel
Overview
Count the number of pulses that appear on pin Until another pin equals the trigger level, and store the result in variable
Operators
Variable - a user-defined variable (byte word or dword).
Port1 - a port or a byte variable or constant that represents the port address that the pulse is being counted on
Pin1 - a pin number between 0 and 7 represented as a constant or byte that the pulse is being counted on
Port2 - a port or a byte variable or constant that represents the port address that stops the count
Pin2 - a pin number between 0 and 7 represented as a constant or byte that stops the count
StopPinLevel - a constant or variable that represents the logic level to stop the counting 0 or 1
Code:
' Count the pulses that occur on PORTA.0 until PORTA.1 goes high and display the results.
Dim WRD As Word ' Declare a word size variable
Loop:
Cls
WRD = CountUntil PORTA,0,PORTA,1,1 ' Variable WRD will contain the Count result
Cursor 1 , 1
Print Dec WRD , " " ' Display the decimal result on the LCD
GoTo Loop ' Do it indefinitely
The counter is incremented on the rising edge of a transition (low to high).
The maximum value the count can obtain is 65535
Download module
Download: CountUntil 

Menu
Recent Articles


Using PDS with SPI GLCD based on ST7565R Controller
Graphic LCDs based on the ST7565 are cheaper then GLCDs with other controllers. SPI requires only four pins. If the circuit