> Right, have to use interrupt. So will it be like, choose pulse edge, enable > interrupt on say rising edge and then turn ON LED? > But how to turn it OFF when square wave pulse is low? As BillW said, change the polarity of the edge trigger. If you don't, then what will happen is that the input frequency will be halved if you use the interrupt to change the state of the LED, ie only the rising edges will cause an interrupt and falling edges will be ignored > bsf option_reg, intedg ; select interrupt on > rising edge of b0/int pin > bsf intcon, int0ie ; enable rb0/int external interrupt > intchk btfss intcon, rbif ; check interrupt flag bit > goto intchk > movf portb, 1 ; end mismatch condition > bcf intcon, rbif ; clear interrupt flag > bsf portb, 1 ; turn on led > btfss intcon, rbif ; check rbif bit > bcf portb, 1 ; turn off led > retfie What you have above is not how it would be done, and is part polling, part interrupt. What follows is very general, but would work on basic PICs which have only one INTCON register and a simple interrupt structure. You can find the interrupt logic tree for any PIC in its datasheet Firstly you do the initialisation bsf option_reg,intedg ;select the edge polarity clrf intcon ;disable all interrupt sources and clear interrupt flags bsf intcon,int0ie ;enable just the INT0 interrupt bsf intcon,gie ;enable the global interrupt [insert your main-line code here - for example a simple do-nothing wait] wait nop goto wait Secondly, the ISR (interrupt service routine). This assumes that only the INT0 interrupt is enabled. No context saving done bcf intcon,int0if ;clear the flag which caused the interrupt clrf temp ;toggle the edge polarity bit (better way to do this anyone ?) bsf temp,intedg,w xorwf option_reg btfss option_reg,intedg ;if edge bit = 1, LED on goto led_off ;else LED off bsf led ;LED on retfie ;exit back to 'wait' led_off bcf led ;LED off retfie ;exit back to 'wait' -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist