mscomm communication via serial port
hi,
i am using the serial port of the PC to transmit data to my microcontroller. At data rates <=56000bps, i am having smooth reception of data by the microcontroller.
But at data rates > 56000bps, the error "8015" appears. the program breaks at the portopen property & gives the 8015 error message.
Someone please bail me out of this mess.
Regards,
Yaar
Re: mscomm communication via serial port
What's your maximum port speed for that port? (Look in Device Manager.) Also, what speed is your microcontroller running at? (I've been using MSComm for a long time and have never seen that error.)
Re: mscomm communication via serial port
Hi AI42,
The maximum port speed is 256000 (as specified by the Device manager).
The microcontroller has its port speed determined by the formula ,
Data rate = (2,000,000/(X+1)).
where X has to be converted to Hex to be fed into the microcontroller's register.
and data rate is the rate ( in decimal) set for communication between the computer & the microcontroller.
Hence the value of X ( in hex) turns out to be:
For data rate = 38400, X=33, baud rate error=0.16%
For data rate = 56000, X=22, baud rate error=2.04%
For data rate = 128000, X=0F, baud rate error=2.34%
For data rate = 256000, X=07, baud rate error=2.34%
The microcontroller can take up these baud rate errors comfortably .
I followed some other threads with similar problem, but they had some issue like the serial port was configured to the printer. In my case there is no such issue.
Look forward to your reply.
Yar
Re: mscomm communication via serial port
Since I run a program using MSComm running at 115k, and it's been running for about a year with no missed data, I'd say that the problem isn't with the MSComm control. (I'm assuming that you're opening the port once, not constantly opening and closing it.)
Re: mscomm communication via serial port
I didnt understand the constantly opening & closing part of the MSCOMM.
When the program executed, I am opening the port when the first form gets loaded. Here. the PC receives some data from the microcontroller.
I switch to another form to do some calculations (in the PC) with the received data & then transmit the calculations from the PC to the microcontroller.
In this process, i m doing some opening and closing of the port.
but, the error that i am getting (error 8015) starts when the very first form (ie, when i want to transmit data from the microcontroller to the PC) loads.
Is the opening and closing of ports somehow related with this?
Re: mscomm communication via serial port
Quote:
Originally Posted by yarjoobas
When the program executed, I am opening the port when the first form gets loaded. Here. the PC receives some data from the microcontroller.
I switch to another form to do some calculations (in the PC) with the received data & then transmit the calculations from the PC to the microcontroller.
Where is the code to transmit the data? On the first form or on the second form?
Quote:
In this process, i m doing some opening and closing of the port.
Don't. There's no reason to, unless some other program needs to use the port while your program is running, and it could lead to problems.
Quote:
but, the error that i am getting (error 8015) starts when the very first form (ie, when i want to transmit data from the microcontroller to the PC) loads.
Is the opening and closing of ports somehow related with this?
No, 8015 usually refers to a hardware error or some insane values in your MSComm setup. Is this a 3-wire system or a 7-wire (handshaking) system? Some (improperly implemented, IMO) PC serial ports don't like running without handshaking.