刘智勇+陈鹏飞+宿磊+廖广兰
摘 要: 基于STM32F107VCT6微控制器,在μC/OS?Ⅲ系统下针对U盘与SD卡之间的文件传输进行研究。控制器分别通过SPI串行总线和OTG接口与SD卡和U盘实现数据传输,控制系统通过FATFS文件系统将U盘的文件数据存入控制器的缓存之中,再将数据写入SD卡,实现了U盘与SD卡之间的数据传输。实验表明:该文件传输原理简单、功能稳定,可广泛应用于日常生活和工农业的小型嵌入式设备当中。
关键词: STM32; μC/OS?Ⅲ; U盘; SD卡; 文件传输
中图分类号: TP274.2 文献标识码: A 文章编号: 1004?373X(2014)18?0107?03
Study on file transmission between U disk and SD card based on STM32 chip
LIU Zhi?yong, CHEN Peng?fei, SU Lei, LIAO Guang?lan
(State Key Laboratory of Digital Manufacturing Equipment and Technology, Huazhong University of Science and Technology, Wuhan 430074, China)
Abstract: The file transmission between U disk and SD card in the μC/OS?Ⅲsystem based on STM32F107VCT6 chip is studied in this paper. The controller achieves data transmission by SD card and U disk respectively through SPI serial bus and USB OTG interface. The control system saves the file data of U disk into the cache of controller itself by FATFS file system, and then writes the data into the SD card to realize the data transmission between USB and SD card. The file communication mode is simple and stable, and can be widely applied to small embedded devices used in daily life, agriculture and industry.
Keywords: STM32; μC/OS?Ⅲ; U disk; SD card; file transmission
随着科技的发展,微控制器成本越来越低,性能越来越强大,这使得其应用越来越广泛,遍及各个领域之中。由于控制器本身的存储空间是非常有限的,因此通常自身不承担存储大量数据的任务,而由控制器的外设比如SD卡、U盘等存储设备承担。本文以ARM微控制器STM32F107VCT6作为系统的核心,针对SD卡、U盘外围存储设备的通信进行了研究,详细分析了它们之间文件传输过程。
1 硬件设计
1.1 STM32F107VCT6
STM32F107VCT6是意法半导体公司(ST Microelectronics,ST)推出的一款STM32互联型微控制器。该控制器集成了各种高性能工业标准接口,且STM32不同型号产品在引脚和软件上具有完美的兼容性,可以轻松适应更多的应用。它包括10个定时器、2个12位A/D(模/数转换器)、2个12位D/A(数/模转换器)、2个I2C接口、5个USART接口和3个SPI端口和高质量数字音频接口IIS,另外STM32F107拥有全速USB(OTG)接口,2路CAN2.0B接口,以及以太网10/100MAC模块,可以满足工业、医疗、自动化和家电市场等多种需求[1]。采用32位ARM Cortex?M3内核,最高运行频率可达72 MHz。
1.2 SD卡接口电路设计
SD卡支持两种接口访问模式,即SDIO模式和SPI(Serial Peripheral Interface)模式。……