OK basic lesson before you get Olinized... This section is written for a '629 in MPlab (untested but should work) list p=12F629 ; PROCESSOR include "P12f629.inc" ; INCLUDE FILE __CONFIG _IntRC_OSC & _MCLRE_OFF ; SETUP OPTIONS Org 00h Goto PORT_SETUP Org 04h Return ; this avoids the interrupt as its not used PORT_SETUP clrf GPIO ; clears the port latches bsf STATUS,RP0 ; goes to bank 1 for direction reg movlw b'11000001' ; set up io (1=input) movwf TRISIO ; and save CMCON_SETUP movlw b'00000111' clrf CMCON ; set up for digital bsf STATUS,RP0 ; back to bank 0 ; when you get here you have a working (basic) chip with an input on GP0. and an output on GP1. Use an external 10K pull-up resistor and a pushbutton switch to Vss on bit 0 and a led and resistor on bit 1 to VCC Its quick and dirty but the led will then follow the switch this is the closest thing to "flash the led" that a novice can learn START_CODE BTFSS GPIO,0 ; Check the switch is off GOTO $-1 ; no go back one BSF GPIO,1 ; Led Off BTFSC GPIO,0 ; check the is on GOTO $-1 ; no go back one BCF GPIO,1 ; Led On Goto START_CODE ; repeat. Now you have found a square wave input and copied it to a pin so you can see it working Everybody gotta start somwhere Regards Steve -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf Of dax2@hotmail.com Sent: 21 November 2006 21:30 To: Microcontroller discussion list - Public. Subject: Re: [PIC] Detecting a square wave The project that I'm doing interfaces with other equipment. The LED indicates if the unit is in standby or not. It flashes fairly fast, about 4-5 times a second. I need to use it in conjunction with an audio signal (music) which is being handled by a detector. It will force the unit out of standby when the music starts. Then force it back into standby when the music is over. I admit that I looked at the posts about using leading/falling edges but to be honest I haven't got a clue as to how to implement that code. I tried using the port digitally. I figured the LED flashed slow enough (in processor time) that it would eventually see the low. Didn't work. What I originally tried with the comparator was to set one input high and the other to the LED signal. Then I polled the interrupt (CMIF) to see if the signal dropped. Didn't work. This is just my second PIC project. ----- Original Message ----- From: "Andre Abelian" To: "Microcontroller discussion list - Public." Sent: Tuesday, November 21, 2006 3:22 PM Subject: RE: [PIC] Detecting a square wave > directly connect to any of external interrupt input and > fallow rising or falling edge. > I do not any reason to use comparator > > Andre > > > > > > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu]On Behalf > Of dax2@hotmail.com > Sent: Tuesday, November 21, 2006 10:57 AM > To: piclist@mit.edu > Subject: [PIC] Detecting a square wave > > > I have a project that requires me to detect a blinking LED. > I'm using a 12F675 PIC. > The signal to the LED is a 5v 50% duty cycle signal when it's on. > A solid 5v when it's off. > I tried to use the comparator but apparently I'm doing something wrong. > Can someone point me in the right direction, please? > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist