home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / BASIC / POWBASIC / LIBRARY4 / PORT4.BAS < prev    next >
BASIC Source File  |  1993-12-01  |  4KB  |  155 lines

  1. 'Program Name    : Port4.bas
  2. 'Author          : Lloyd L. Smith for Spectra Technical Support
  3. 'Date            : 11-12-90
  4. 'Compuserve #    : GO PCVENB, Vendor #12/Spectra,  Tech Support ID 71530,2640
  5. 'Tech Support BBS: 813-625-1721, PC-Board, 8,N,1 USR HST 300 - 14.4, 24hrs
  6. 'Tech Support Fax: 813-625-1698  G2 & G3 compatible
  7. 'Tech Support Voc: 813-625-1172  Voice
  8. 'Prog ConceptDate: 07-01-88 - Smithtronix Corporation
  9. '
  10. 'Basic Serial Port routines for extended com ports, illustrates polled use
  11. 'of serial ports before PowerBasic 2.10a.  Use subroutines as needed.  These
  12. 'are programming examples.
  13. '
  14. 'Remember if you use polled ports, they are not interrupt driven nor buffered.
  15. 'With PB 2.1a you now have access to 4 interrupt driven & buffered serial ports.
  16. '
  17. 'Serial Port Base Address Information
  18. 'these addresses vary, be sure to check the board you are using.
  19. 'com1 3f8-3ff ,com2 2f8-2ff ,com3 3e8-3ef ,com4 3e0-3e7
  20. 'com5 2f0-2f7 ,com6 2e8-2e7 ,com7 2e0-2e7 ,com8 260-267
  21. '
  22. 'Serial Port Address Register LineUp
  23. '3F8H (Out) Data Output to transmitter holding register
  24. '3F8H (In)  Data Input from receive Data Register
  25. '3F9H (Out) Baud-Rate Divisor(Low Byte)
  26. '3F9H (In)  Baud-Rate Divisor(High Byte)
  27. '3FAH (In)  Interrupt Enable Register
  28. '3FBH (Out) Line Control Register
  29. '3FCH (Out) Modem Control Register
  30. '3FDH (In)  Line Status Register
  31. '3FEH (In)  Modem Status Register
  32.  
  33.  
  34. Xmitcom3:
  35. def seg= &H40
  36. Ckt3stat:
  37. address=&h3E8
  38. x=inp(address+5)
  39. if x and 32 then gosub xmitcom3 else Ckt3stat
  40. xmitcom3:
  41. out Port3,DataO3$
  42. def seg
  43. return
  44.  
  45. RecCom3:
  46. def seg= &H40
  47. ckr3stat:
  48. address=&h3E8
  49. x=inp(address+5)
  50. if x and 1 then gosub RecCom3 else ckr3stat
  51. reccom3:
  52. datai3$=inp(address)
  53. def seg
  54. return
  55.  
  56.  
  57. Xmitcom4:
  58. def seg= &H40
  59. ck4stat:
  60. address=&h3E0
  61. x=inp(address+5)
  62. if x and 32 then gosub xmitcom4 else ck4stat
  63. xmitcom4:
  64. out port4,dataO4$
  65. def seg
  66. return
  67.  
  68. RecCom4:
  69. def seg= &H40
  70. ckr4stat:
  71. address=&h3E0
  72. x=inp(address+5)
  73. if x and 1 then gosub RecCom4 else ckr4stat
  74. reccom4:
  75. datai4$=inp(address)
  76. def seg
  77. return
  78.  
  79.  
  80.  
  81. 'This routine swaps the base addresses of com1 & com2
  82. SWapCom12:
  83. defseg=&H40
  84. x=peek(0):y=peek(1)
  85. poke 0,peek(2):poke1,peek(3)
  86. poke 2,x:poke 3,y
  87. def seg
  88.  
  89.  
  90. SetBaudRate:
  91. 'Setup the serial port baud rate the hardway
  92. 'Additional register programming available from intel 8250 data books.
  93. base=&H3F0
  94. addr=base+3
  95. out addr,&H80    'turn on the seventh high bit
  96. out addr-2,0     'msb for 1200 baud
  97. out addr-3,&h60  'lsb for 1200 baud
  98. 'setting up the number of start and stop bits for serial port control
  99. a=0
  100. a=a or &H02
  101. out base+3,27
  102. out base+5,0   'disable interrupts
  103. return
  104.  
  105.  
  106. 'this routine swaps the port addresses to trick dos into going
  107. 'to more than one one port.  Only two serial ports can be open at any
  108. 'one time.
  109. setport:
  110. close #1
  111. def seg=&H40
  112. basel=&HF8:baseh=&H3
  113. poke 0,basel
  114. poke 1, baseh
  115. def seg
  116. OPEN "com1:9600,n,8,1,RS,CD,DS,CS,OP1000,RB2000" FOR RANDOM AS #1
  117. return
  118.  
  119. Comset4PortsLow:
  120. 'com1 3f8-3ff ,com2 2f8-2ff ,com3 3e8-3ef ,com4 3e0-3e7
  121. def seg=&h40
  122. poke 0,&f8  'com1 set low byte
  123. poke 1,&h3  'com1 set hi  byte
  124.  
  125. poke 2,&f8  'com2 set low byte
  126. poke 3,&h2  'com2 set hi  byte
  127.  
  128. poke 4,&e8  'com3 set low byte
  129. poke 5,&h3  'com3 set hi  byte
  130.  
  131. poke 6,&e0  'com4 set low byte
  132. poke 7,&h3  'com4 set hi  byte
  133. def seg
  134. return
  135.  
  136. Comset4PortsHi:
  137. 'com5 2f0-2f7 ,com6 2e8-2e7 ,com7 2e0-2e7 ,com8 260-267
  138. def seg=&h40
  139. poke 0,&f0  'com1 set low byte
  140. poke 1,&h2  'com1 set hi  byte
  141.  
  142. poke 2,&e8  'com2 set low byte
  143. poke 3,&h2  'com2 set hi  byte
  144.  
  145. poke 4,&e0  'com3 set low byte
  146. poke 5,&h2  'com3 set hi  byte
  147.  
  148. poke 6,&60  'com4 set low byte
  149. poke 7,&h2  'com4 set hi  byte
  150. def seg
  151. return
  152.  
  153.  
  154.  
  155.