Jose, this isnt going to work. The spacing has to be the same for all the bits. You sample them all at the same rate, and set your recieve register bits according to what you find at each slice of time. Take out a comb, like for your hair. draw on a paper the pattern for the preamble as black 'o' for on and space for off. Lay the comb over the pattern. Anytime you see white paper between the teeth, the bit is low. anytime you see an 'o' the bit is set. count the number of teeth set for a bit- it will be one or two or three depending on how big you draw the dots. Same for the spaces. If you move the comb so that the space between 2 teeth is in the middle of each bit, you have the best chance to detect it. You could even sample each piece twice and check that both are the same before deciding it is on or off. how about something like this: wait till 1/2 of a bit has gone by. check the pin if the pin is high, set bit #0 high in recieve register If the pin is low, set bit #0 low in reciever register. wait a FULL BIT LENGTH, minus the time for the test. if the pin is now high, set bit #1 high in recieve register. If the pin is low, set it low. wait a FULL BIT LENGTH, minus the time for the test. If you do this 8 times, your recieve register is stuffed with the incoming byte. Now you test the byte to see if it was the one you were looking for. if it was supposed to be a "U", does the pattern match or not? If it doesnt match, start over, maybe it was just noise. wait > If my preamble sir Kevin is 10101010, at 1200 baud, > is this preamble reception algorithm right? > > > loop1 btfss PORTC,7 > goto loop1 > call 417us ;halfbit delay > loop2 btfsc PORTC,7 > goto loop2 > call 833us ;fullbit delay > loop3 btfss PORTC,7 > goto loop3 > call 417us ;halfbit delay > loop4 btfsc PORTC,7 > goto loop4 > call 833us ;fullbit delay > loop5 btfss PORTC,7 > goto loop5 > call 417us ;halfbit delay > loop6 btfsc PORTC,7 > goto loop6 > call 833us ;fullbit delay > loop7 btfss PORTC,7 > goto loop7 > call 417us ;halfbit delay > loop8 btfsc PORTC,7 > goto loop8 > call 833us ;fullbit delay > > > ____________________________________________________________________ > Get free email and a permanent address at http://www.netaddress.com/?N=1 > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body