At 10:50 27/03/1997 -0500, you wrote: >Hey Pic'ers (pretty close to Packers, eh?), > >I've been zero crossing using a lot of goto loops. That makes me feel a >bit uneasy, but it works so far. I can imagine loops like that are >dangerous due to the chance an event may be missed and you're stuck or >thrown off count. Example: >------code start-------- >ZEROPLUS btfsc PORTA,1 ;this ensures that the beginning of a setting >starts with the ;positive cycle of the ac line > goto ZEROPLUS >Z2 btfss PORTA,1 > goto Z2 >T_ON bsf PORTB,0 >A1 btfsc PORTA,1 > goto A1 >T_OFF bcf PORTB,0 > goto Z2 >-----code end-------- > >You'll note that I'm just verifying the output by having portb bit 0 >'follow' the input signal. Like I said...it works fine, but has anyone >has trouble with relying on such goto loops? # Did you disable the watchdog first ? # You doesn't talk about the input signal frequency, if signal is slow there some possibility it stay long enought just at the input triggering level. Means if Port input trigger level is for example 2V, then you apply a 2V signal at this pin port: There is many chance that while you test the pin the state will change due to noise input. Sometime you will get a zero, and sometime you will get a one. Then if the PIC is running fast enought, you have chance it copy sometime a zero instead a one (or the inverse) and will obtain something like that: ______-_-----------_______-------------_-_-_______________ Don't forget at 4MHz, your test loop will take a maximum of 3 micro-second. It's fast enought to handle noise. Best way is to put a comparator at the input with two limitation diodes. I also see some circuit with an opto-coupler. Best regards, Philippe. +--------------------------------------------------------+ | Virtual Micro Design | | | | E-Mail: p.techer@idls.izarbel.tm.fr | | URL: http://idls.izarbel.tm.fr/entp/techer/P01.HTM | +--------------------------------------------------------+