serial port (2) 初始化com口
来源:互联网 发布:服务器系统优化 编辑:程序博客网 时间:2024/06/05 18:26
如何让com口工作在中断模式:
1, 在8259中把com口对应的中断打开
2, MCR BIT3(OUT2)设1(X86架构)
3, IER 把需要的中断置起来,
如何让com口工作在FIFO模式:
1。设置FCR BIT0让COM知道下面是设置FIFO模式的命令。
2。设置FCR BIT7-BIT6 来决定缓冲大小
0 0 1byte
0 1 4byte
1 0 8byte
1 1 14byte
3. 设置FCR BIT3来 启动FIFO模式
下面这段代码就是初始化COM口,并工作在FIFO模式。
Sample Code
; Set IRQ enable and out2 to set enable interrupts
mov cl, COM_IRQ ;
mov dx, 21h
cmp cl,7 ; judge IRQ > 7
jbe short wlsp_00
mov dx, 0a1h
sub cl, 8
wlsp_00:
in al, dx ; Program Interrupt Controller to
mov ah, 01
shl ah, cl
xor ah, 0FFh
and al, ah
out dx, al
mov cl, COM_IRQ ;
cmp cl, 7
jbe wlsp_01
in al, 21h
and al, 0FBh
out 21h, al
wlsp_01:
mov bh, MCR ; Modem Control Register
call Read_COM_Reg ; Read the reg to
mov bh, MCR
mov bl, 008h ; set out2 to set enable interrupts
call Prog_COM_Reg ; Program the reg
; Set Enable Buad_Rate
mov bx, 0383h ; Prog 3FB reg to
; Data Bits =8, Access baud rate generator
call Prog_COM_Reg
; Program the baud rate divisor
mov bh, 00h ; Prog 3FB reg to set
mov bl, DIVISER ; Baud rate divisor LSB
call Prog_COM_Reg
mov bx, 0100h ; Prog 3F9h reg to set
; Baud rate divisor MSB
call Prog_COM_Reg
; Reset DLAB, program 8 bits, 1 stop bit, no parity checking
mov bx, 0303h ; 3FB, 8 Bits per char
call Prog_COM_Reg
; Program COM port Interrupt Enable Register
mov bx, 0100h ; Prog 3F9 Reg to
; disable THRE, line status,
; modem-status-change, data available int
call Prog_COM_Reg
; FIFO Control Register
mov bx, 0201h ; Prog 3FA reg to
; enable FIFOs
call Prog_COM_Reg
mov bx, 02C7h ; Prog 3FA reg to
; 14-byte level trigger, TX FIFO reset,
; RX FIFO reset, enable FIFO
; Clear FIFOs, 14-byte level
call Prog_COM_Reg
; Interrupt Ident Register
mov bh, 02h ; 3FAh reg
call Read_COM_Reg
; Modem Conltrol Register
mov bx, 040Bh ; Prog 3FC reg to
; Activate DTR, RTS, OUT2
call Prog_COM_Reg
; Interrupt Enable Register
mov bx, 010Fh ; Prog 3F9 reg to
; enable THRE, line status,
; modem-status-change, data available int
call Prog_COM_Reg
; Line Status Register - LSR
; reset the LSR
; reset IIR
mov bh, 05h ; 3FDh reg
call Read_COM_Reg
; Modem Status Register - MSR
; reset MSR
; reset IIR
mov bh, 06h ; 3FEh reg
call Read_COM_Reg
系列文章连接
CMO 1
- serial port (2) 初始化com口
- Serial Port
- SerialPort (RS-232 Serial COM Port) in C# .NET
- How to change your USB Serial Port COM number?
- TTL To UART RS232 COM Serial Port Adapter Cable
- 在VMware虚拟机机下,为什么添加串口,只有serial port 2, 没有serial port
- Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems
- Java serial port design
- SERIAL PORT ABCs
- Configuring a Serial Port
- iPhone serial port communication
- vmware serial port连接
- boost asio serial port
- iPhone serial port communication
- WRT54GS Serial Port
- Serial Port For STM32
- error opening serial port
- ROS serial port programming
- 搞垮他的数据库--谈Oracle安全
- java关于日期的运算等处理方法
- 教菜鸟写注册机——实战篇
- 玩转DC---拍出美丽夜景
- 收藏夾
- serial port (2) 初始化com口
- 摄影基础知识汇总
- SoapExtension 1.0 的问题与解决
- 最实用 DC终极扫盲大辞典! --- 让你对DC完全了解的88条名词解释(一)
- 使用Visual C#实现断点续传
- 数码相机扫盲大辞典
- [译]The other ways to detect OllyDbg 检测OllyDbg的另类方法
- XML入门精解之结构与语法
- 说一下偏振镜