Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/08/03 04:15
Read: times


 
#41094 - RE: First x bits missing from serial string
Responding to: ???'s previous message
Hello Marshall

I think I might have a clue besides what you already have posted.

This particular fragment of code looks like the source of your lost bits
SendByte(frame.SystemAddress); SendByte(frame.DestinationAddress);
SendByte(frame.SourceAddress);
SendByte(frame.FunctionCode);
SendByte(frame.Length);

for (i =0; i> 8);

// shifts the last byte to the function
SendByte (frame.Crc);


TI=0;
VariableDelay(200); //Hang around a bit before turning driver off (400 = 4.697mSec)
RS485State = RX; //Turn the driver into Receive mode
ModuleStatus = INACTIVE;


Now, here is what I did in one project a long time ago. This might give some ideas
Only in my case, I had 2 485 transcievers on the line, one for transmit one for receive. So, while transmitting, you can also receive the same byte. This way, you know when you finished transmitting

Transmit a packet {
// wait till the bus is silent
start:
do {
wait (3ms)
} while (!silent)
Send the packet
do{
if (rcv == ACK) return;
if (rcv == NAK) goto start;
}while (!3ms)
}

And this is the actual implementation

/* transmit a character on 485 and check if we get it back */
byte put_485(byte c){
byte x;
if (RI) {
RI = 0;
return !OK;
}
TX485 = 1;
SBUF = c;
while (!RI); // wait till we hear our character again
x = SBUF; // check our character
RI = 0;
TX485 = 0;
return (c==x)?OK:!OK;
}

If you notice, the turnaround delay is in the code itself {while (!RI)}

Hope this will help you fix the problem

Jerson

List of 9 messages in thread
TopicAuthorDate
First x bits missing from serial string            01/01/70 00:00      
   RE: First x bits missing from serial string            01/01/70 00:00      
      RE: First x bits missing from serial str            01/01/70 00:00      
   RE: First x bits missing from serial str            01/01/70 00:00      
   RE: First x bits missing from serial string            01/01/70 00:00      
   RE: First x bits missing from serial string            01/01/70 00:00      
   RE: First x bits missing from serial string            01/01/70 00:00      
   Fixed it            01/01/70 00:00      
   RE: First x bits missing from serial string            01/01/70 00:00      

Back to Subject List