bitsurfer
Member level 3
Hello,
I need help for 8051 serial communication with computer.
While sending strings to computer goes OK I have serious problem with receiving.
Mostly because I don't understand this part well.
This is critical part of my 8051 C code:
I send from computer numbers from 0 to 15 as strings.
This is VB.NET code:
What happens?
Bytes arrived to SBUF with values 0-7 and beeing showed on first 4 leds of port P1.
When commes a number greater than 9 (say "10") then two bytes arrives.
But I need to send from computer numbers from 0 to 255 to be visible on all bytes of P1.
What should I do to achieve this?
I need help for 8051 serial communication with computer.
While sending strings to computer goes OK I have serious problem with receiving.
Mostly because I don't understand this part well.
This is critical part of my 8051 C code:
Code:
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 to see what happens
RI = 0;
// here is key check for terminate receiving...
goto again;
I send from computer numbers from 0 to 15 as strings.
This is VB.NET code:
Code:
For t As Integer = 0 To 15
Application.DoEvents()
Form1.sPort.Write(CStr(t)) 'it have to be a string?
Sleep(3000)
Next
What happens?
Bytes arrived to SBUF with values 0-7 and beeing showed on first 4 leds of port P1.
When commes a number greater than 9 (say "10") then two bytes arrives.
But I need to send from computer numbers from 0 to 255 to be visible on all bytes of P1.
What should I do to achieve this?