-----Original Message----- From: To: PICLIST@MITVMA.MIT.EDU Date: Friday, June 19, 1998 7:57 AM Subject: Synchronized serial tx from BS2 to PIC Nichole, You are here by nominated for the "Stick To It Award". How many lines do you have between the pic and stamp? Are any of them multiplexed so that both can send on them? When not communicating, what states are the lines in? I haven't looked at serial communication bits for a while,but I think that the steady state is a "mark" and the start bit is a "space". May have them reversed. But you must make sure that when there is no activity on the line, the line stays in its "no activity" state or what I think is a "mark". If the line is multiplexed and driven by more than one device, then use a pull up resister, or pull down (which ever gets it to the proper lvoltage level. Mormaly, a high level voltage is used as no signal and a low (ground) level is used as the true signal. This would allow a pull up resister to be used to "pull up" the line to the high voltage when no device is doing the driving. Also this means that to overcome the effect of this pullup resister when a device does srive it, the device brings the line to ground and current folws through it and through the pullup resister. The main voltage drop is through the pullup resister and brings the line to a near ground level. The driving device is "sinking" current and the old ic's could provide ten times more current as a "sink" than as a "source" (where it tried to raise the line to the high voltage) So if posible, ground is used as the "true" level. Because we think of the value "one" as a true value, and readding a pin with ground on it gives you a "zero", some confusion can exist for the programmer. (you). The best thing to do is to read the input and as soon as posible invert it. I think you ae using test and branch instructions, so that advice would not apply. But be sure that the sharred lines, if not all lines, are pulled high or low, which ever is needed. Because you are working with two asyncionus devices, there may be a timming problem. You say that the pic signals the stamp "not to send data" after it receives the stop bit. This sounds dangerous as the stamp may hot get it in time and start thre next byte or bit or something. Why not let the pic raise the signal line and when the stamp sees it, the stamp sends one byte (and ignores the signal line while sending the byte) When the pic recgonizes the start bit, the pic lowers the signal line and continues receiving the rest of the byte. Believe it or not, you are trying to communicate under perfect conditions. Later when the lines get longer, wrap around motors and have people walk over them, there may be errors on the line. And the following is just a hint of what's involved for serious communications. Because you are sending more than one byte, it would be nice to have some way to tell when the first byte of the string is received. This can be done by using a special (one that is not used as a data byte) as a "reset character". When the pic receives this character it resets everything and starts looking for the first data byte. If you are using the data byte to represent the values between 0 and 255, then this is not possible. Plan two may be to have a minimum peroid between each stream where no data is sent. And after this peroid has elapes, the pic knows that the first byte of data is next. I used ascii characters for communicating. And the fields were seperated by tab characters. This allowed me to use a terminal to receive or xmit, and it can be written to a file as is for later use with a spread sheet. In closing, make sure that the lines are allways in a known state and try having the pic raise the signal line sooner. Keep up the good aditude. Bill C. bill@cornutt.com >Hi everyone > >I am writing a serial routine to interface a PIC 16F84 with a BS2 using the >BS2 "FPIN" to synchronize data transfer. > >Has anyone written PIC 16F84 or similar code to accept the BS2 sync serout? > >I am having problems synchronizing the PIC code to the BS2. I am using >inverted mode at 9600. The PIC makes FPIN high to tell the BS2 it is ready for >data. When a stop bit is detected FPIN goes low. The process is repeated for >about 20 bytes. When PIC has all the data it makes FPIN low until it is ready >again. Is it that simple? I don't think so cause it doesn't work. > >Any ideas or sample code? > >Thanks >