;16C5xxLP are good with 32.768 khz crystals and cheap ;With a 32.768 khz xtal this LED would flash once every 8 seconds: ; Loop 65536 times, then invert the LED ; :Loop djnz Count0,:Loop ;Decrement Count0 until it reaches zero djnz Count1,:Loop ;Decrement Count1. If it's not zero, ;jump back to :Loop xor RA,#00000010b ;Invert the LED (bit 2 of port A) ;Add another loop and it's almost a day and a half ;You can size the first loop to the units you want to measure, then count those loops ;This could be your input: ; Check button status. If it's pressed, skip the additional delay and jump ; back to the first loop ; ChkBtn jnb RA.0,Start:Loop ;Jump to 1st loop if button is pressed ;(button is active low) mov count0,#50 ;Limit first loop to time period you wan t :Loop djnz Count0,:Loop ;Decrement Count0 until it reaches zero djnz Count1,:Loop ;Decrement Count1. If it's not zero, ;jump back to :Loop ;Or limit Count1 to the number of time periods jmp Start:Loop ;Jump back to first loop ;you can get into granularity and counting cycles but a stopwatch is the way to go ;Code from Simple.src, Parallax Inc.