Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

38400 bps in Qbasic

Status
Not open for further replies.

PhilX

Programmer
Apr 27, 2002
13
0
0
US
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
 
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.

Code:
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
 
You don't need assembler to do the port accesses listed here. The following QB code is equivalent:
[tt]
OUT &H2FB, &H83
OUT &H2F8, 3
OUT &H2F9, 0
OUT &H2FB, 3
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top