I am using a capture module to measure RPM with a PIC16F628A. It works very well, but if the motor isn't running there will be no pulse so I am stuck in an endless loop waiting for the pulse. I need to do other things on the pic, so this isn't good. Besides incrementing a value, how else can I add a failsafe to exit the loop?
In the CaptureLoop I can look for a timer1 overflow flag which would work, but the trash loop the timer isn't running, so that wouldn't work.Code:Trash: If Capture = 0 then Goto Trash 'stuck in loop if no capture endif T1CON.0=1 'starts timer Capture=0 'trash first capture CaptureLoop: If Capture = 0 then Goto CaptureLoop endif T1Con.0=0 period.LowByte=CCPR1L period.HighByte=CCPR1H




Bookmarks