At present, USB flash drives have become one of the most commonly used mobile storage devices due to their small size, easy to carry, large capacity, and convenient use. However, people have always used USB flash drives only for communication between USB flash drives and computers. If you want to transfer the contents of multiple USB flash drives to each other, you must do it through computer connection, which is troublesome and cannot meet people's needs to dump data anytime and anywhere when they are out. In response to this demand, this paper designs a USB flash drive dumper with C8051FD40 microcontroller as the core, which can realize the data exchange between two USB flash drives without using a computer. It has the advantages of small size, fast transmission speed, convenient operation, and low hardware comprehensive cost.
1 System Hardware Design
1.1 System overall structure and working principle
The system consists of a power module, a USB interface dump module, a control module, a keyboard module, and a liquid crystal display module, as shown in Figure 1. The C8051F040 microcontroller is connected to two CH375 USB flash drive modules. By opening a data buffer inside the microcontroller, the subroutine library is directly called to transfer the selected file data in one USB flash drive to another USB flash drive. The liquid crystal and external keyboard realize the human-machine interface. The file to be transferred is selected through the up, down, select, copy and other buttons on the keyboard, and the file name, file size and other related information are displayed in the liquid crystal module. The human-machine interaction interface is friendly and easy to operate.
1.2 CH375 USB flash drive module
The CH375 USB flash drive reader/writer module developed by Zhennan Electronics is used. The module is small in size, only 3.3x2.0 cm2. The module is powered by 5 V and is equipped with an indicator light, which is lit when working. The module uses the USB master-slave controller CH375B and is driven in parallel to realize the reading and writing of the USB flash drive. A total of 13 signal lines are required (5 control lines and 8 data lines).
The znFAT provided by this module is a FAT32 file system solution on a single-chip microcomputer, which can easily realize various file-level applications on the U disk. It mainly includes some basic file operations such as file sector positioning, file opening, information modification, file closing, file deletion, file reading, file writing, and disk information query. This module has the characteristics of small size, low price and easy use. Through this module, it is easy to transfer related files between two U disks through a single-chip microcomputer.
The connection between CH375 U disk read/write module and C8051F040 microcontroller is shown in Figure 2. C8051F040 selects the U disk module through CS, and the U disk module communicates with the microcontroller in interrupt mode through INT. DO~D7 are the parallel communication data lines between CH375 U disk module and microcontroller, and the microcontroller controls CH375U disk module through AO, RD, and WR control signals. D+ and D- are the serial interfaces between CH375 U disk module and USB storage device. Through CH375 U disk module, it is easy to realize direct data dump between microcontroller and USB storage device.
1.3 LCD display module
This system uses the MGLS12232 LCD module with 122x32 dot matrix. The module has two 2.560-bit RAMs and two SED1520 controllers built in. The left and right half screens are controlled by two selection signals, E1 and E2. There are two connection methods for graphic LCD modules: one is direct access method and the other is indirect control method. This system uses direct control method, which directly connects the interface of the LCD module as a memory or I/O device to the microcontroller bus. The module is small in size, low in price and can meet the display of general folder names, file names and file information through the LCD module. [page]
1.4 Keyboard Module
The keyboard module is a 3x3 matrix keyboard structure, using Button keys, which define the power-on, reset, page up, page down, select, copy, paste and other keys, so as to realize various file dump operations with the least number of keys.
1.5 C8051F040 MCU Control Module
The C8051F040 microcontroller control module is the core control module of this system. The microcontroller has rich on-chip resources and powerful control functions: it is fully compatible with 8051, the maximum system clock frequency is 24 MHz, and the execution time of 70% of the instructions is 1 or 2 system clock cycles. Rich interrupt sources, the extended interrupt system provides 20 interrupt sources to CIP-51. An interrupt-driven system requires less MCU intervention, so it has higher execution efficiency. So many interrupt sources can fully meet all the peripherals of this system. Universal Serial Bus (USB) function controller, with 8 flexible endpoint pipelines, integrated transceiver and 1K FIFO RAM; large on-chip storage, CIP-51's SFR address space can contain up to 256 SFR pages. Through SFR paging, CIP-51MCU can control a large number of SFRs required for controlling and configuring on-chip peripherals. Rich serial port resources, with two enhanced full-duplex UARTs, an enhanced SPI bus and SMBus/I2C. Each serial bus is fully implemented in hardware and can generate interrupts to the CIP-51, so very little CPU intervention is required. These serial buses do not "share" resources such as timers, interrupts, or port I/O, and any one or more can be used simultaneously.
The function of this module is to cache the file data to be transferred between two USB flash drives by opening a data buffer inside the microcontroller, and to control the opening, reading, writing and closing of USB flash drive files through two CH375 USB flash drive modules to achieve the transfer of file data. The control unit can also process the interrupt information sent by the peripheral keyboard to achieve the control of the microcontroller such as file selection. Some relevant file information is displayed by controlling an MGLS12232 LCD display module.
2 System Software Design
2.1 Peripheral control method
This system uses the CH375 U disk module, which comes with znFAT, a FAT32 file system solution on the microcontroller. This reduces the complicated programming of the Fat32 file system. Since the CH375 U disk module is equipped with a file system and file operation subroutines, it is easier to realize the LCD display of file names and file information, as well as file selection and transfer operations through the microcontroller main program call.
Since the C8051F040 microcontroller has rich interrupt resources, and interrupts have the following advantages:
1) Time-sharing operation. The CPU can serve multiple I/O devices in a time-sharing manner, thus improving the utilization rate of the computer.
2) Real-time response. The CPU can handle random events of the application system in a timely manner, greatly enhancing the real-time performance of the system.
3) High reliability. The CPU has the ability to handle emergencies such as equipment failure and power failure, thereby improving the reliability of the system.
In summary, all peripheral keyboards in this system are controlled by interrupts, and file transfer is also controlled by interrupts. In this way, the utilization efficiency of C8051F040 system resources has been greatly improved.
2.2 File Dump Solution
First, a buffer is opened inside the C8051F040 microcontroller. When a file needs to be transferred, first select a file in a USB flash drive. When the copy and paste buttons are clicked, the relevant program will be automatically called through an interrupt to open the file, read the file data from the opened buffer, and then store the buffer data in a newly created file with the same name in the corresponding directory of another USB flash drive.
The overall flow chart of the system is shown in Figure 3. After the system is powered on, the buffer zone opened inside the C8051F040 microcontroller is initialized, and the LCD screen displays the initial interface, and then enters the state of waiting for the USB flash drive to be inserted. After waiting for a period of time, if no USB flash drive is inserted, the prompt message "Please insert the USB flash drive" is displayed. When the number of USB flash drives is one or two, the USB flash drive information is read and basic USB flash drive information is displayed on the LCD screen. After that, the C8051F040 microcontroller waits for keyboard operation, calls the corresponding interrupt program according to the code input by the keyboard, and after processing, continues to wait for the interrupt signal from the keyboard.
3 Online debugging
The two USB interfaces of the USB dumper are connected to two USB disks A and B respectively. The LCD screen can display the files in USB disk A. The files in USB disk A can be selected by manually operating the keyboard buttons on the dumper and can be transferred to USB disk B. The most difficult part in the production of this USB dumper is to debug the program on the device side. Due to the strict requirements of the USB protocol, the program must perform certain requests or states within the valid time, otherwise the USB will not work properly. Therefore, in the debugging process, some information output by the serial port output program is often used to assist debugging and locate the problem.
The debugging work is mainly divided into two steps. The first is to be able to display the files in the U disk. With the help of PC debugging software (Bus Hound downloaded from the Internet), the USB protocol on the device side is adjusted, and then the U disk is added to write the U disk display program. The file name in the U disk can be seen on the LCD screen; the second step is dump, writing the dump program in the microcontroller for debugging. Dumping files can be realized by selecting the keyboard button.
4 Conclusion
Although there are functional modules for microcontrollers to read and write USB flash drives on the market, they can only realize simple reading functions, and cannot realize direct transmission and display between two USB flash drives. The USB flash drive dumper designed in this paper has been shown to be very practical and operable through experiments. People can easily complete the file dump from one USB flash drive to another without the help of a computer outdoors. Because the USB interface uses a very fast transmission speed, it can fully meet the needs of ordinary users. The system uses STM packaging, has the advantages of small size and easy to wear, and is a cheap and practical electronic product.
Previous article:Temperature collection and wireless transmission system based on single chip microcomputer
Next article:Design of a multi-purpose intelligent temperature measuring instrument
Recommended ReadingLatest update time:2024-11-16 19:39
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Summary of Verilog non-synthesizable statements...
- Initialization operations required for C51 microcontroller to output printf
- [Exploration of RTOS and Linux controller cycloneDDS communication and encryption protection] A preliminary study of AC6 development environment
- How to achieve low power consumption when porting a program from MSP430FR4133 to MSP430FR6972?
- The latest proteus 8.9sp2
- Bidirectional 400V-12V DC/DC Converter Reference Design
- 6G is on the way, what is the terahertz technology behind it?
- 100W24v output board, change to 12V output
- How to copy the files used in the compiler and IDE installation directory to the project folder when creating a new CCS project
- Idle series--DIY an Openmv4R