×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

38400 bps in Qbasic

38400 bps in Qbasic

38400 bps in Qbasic

(OP)
Hello!

I must do a qbasic serial data output with 38400bps, anybody that did and know how this is possible?
I`m gratefull about any help!

Happy Easter to everybody!

Regards

Phil

RE: 38400 bps in Qbasic

Below is some code I threw together. It works with the Qbasic that comes with DOS. It uses assembler to access the divisor latch of COM2 to change the max baud rate from 9600 to 38400. The assembler may not work with other versions of Qbasic.


OPEN "com2:9600,n,8,1,cd0,cs0,ds0,op0,rs,tb256,rb256" FOR RANDOM AS #2 LEN = 256

DATA   80, 82,186,251,  2,176,131,238,186,248,  2,184,  3,  0,239,186
DATA  251,  2,176,  3,238, 90, 88,203,
'The previous 2 data lines contain the following assembler code:
' push ax
' push dx
' mov dx, 0x2fb
' mov al, 0x83
' out dx, al
' mov dx, 0x2f8
' mov ax, 0x3     115200 / 3 = 38400
' out dx, ax
' mov dx, 0x2fb
' mov al, 0x3
' out dx, al
' pop dx
' pop ax
' retf
'This code sets the baudrate to 38400
DIM a%(51)
DEF SEG = VARSEG(a%(0))
FOR i% = 0 TO 24
    READ d%
    POKE VARPTR(a%(0)) + i%, d%
NEXT i%
CALL ABSOLUTE(VARPTR(a%(0)))
DEF SEG

'Just a silly RX terminal program below to test it
PRINT #2, "Hello!"
WHILE INKEY$ = ""
IF NOT EOF(2) THEN
a$ = INPUT$(1, #2)
PRINT a$;
END IF
WEND
PRINT #2, "Bye!   "
CLOSE



 
Kim_Christensen@telus.net
http://www3.bc.sympatico.ca/Kim_Christensen/index.html
 

RE: 38400 bps in Qbasic

You don't need assembler to do the port accesses listed here. The following QB code is equivalent:

OUT &H2FB, &H83
OUT &H2F8, 3
OUT &H2F9, 0
OUT &H2FB, 3

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close