Qbasicnews.com

Full Version: serial communication problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
how can i send data through com1 with qb?
protocol is 2400,N,8,1

i used

OPEN "com1:2400,n,8,1,cd0,cs0,ds0,rs" FOR OUTPUT AS #1
OUT (1016), 254
OUT (1016), 1
OUT (1016), 1
SLEEP 2
OUT (1016), 254
OUT (1016), 1
OUT (1016), 0
END

but no responce from device (pic16f84)

is something wrong with program?

thx
If no com port is open on the other end then you will always receive this error. You need to make a program to receive the data (if you haven't already).

Basically, make another program that opens the com port for INPUT. Then use INP to receive the same number of bytes that you will send. It should wait in a loop until it gets the data. Run the program and go over to your other computer and run the output program.
thx for the answer but i want to know if the program is correct?
because i am sendig the data not to other pc but to a pic
I am not sure of this, But
If you are opening the port using qb (ie: #1)
then you need to address the port that way.
for example

Print #1,
Write #1,
To send data through the com port you need to use PRINT #f where f is the file number. OUT is for sending bits to specific ports on the computer and is used like this:
OUT &HFE, $HC6
NOTE: I am not liable if the above "OUT" statement causes damage to your computer. I have no idea what it does.
The addr you have used is correct for com1: &H3F8, but the difficulty is that when basic does it,
it checks to see if the Transmit buffer is empty before sending the next char. Theoretically your code should work at least once,
assuming that the buffer was emty, and you are not sharing this buffer with Received data.
Cause the pic could be sending char's that simply fill up the buffer.

On the other hand the speed with which the three commands happen, means the Tx buffer wont be empty when you are already sending the next char.

Are you using a cable supplied by someone else, or did you make it up.
Make sure the cable is a crossover, Tx to Rx, Rx to Tx etc.