assume your preamble sequence is 101010101010...... here are the instructions you will need: btfsc port,pin ; This will skip over the next instruction if the port pin is set to zero. using the goto instruction, you can use this and the next instruction to set up loops to detect a 1, 0 sequence. btfss port,pin ; this will skip over the next instruction if the port pin is a 1. use some goto instructions in there to make the program execute differenet segments depending on if you were expecting a 1 or a 0 at that stage. (if it's a zero, then you should expect a 1, and vice versa) call delay ; download a delay routine from www.piclist.com or write your own to delay exactly one bit period, and one that delays half a bit period as I explained below. You will need two loops, one for if it last received a 1, and should expect a zero after a prescribed period of time, and another for if it last received a zero, and therefore it should expect a 1. Write this all down, so you can see in front of you the sequence you are checking for, then it should be clearer to you. But, I am _not_ going to write the code for you. If you write something, and post it, I will, and I am sure that the others will help you debug it if you tell us where you think it is going wrong. Regards, and best of luck Kevin. ----- Original Message ----- From: "Jose S. Samonte Jr." To: Sent: Wednesday, March 21, 2001 10:37 AM Subject: Re: [PIC]: Would anyone understand...? > Thank you so much to all the people who understand me, but it is > really very vague for me. > Could anyone lend me a assembly code, even just for the preamble and > sync byte transmission and reception, please? > > I hope for your understanding again...=) > > > Kevin Blain wrote: > your receiver might work like this > > idle state...... > > some signal arrives - maybe you have a squelch indication, or the data line > toggles or something like that > > At this point your receiver is expecting preamble. let's say you're using > 1200 baud, and therefore it should expect to see alternate 1's and 0's every > 1 second /1200 bits per secone = 833us per bit. therefore, if you were to > wait half this time from the first transition, sample the bit, then wait the > full 833us, sample again, and so on, you should be able to verify that it > alternates, if that is your preamble format. if it doesn't match from the > start, then it's not preamble, it's noise on the channel. If it matches to > start with, but then stops matching, maybe it's sync word, so go to the next > step. > > your receiver now knows that some data is due, but is not sure when it is > going to start. So decide on the sync word you are going to use, and using a > similar method to above, detect when this word occurs - e.g. if your sync > word is 11001100 then your preamble detect should be going "Oi! that's not > preamble, because the signal didn't toggle every bit! therefore hand it over > to the sync word detection" > > > > Don't stress over what might happen if your receiver misses this for > whatever reason, if, in the unlikely event of the preamble / sync word > occuring in the data, sure, the receiver will get confused and try to output > this as data, but it should be able to detect that the signal has > dissapeared (squelch?) and go back to idle state. > > Your last step would be to get some form of checking going on, CRC of just > simply sum the bytes sent and have a couple of bytes at the end showing the > total, this would allow you to reject the garbage. > > Regards, Kevin > > > > ----- Original Message ----- > From: "Jose S. Samonte Jr." > To: > Sent: Wednesday, March 21, 2001 9:49 AM > Subject: Re: [PIC]: Would anyone understand...? > > > > What my problem sir sir how to receive the preamble and the sync word. > > In other words, how the receiving part would be able to recognize the > preamble > > and sync byte from the data needed to be shown on the LCD. > > > > > > > > > > Peter Betts wrote: > > > My problems are on the preamble, sync word, and the checksum/ > > > CRC. Basically, it's packet transmission and reception. > > > > Preamble's are just a long string of 1's and 0's to indicate transmission > is > > about to start. > > > > Sync words are just a collecting of 1's and 0's in a specific pattern that > > is long enough for the receiving system to lock onto (correlate) and > > synchronise at the appropriate bit rate. > > > > Checksum is a Cyclic Redundancy Check and is normally a delay line with > > XOR'ed taps fedback into the delay line input. (The feedback bit gives you > > the "cyclic" term) > > > > There are many many text books that explain CRC generation. It can be as > big > > or small as you like. If it's a PC you are talking to then I don't know > the > > correct polynomial for the CRC in this circumstance. > > > > You notice how again you can break this down into smaller and smaller > bits. > > If it's a PC you're talking to get the speification of the interface and > > read it. Then just try a simple terminal program and turn off all fancy > > handshaking or parity checking. Just try raw data communications. When > that > > works try adding CRC (parity) etc etc. > > > > Pete > > > > -- > > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > > > > > > ____________________________________________________________________ > > 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 > > > > ____________________________________________________________________ > 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