Here is a join of the 3 answers you people send (thanks) >Dude, >Could you send us the code you're using to estabilish the communication >with >the Hardware ? >Ciao, >Diego
>What about sending more than one stop bit? >That will effectively give the micro more time between bytes. >David... >Hardware or software handshaking would be the normal way to solve this >serial communications problem, or increase the size of the buffer on the >receiving system. >I have successfully used the TComPort component to talk with serial >systems at baud rates in the order of 38,400 baud. > http://sourceforge.net/projects/comport/ >David Let me explain some better This microcontroller I´m comunicating with, is very simple. As simple than TX and RX (not CTS or DTS). There´s no buffer in the receiving system, and, the weird thing, in the end, is that PC is the slow partner... We see it using a osciloscope. Our protocol always send a byte and than receive a byte, send and receive, and so on. This way communication goes days along, even with no comunication erros. But as I´m talking about, osciloscope show as below: PC send a byte uC receive it, process it and answer whitin 50 microseconds (microseconds here) PC receive the answer and send another byte, but it takes 1 to 1,5 ms between the receive and the send (milliseconds here) uC receive it, process it and answer whitin 50 microseconds (microseconds again here) When the PC receives the answer from uC, there´s no process, it sends back immediately, one line below another, like this: if ComPort.Read(1) then begin ComPort.Send(buffer); ... end; The question is: What is that 1ms between receive and next send? As asked, we stabilish the connection this way: function TXComPort.Open: boolean; var Buffer : TCommConfig; dcbCommPort : DCB; ok : boolean; s : string; size : cardinal; TimeOutBuffer: TCommTimeouts; begin if Opened then begin raise Exception.Create('Porta '+IntToStr(Config.Port)+' já está aberta'); end; s:='\\.\COM'+IntToStr(Config.Port); Handle:=CreateFile(PChar(s), GENERIC_READ + GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, //FILE_ATTRIBUTE_NORMAL, 0); IOpened:=Handle<>INVALID_HANDLE_VALUE; if IOpened then begin // pega a configuracao ou o tamanho necessario size:=SizeOf(TCommConfig); ok:=GetCommConfig(Handle, Buffer, size); if ok then begin GetCommState(Handle, dcbCommPort); // BUILDCOMMDCB doesnt work, so we do it for ourselves dcbCommPort.BaudRate:=Config.BaudRate; dcbCommPort.ByteSize:=8; dcbCommPort.Parity :=0; dcbCommPort.StopBits:=0; dcbCommPort.Flags :=4113; ok:=SetCommState(Handle, dcbCommPort); if ok then begin GetCommTimeouts (Handle, TimeoutBuffer); TimeoutBuffer.ReadIntervalTimeout := MAXDWORD;//Config.TimeOut; TimeoutBuffer.ReadTotalTimeoutMultiplier := MAXDWORD; //Config.TimeOut; TimeoutBuffer.ReadTotalTimeoutConstant := Config.TimeOut; ok:=SetCommTimeouts(Handle, TimeoutBuffer); end; end; if not ok then begin Close; end; end; Result:=IOpened; end; ----- Original Message ----- From: "Diego" <[EMAIL PROTECTED]> To: "Borland's Delphi Discussion List" <[email protected]> Sent: Tuesday, September 06, 2005 11:40 AM Subject: Re: COM speed problem ----- Original Message ----- From: "Diego" <[EMAIL PROTECTED]> To: "Borland's Delphi Discussion List" <[email protected]> Sent: Tuesday, September 06, 2005 10:50 AM Subject: Re: COM speed problem > Cara, > > Como vc está fazendo essa chamada de comunicação ?? > Manda o código aí pra eu dar uma olhada e ver se posso te ajudar.. > > Fui ! > > Diego > > ----- Original Message ----- > From: "Moacir Flávio Gonçalves" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Tuesday, September 06, 2005 8:13 AM > Subject: COM speed problem > > > > Im working in a project using COM to comunicate to some hardware and i´m > have a big problem: when I send some data to the hardware, it receives and > send the answer in 50 microseconds or less, but, when my program receives > the answer, theres 1 ms of delay until i can send a byte back to hardware. > Its not my program fault, its some kind of windows or whatever issue because > i make a test program that receive, send, receive, send one line below > another to see it, and the delay is outside my program. Have it anything to > do with some configuration tip or maybe a overlapped style can fix it? > > someone? > > _______________________________________________ > > Delphi mailing list -> [email protected] > > http://www.elists.org/mailman/listinfo/delphi > _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

