搜索
bottom↓
回复: 3

通信器件ST16C2552的使用感受

[复制链接]

出0入0汤圆

发表于 2007-10-6 23:16:43 | 显示全部楼层 |阅读模式
最近在开发中用到了ST16C2552器件。ST16C2552是用于串行数据通信的2通道通用带16字节收发FIFO的异步收发器(UART)。它的基本功能是将并行数据转换成串行数据,反之亦然。UART可处理高达5Mbit/s的串行数据速率。同时,ST16C2552自带了调制解调器的控制功能,由于我的项目较为简单,没有用到调制解调器功能。
    该器件使用起来并不难,硬件只要按资料的标准电路连接就行,需要通信中断功能,则将其中断信号引脚与单片机的外部中断引脚相连,软件方面只要进行好初始化就可以了。
参考代码:
假设器件地址为0x8000,通道A地址为0x8008-0x800F,通道B地址为0x8000-0x8007
#define CHA_RHR                (*(unsigned char *)0x8008)                /* read only */
#define CHA_THR                (*(unsigned char *)0x8008)                /* write only */
#define CHA_IER                (*(unsigned char *)0x8009)                /* write only */
#define CHA_FCR                (*(unsigned char *)0x800A)                /* write only */
#define CHA_ISR                (*(unsigned char *)0x800A)                /* read only */
#define CHA_LCR                (*(unsigned char *)0x800B)                /* write only */
#define CHA_MCR                (*(unsigned char *)0x800C)                /* write only */
#define CHA_LSR                (*(unsigned char *)0x800D)                /* read only */
#define CHA_MSR                (*(unsigned char *)0x800E)                /* read only */
#define CHA_SPR                (*(unsigned char *)0x800F)                /* read and write */
/* the three register sets are accessible when LCR bit7 is a logic 1 */
#define CHA_DLL                (*(unsigned char *)0x8008)                /* read and write */
#define CHA_DLM                (*(unsigned char *)0x8009)                /* read and write */
#define CHA_AFR                (*(unsigned char *)0x800A)                /* read and write */

#define CHB_RHR                (*(unsigned char *)0x8000)                /* read only */
#define CHB_THR                (*(unsigned char *)0x8000)                /* write only */
#define CHB_IER                (*(unsigned char *)0x8001)                /* write only */
#define CHB_FCR                (*(unsigned char *)0x8002)                /* write only */
#define CHB_ISR                (*(unsigned char *)0x8002)                /* read only */
#define CHB_LCR                (*(unsigned char *)0x8003)                /* write only */
#define CHB_MCR                (*(unsigned char *)0x8004)                /* write only */
#define CHB_LSR                (*(unsigned char *)0x8005)                /* read only */
#define CHB_MSR                (*(unsigned char *)0x8006)                /* read only */
#define CHB_SPR                (*(unsigned char *)0x8007)                /* read and write */
/* the three register sets are accessible when LCR bit7 is a logic 1 */
#define CHB_DLL                (*(unsigned char *)0x8000)                /* read and write */
#define CHB_DLM                (*(unsigned char *)0x8001)                /* read and write */
#define CHB_AFR                (*(unsigned char *)0x8002)                /* read and write */

        CHA_LCR = 0x83;               
        CHA_DLL = 0x0C;                // 1843200/16/9600 = 0x0C,9600BPS
        CHA_DLM = 0x00;
        CHA_AFR = 0x00;
        CHA_LCR = 0x03;                // divisor latch disable,access general register
       
        /* to COM B register init */
        CHB_LCR = 0x83;                // divisor latch enable,access special register
        CHB_DLL = 0x0C;                // 1843200/16/9600 = 0x0C,9600BPS
        CHB_DLM = 0x00;
        CHB_AFR = 0x00;
        CHB_LCR = 0x03;                // divisor latch disable,access general register
由于不使用调制解调器,初始化很简单了,以后只要向CHA_THR或CHA_THR就能发送数据,接收数据则是读CHA_RHR或CHA_RHR


ST16C2552器件资料
点击此处打开ourdev_175503.pdf(文件大小:375K)
SC16C2552与ST16C2552器件兼容
点击此处打开ourdev_175504.pdf(文件大小:502K)

阿莫论坛20周年了!感谢大家的支持与爱护!!

你熬了10碗粥,别人一桶水倒进去,淘走90碗,剩下10碗给你,你看似没亏,其实你那10碗已经没有之前的裹腹了,人家的一桶水换90碗,继续卖。说白了,通货膨胀就是,你的钱是挣来的,他的钱是印来的,掺和在一起,你的钱就贬值了。

出0入0汤圆

发表于 2007-10-6 23:22:01 | 显示全部楼层
好东西,谢谢楼主分享,,

我最近也用到一个相似的器件

不过我只做硬件部份..            相关时序我也都看过了. 感觉还挺好用

出0入0汤圆

发表于 2007-10-8 11:43:08 | 显示全部楼层
感谢共享!

出0入0汤圆

发表于 2014-8-26 21:18:48 | 显示全部楼层
感谢分享,我最近也在弄这个,细节决定成败
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-10-3 09:17

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表