'-------------------------------------------------------------- ' (c) 1997,1998 MCS Electronics '-------------------------------------------------------------- ' file: COUNTER.BAS ' demo: COUNTER '-------------------------------------------------------------- ' Connect the timer input P3.4 to a frequency generator ' *TIMER/COUNTER 1 is used for RS-232 baudrate generator '-------------------------------------------------------------- Dim A As Byte , C As Integer Config Timer0 = Counter , Gate = Internal , Mode = 1 'Timer0 = counter : timer0 operates as a counter 'Gate = Internal : no external gate control 'Mode = 1 : 16-bit counter Counter0 = 0 'clear counter Start Counter0 'enable the counter to count Do 'set up a loop A = Inkey 'check for input C = Counter0 'get counter value Print C 'print it Loop Until A = 27 'until escape is pressed End