基于AT89C5131的接口设计
2010-05-13刘王莹,董春曦
刘 王莹,董春曦
摘 要:介绍计算机与设备、设备与其他模块间的通信。采用带有USB微控制器单片机芯片AT89C5131为通信的控制核心。AT89C5131是Atmel公司推出的芯片,有较快的处理速度和较大的存储容量,还可以在系统编程,是USB接口设计的理想选择。合理设计其外围电路并用Keil Uvision 3开发固件程序,主要针对USB接口、SPI接口和键盘接口的设计与程序开发。实现计算机和设备控制面板对设备的双重控制,以及计算机通过AT89C5131使用SPI等通信协议与其他设备模块的通信。这里将USB接口通信的输入与输出通道分割开来,提高了通信速度。
关键词:端口特性;USB通信;SPI通信;键盘设计
中图分类号:TP302文献标识码:B
文章编号:1004-373X(2009)12-028-03
Interface Design Based on AT89C5131
LIU Ying,DONG Chunxi
(School of Electronic Engineering,Xidian University,Xi′an,710071,China)
Abstract:Communication between computer and device,and communication between device and other modules are introduced.AT89C5131 with USB device controller is used as the processor which is produced by Atmel Corporation and has higher process speed and larger memory capability.AT89C5131 also allows in-system programming and it is a perfect choice for USB interface design.The peripheral circuit is designed rationally and the hardware program is developed with Keil Uvision 3,mainly about the design and development of USB,SPI and keyboard interface.It implements the double control from computer and device control panel to device and the communication between computer and other device module through AT89C5131 using SPI or other communication protocols.The input and output of USB interface communication is divided up,which improves the communication speed.
Keywords:port characteristics;USB communication;SPI communication;keyboard design
0 引 言
AT89C5131是一个基于52内核的单片机[1]。在存储器方面,其内部集成了32 KB的FLASH存储器用于代码的存储;1 KB的E2PROM存储器用于用户数据的存储;用户可以使用片上的Bootloader或FLASH API,通过USB接口或其他接口(如UART和I2C总线)对FLASH存储器和E2PROM存储器进行ISP或者IAP编程。AT89C5131支持USB 1.1和USB 2.0协议,拥有1个控制端口和6个普通可编程端口,支持控制、批量、中断和同步传输4种传输方式,还支持串行I/O接口模式及Master和Slave的SPI接口模式[2]。
1 系统硬件设计
基于AT89C5131的通信和控制模块主要完成以下功能:在通信方面,通过USB实现与计算机的通信,接收计算机对设备的控制命令和计算机发送的数据,并将设备的工作状态发送给计算机,同时将计算机传来的控制命令和数据通过SPI接口传送到其他设备模块,并收集其他设备模块的状态信息;在控制方面,AT89C5131负责收集设备控制显示面板的控制命令,更新设备显示状态等。……
