home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / PARADIS1 / 16550CHK.PAS next >
Pascal/Delphi Source File  |  1992-05-27  |  3KB  |  92 lines

  1. (6844)  Sun 17 May 92 23:07
  2. By: Jan Feijes
  3. To: Trevor Carlsen
  4. Re: Re: 16550 chip
  5. St:
  6. ---------------------------------------------------------------------------
  7. @MSGID: 2:281/506 488f57d6
  8. And I quote :
  9.  Trevor Carlsen said to All about 16550 chip on the 05-01-92  23:06
  10.  
  11.  TC> Does anybody have any Pascal (or assembler) code that will
  12.  TC> demonstrate a fool-proof way of determining if the UART is a 16550,
  13.  TC> 16450 or 8250?
  14.  
  15.  If asked this question some time ago, and have found some routines
  16.  which I adapted and allow me to see the difference between an 16550
  17.  and a 8250, 16450. this is I can tell when I am dealing with an
  18.  16550 or not :
  19.  
  20.  Function Check16550Present : Boolean;Assembler;
  21.  
  22. {
  23. -------------------------------------------------------------------------
  24.  Checks if 16550 UART is present
  25. -------------------------------------------------------------------------
  26. }
  27.  
  28. Var
  29.    OldState : Byte;
  30.  
  31. ASM
  32.                 MOV       DX,COM
  33.                 ADD       DX,2           { Use interrupt ID Regs
  34. }
  35.                 IN        AL,DX          { Read old value for 16550
  36. }
  37.                 AND       AL,$C0         { Check bit 7 & 6
  38. }
  39.                 XOR       AL,$C0         { BOTH bits are set ?
  40. )
  41.                 JZ        @BitsSet       { returns zero if both bits are set
  42. }
  43.                 MOV       AL,$00         { Bits not set then set back to zero
  44. }
  45.                 JMP       @StartCheck
  46. @BitsSet:       MOV       AL,$07         { Bits were set then set back to 1
  47. }
  48. @StartCheck:    MOV       OldState,AL    { Store it somewhere
  49. }
  50.  
  51.                 MOV       AL,$07         { Switch buffers on
  52. }
  53.                 CLI                      { Disable interrupts
  54. }
  55.                 OUT       DX,AL          { Write to interrupt ID register
  56. }
  57.                 IN        AL,DX          { Read fifo settings
  58. }
  59.                 MOV       BL,AL          { Put value in BL
  60. }
  61.                 MOV       AL,OldState    { Restore old value for fifo's
  62. }
  63.                 OUT       DX,AL          { Set int ID back to old value
  64. }
  65.                 STI                      { Enable interrupts
  66. }
  67.  
  68.                 XOR       AX,AX
  69.                 AND       BL,$C0         { Only leave bit 6 & 7
  70. }
  71.                 XOR       BL,$C0         { If both were set -> zero
  72. }
  73.                 JNZ       @GetOut
  74.                 INC       AL             { Both zero, $C0 was set
  75. }
  76. @GetOut:
  77. end; {Check16550Present}
  78.  
  79. This simply enables the fifo's. On UARTS without the fifo this doesn't work,
  80. on the 16550 it does. Com holds the base adress of the communications port.
  81.  
  82. Grtx
  83.  
  84. Jan Feijes
  85.  
  86. ... MCOMM : Tagging files by using the mouse
  87. --- GEcho/beta
  88.  * Origin: >> INTERFACE << +31-70-3361380/3361381/3360698 1,2 GIGA! (2:281/
  89. 506.50)
  90.  
  91. @PATH: 281/506 515 1 280/0 500/9 512/0 1007 
  92.