This is my sort of first try at a little program and would like to know if I am doing things right. I only understand the simple commands and there might be a better way of doing it, what do you think ?
The program is to eliminate every third pulse from a sensor. The pulse enters porta and is duplicated out on portb, every third pulse should be ignored and not duplicated.
porta,1 = pulse input
portb,1 = pulse output
_on
btfss porta,1 :
goto _on :check for pulse, if not loop
decfsz count,f :check if its third count
goto setout :let pulse through, set an output
call skip :if counter is clear skip a pulse
goto _on :
setout
bsf portb,1 :set pulse output
Waitout
btfsc porta,1 :
goto waitout :loop until input goes low
bcf portb,1 :remove output
goto _on :
skip :no output is sent, pulse skipped
btfsc porta,1 :
goto skip :wait till input is removed
clrf count :
movlw 0x02 :
movlw count :reset counter with 2
return
The program is to eliminate every third pulse from a sensor. The pulse enters porta and is duplicated out on portb, every third pulse should be ignored and not duplicated.
porta,1 = pulse input
portb,1 = pulse output
_on
btfss porta,1 :
goto _on :check for pulse, if not loop
decfsz count,f :check if its third count
goto setout :let pulse through, set an output
call skip :if counter is clear skip a pulse
goto _on :
setout
bsf portb,1 :set pulse output
Waitout
btfsc porta,1 :
goto waitout :loop until input goes low
bcf portb,1 :remove output
goto _on :
skip :no output is sent, pulse skipped
btfsc porta,1 :
goto skip :wait till input is removed
clrf count :
movlw 0x02 :
movlw count :reset counter with 2
return