In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Zoot wrote: Why not use a simple RTCC interrupt that's at least 4x faster than your pulses, and count them there? e.g. [code] samplePin PIN RB.0 INPUT sampleFrame VAR Word sampleCount VAR Word sampleCaptured VAR Word sampleState VAR Byte INTERRUPT 400_000 ' will count pulses up to 100khz sampleState.0 = samplePin ' capture pin right now IF sampleState.0 = 1 THEN ' this state was 1 IF sampleState.1 = 0 THEN ' previous state 0, must be rising edge INC sampleCount ENDIF ENDIF sampleState = sampleState << 1 ' save current state as previous INC sampleFrame IF sampleFrame >= 4000 THEN ' capture every 10ms sampleCaptured = sampleCount sampleCount = 0 sampleFrame = 0 ENDIF RETURNINT Start: Main: 'debug sampleCaptured GOTO Main [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=406111#m407800 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)