• 沒有找到結果。

在计算机系统中巧用

N/A
N/A
Protected

Academic year: 2022

Share "在计算机系统中巧用"

Copied!
4
0
0

加載中.... (立即查看全文)

全文

(1)

收稿日期: 2004- 03-23

作者简介: 王明洋, 男, 讲师, 主要从事电工、电子及通讯技术的教 学与研究。

在计算机系统中巧用 16C550 异步通信芯片的研究

王明洋1, 李 2

( 1. 武汉船舶职业技术学院电子电气工程系, 湖北武汉 430050;

2. 湖北省宜昌市 712 研究所, 湖北宜昌 443003)

要: 针对计算机通讯系统中多串口设备问题, 本文提出了用 16C550 异步通信芯片完 成多串口 功能, 进 行 了相应的软、硬件设计。经实际应用, 此四串口模块能够完成 七串口功 能, 并且 具有集 成度高、制作 成本低、

稳定性好等功能, 具有一定的应用价值。

关键词: 异步通信芯片; 16C550; 四串口.

中图分类号:TP33 文献标识码: A 文章编号: 1671-8100( 2004) 02- 0014-04

1 硬件设计

在计算机系统中, 为了协调主机与各外设之 间的 通讯, 需 要 用 到多 个 串 口, 此 时我 们 可 用 16C550 组成多串口模块。图 1 为笔者设 计的一 种四串口板的结构框图, 其底板采用 ISA 总线结 构。其设计思想是: 四串口板的每个串口主要由 16C550 芯片组成, 每个串 口通过 16C550 芯片 提 供串行异步收发数据和进行并行到串行 或串行 到并行的数据转换; 串行数据流的同步采用在发 送数据上增加起始位和停止位, 形成一个数据字 符( 面向规程的字符) 来完成。

如果四串口板的每个串 口都独立占用微 机 的一个中断资源, 那么微机的中断资源将会不够

[1]。为此, 可将多个串口设计为共享微机的一 个中断源, 并利用串口接口芯片的 FIFO 缓冲器, 实施高效可靠的串口通信。

该模块主要特点是:

( 1) 具 有四个 独立 的 RS- 232、RS- 422 或 RS- 485 串口( 通过跨接选定) ;

( 2) 在单个 微机 系统中 可支 持 2 块四 串口 板, 可外接 8 路串口;

( 3) 每个串口可以独立使用或共同使用一个 中断级;

( 4) 与标准 的 PC 串 口 COM1、COM2、COM3、

COM4 兼容。

图 1 四串口板的功能框图

14

在计算机系统中巧用 16C550 异步通信芯片的研究

(2)

2 软件设计

2. 1 对四串口板的初始化方法

对四串口板中的每一个串口, 其数据格式的 设置和波特率的设置与通常的 8250 UART 串口一 样, 只是在 中断设计、FIFO 控制等方面 不同。下

面分别加以说明。

( 1) 中断设置。16C550 的中断标识寄存器设 置是在原 8250 的基础上增加了一个附加位, 其设 置如表 1( 中断标识寄存器的地址为 COMBASE+

2, 其 中: COMBASE 为 16C550 的 IPO 基 地 址, 下 同。) 。

表 1 中断标识寄存器附加位

Bi-t 7 Bi-t 6 bi-t 5 Bi-t 4 bi-t 3 Bi-t 2 bi-t 1 bi-t 0 FIFO

允许

FIFO

允许 总为 0 总为 0 FIFO

中断位 见表 2 见表 2 见表 2

bi-t3: 当 FIFO 禁 止时( FIFO 控 制寄存 器的 bi-t 0 为 0) , 该位为 0; 否则, 该位被置 1, 就指示为 因超时而产生的发送器或接收器中断挂起, 当然 FIFO 超时也置位 bi-t 2, 即 FIFO 触发电平中断, 见 表 2。

bi-t 6 和 bi-t 7: 当 FIFO 禁止时( FIFO 控制寄存 器的 bi-t 0 为 0) , 该位为 0; 否则, 这两位总置 1, 但 它们不影响 FIFO 触发电平。

16C550 的中断标识码如表 2 所示。

表 2 16C550 的中断标识码

bi-t 3 Bi-t 2 bi-t 1 bi-t 0 优先级( 0 优先级最高) 中断标志

0 0 0 1 NONE NONE

0 1 1 0 0 串行化错误或 BREAK

0 1 0 0 1 FIFO 接收器触发电平

1 1 0 0 1 FIFO 超时

0 0 1 0 2 发送器缓冲器空

0 0 0 0 3 RS- 232 输入

( 2)FIFO 控制设置

16C550 将线路状态寄存器( 地址为 COMBASE + 5) 的 bi-t 7 设为 FIFO 重写标志。

16C550 将中断标识寄存器( 地址为 COMBASE

+ 2) 设计为读写寄存器, 在读模式时, 为中断标识 寄存器; 在写模式时, 为 FIFO 控制寄存器, 这个寄 存器的设置含义如表 3 所示。

表 3 16C550 的 FIFO 控制寄存器含义

Bi-t 7 Bi-t 6 bi-t 5 Bi-t 4 Bi-t 3 Bi-t 2 bi-t 1 bi-t 0 接收触发电平

Bi-t 7 Bi-t 6 触发电平

0 0 1

0 1 4

1 0 8

1 1 16

保留 保留 DMA 模式

选择

发送 FIFO 复位

接收 FIFO 复位

FIFO 允许

bi-t0: 该位写 1 时允许各个 FIFO 操作, 该位 写 0 将清除所有 FIFO 中的字符, 在寄存器其它位 写入之前, 该位必须为 1。

bi-t 1: 该位写 1 时清除来自接收器 FIFO 的所 有字节, 清除内部计数器, 但不清除移位寄存器, 该位写入的 1 被自动清除。

bi-t 2: 该位写 1 时清除来自发送器 FIFO 的所 有字节, 清除内部计数器, 但不清除移位寄存器,

该位写入的 1 被自动清除。

bi-t 3: 该位写 1 支持 DMA 操作。

bi-t 4 和 bi-t 5: 保留。

( 3) 16C550 的中断模式操作

由于使用的四串口板只用于接收方式, 因此, 这里主要讨论接收 FIFO 的处理情况。当 FIFO 和 接收器中断允许时( FIFO 控制寄存器的 bi-t 0= 1, 且中断允许寄存器的 bi-t 0= 1) , 接收中断将会发

15 武汉船舶职业技术学院学报

2004 年 第 2 期 Journal of Wuhan Institute of Shipbuilding Technology 2004 年 6 月

(3)

生如下的情形:

1) 当 FIFO 在程序触发电平到来时, 接收数据 的可用中断将被发送到 CPU, 并且当 FIFO 落在程 序触发下沿时, 就清除中断。

2) 当 FIFO 触发电平到达时, 中断标识寄存器 中接收数据可用的标识就产生了; 和中断一样, 当 FIFO 在触发下沿时就会被清除。

当 FIFO 中的计数低于程序触发电平时, 在经 过一段时间之后, 还没有字节进 入 FIFO, 16C550 就会发生超时中断。当 FIFO 中至少有一个字节, 并且最新接收的字节比以前接收的 4 个字节所化 时间还长或最近 FIFO 的 CPU 读字节比以前多化 4 倍以上的时间时, 就会发生超时中断。当 CPU 从 FIFO 读入一个字节时, 超时中断被清除且定时 器复位; 每当字节接收后或当 CPU 从 FIFO

中读入一个字节时, 超时中断定时器复位。

2. 2 程序流程

四串口板的初始化程序框图如图 2 所示, 中 断服务程序框图如图 3 所示。

图 2 四串口板的初始化程序框图

图 3 四串口板的中断服务程序框图 16

在计算机系统中巧用 16C550 异步通信芯片的研究

(4)

3 应用效果

在我们正在开发的某计算机通讯系统中, 需 要用到 7 个串口设备, 采用本文设计的两块四串 口模块完成了 7 个串口的功能。在应用过程中发 现: 将每块四串口板采用 CMOS 集成工艺制作在 一块硅片上, 提高了系统的集成度, 使整个系统的

设计更加简捷, 同时也降低了系统的制作成本, 另 外, 四串口板在很好地完成了单个 ST16C550 芯片 所有工作的同时, 利用四串口芯片的 FIFO 缓冲器 能够实现高效可靠的串口通信, 提高了系统的稳 定性和工作效率。

参考文献

[ 1] 陈光东. 单片微型计算机原理与接口技术[ M] . 武汉: 华中科技大学出版社, 2000.

( 责任编辑: 谭银元)

The Program & Application of Asynchronism Communication Chip 16C550

WANG Ming- yang, LI Yun

( Wuhan Institute of Shipbuilding Techonlogy, Wuhan 430050, China) No. 712 Research Institute in Yichang City, Hubei Province, Yichang 443003, China)

Abstract: This paper introduces the working principles and program outlines of the current popularly used asynchronism communication chip 16C550 and its related mult i- series interface board. A practical ap- plication example and program f low chart in which the mult-i series interfaces share a dicontinuity resource

is provided.

Keywords: asynchronism communicat ion chip; 16C550; share a discont inut ity resource; application pro- gram.

( 上接第 4 页)

Improving the Ideological and Ethical Education of the High Vocational Colleges with the Focus of Cultivating Professional Quality

MA Qi- ke

( Wuhan Institute of Shipbuilding Techonlogy, Wuhan 430050, China)

Abstract: the characteristic of the students in high vocat ional college is that they should have good pro- fessional quality which is directly relative to their future job as well as the development of the high voca- tional colleges. This paper points out that a special but suitable way can be found. The way is improving the students. ideological and ethical standards with the focus of professional virtue educat ion, improving the students. cultural quality with the help of the culture construct ion of the campus, strengthening their professional creative capability under the way of practice, and cult ivat ing their good professional psycho- logical quality.

Key words: professional quality; professional virtue; cultural quality; professional creative capability;

professional psychology.

17 武汉船舶职业技术学院学报

2004 年 第 2 期 Journal of Wuhan Institute of Shipbuilding Technology 2004 年 6 月

數據

表 2  16C550 的中断标识码

參考文獻

相關文件

The Government also established the Task Force on Promotion of Vocational and Professional Education and Training in April 2018 to evaluate the implementation

refined generic skills, values education, information literacy, Language across the Curriculum (

(b) reviewing the positioning of VPET in the higher education system in Hong Kong, exploring the merits of developing professional vocational qualifications at the degree

Wang, Solving pseudomonotone variational inequalities and pseudocon- vex optimization problems using the projection neural network, IEEE Transactions on Neural Networks 17

volume suppressed mass: (TeV) 2 /M P ∼ 10 −4 eV → mm range can be experimentally tested for any number of extra dimensions - Light U(1) gauge bosons: no derivative couplings. =>

Define instead the imaginary.. potential, magnetic field, lattice…) Dirac-BdG Hamiltonian:. with small, and matrix

incapable to extract any quantities from QCD, nor to tackle the most interesting physics, namely, the spontaneously chiral symmetry breaking and the color confinement.. 

• Formation of massive primordial stars as origin of objects in the early universe. • Supernova explosions might be visible to the most