Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi everyone!
I tried to send to my serial port a signal with the following code:
mov ah,00
mov al,10100111b
mov dx,00
int 14hmov ah,01
mov al,01b
int 14h...and turning it off with the following code:
mov ah,01
mov al,00b
int 14h...when I ran the program no runtime errors occured except that the serial port stayed on an the LED light didn't go on and off like it was supposed to. If anyone knows the code to send bits to serial ports please send me it and/or reply to this message.
Thanks.

G'day,
Exactly what do you have connected to the serial port? What are you trying to achieve?
The use of int 14h requires that the CTS and DSR signals are asserted on the serial connector.
You're sending out info at 2400bps (or baud) and then what? That my may seem a slow speed for today's kids, but it is still faster than a blink of the eye.
The int BIOS function also returns error codes in AH (I think), so you should be able to check if a character is being sent correctly.
To correct the CTS/DSR problem you may have to use a "loopback" connector: these are often found in modem literature for testing if the com port is working.
You could then use a terminal programme like hyperterminal or Qmodem in "chat" mode. Then everything that you send out of the port will get echoed back.
Be aware that 2400 bps at 8 data bits, 1 stop and 1 start gives you a bit "period" of 1/240 or about 4ms; this may be too fast for your circuit (a light bulb changes state about every 20ms- depending on where you live-and most people consider it continuous)
The other possible problem that you have is Windows itself: with WIN2000 and above, it doesn't like giving you hardware access...
regards,
Elric

I've connected an LED to the serial port. The LED's in-line is on pin 3 and out-line on pin 5. All I want to do is to be able to turn it off and then back on again if so desired by the user. I try it again and I'll slow down the baud. Thanks.

G'day,
So you have it connected between TX and signal ground. The "in" line would be the anode and the out would be the cathode (sometimes marked k). You should really have a current limiting resistor in series with it too. It depends on the LED that you are using, but a red LED drops about 2Volts when passing about 10-20mA of current (you can get smaller ones now that pass 2mA).So, if the RS232 output is about 12V (I think most PCs use that voltage) you have roughly 10V difference (ie12V - 2V) and so to pass a max of 20mA, you will require a 10/20mA = 500 ohm resistor ( I believe the nearest preferred value is 470 ohm). I would put this in series with the LED to avoid any damage to the port.
To answer the other part of your question, the method that you are using is questionable. You have to be aware that the output from tx line is not latched. If you wrote a series of ones (ie ff hex) to the port then they would only be present for the duration of 1 byte (ie 40ms as discussed before 10bits X 4ms). To keep the LED lit up you would need to incorporate a "loop" in your code that continously writes a bit stream of high outputs - I can't remember exactly what the polarity is with RS232 (it might be 0's that send the line high)Either way, you will have to keep the output going for as long as you want the LED to be lit.
A better solution maybe to use one of the control lines (RTS/ DTR etc) to power the LED and just send a "dummy" string of characters out of the port.
The best solution, of course, is to use direct control of the U(S)ART in the PC with your code: either that, or use the printer port- a much better solution.
Good luck,
Elric

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |