For a As Integer = 1 To 10
For t As Integer = 0 To 255
Form1.sPort.Write(Chr(t))
Next
Next
again:
while(RI!=0)
{
P1=SBUF;
RI=0;
receivedBytes++;
}
show_lcd_received_bytes(receivedBytes);
goto again;
Hello,
While I can send data to computer well, and from computer too I have problems with accurately receiving data to 8051 mC.
Here is my VB.NET code for sending bytes:
Code:For a As Integer = 1 To 10 For t As Integer = 0 To 255 Form1.sPort.Write(Chr(t)) Next Next
For sure, this code sends 2550 bytes.
And here is C code for receiving bytes:
Code:again: while(RI!=0) { P1=SBUF; RI=0; receivedBytes++; } show_lcd_received_bytes(receivedBytes); goto again;
By watching variable receivedBytes it take only 190-210 bytes (every time different) because computer dumps data to port without any synchronisation.
Is here any technique or method to receive full data fast and proper?
I also try receiving data with serial interrupt with same results.
This is, of course, not usable in any practical application.
What to do here?
Dim r As Integer = 255 'your integer
Form1.sPort.Encoding = System.Text.Encoding.GetEncoding(1250)
Form1.sPort.Write(Chr(r))
SCON = 0x50;
TMOD = 0x20; //timer 1, mode 2, 8-bit reload
TH1 = 0xFD; //reload value for 9600 baud
TR1 = 1;
TI = 1;
again:
while(RI!=1)
{;}
P1 = SBUF; //send to port with led's
RI = 0;
show_lcd_received_bytes(receivedBytes); // here is key check for terminate receiving...
goto again;
you might use the RTS and CTS of the serial port for that.
have you considered setting up the VB.net SerialPort object to use 2 stop bits instead of one???
like i said, use the Clear to sent pin of the serial port. if the data is received and acknowledged by the pc, The PC asserts RTS to indicate a desire to transmit to the UC, and the UC asserts CTS in response to grant permission. refer RS 232 communication schemes .
again:
CTS=1;
while(RI!=1)
{;}
P1 = SBUF; //send to port with led's
RI = 0;
CTS=0;
show_lcd_received_bytes(receivedBytes); // here is key check for terminate receiving...
goto again;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?