As modern industrial production and scientific research place increasing demands on data acquisition systems, transmission speed, error correction capability, and
ease of operation and installation are issues that people have always been concerned about when collecting data. This makes data communication technology inevitably
become a key technology, and the interface used by the data acquisition system for data communication is
one of the important factors affecting the overall efficiency of the system. USB (Universal Serial Bus) bus interface technology
has gradually become the development trend of modern data transmission due to its advantages such as fast speed, easy equipment installation and configuration, easy expansion, bus power supply, and flexible use [1-5].
This paper presents a USB interface design scheme for a data acquisition system based on C8051F320, completes the USB interface
hardware circuit design and software program development, and applies it to the warehouse video surveillance system to achieve fast and convenient data acquisition
and transmission.
2 Principle of C8051F320 MCU
2.1 Main Features of C8051F320
C8051F320 is a small MCU for USB devices in the C8051F series MCU launched by Cygnal Corporation of the United States
. The device integrates 2304 Byte RAM and 16K Byte Flash memory. Since the
chip does not require any external components (including resistors and crystal oscillators) when designing, it is an ideal
choice for small USB applications. Compared with other similar USB products, C8051F320 has the following main features:
① Meets USB2.0 protocol;
② Can run at full speed (12 Mbps) or low speed (1.5 Mbps);
③ Integrates a clock source, no external crystal is required for full-speed or low-speed transmission;
④ Supports 8 flexible and universal USB endpoints;
⑤ Built-in a 1K USB dedicated buffer memory;
⑥ Integrates a USB receiver and does not require external resistors.
⑦ It has a high-speed enhanced 8051 MCU core, which adopts a pipelined instruction structure. 70% of the instructions
are executed in one or two system clock cycles, and the processing speed can reach 25MIPS (when the clock frequency is 25MHz).
In addition, C8051F320 has many other features, such as support for in-system programming (ISP), with programmable digital I/O
and digital cross switches, and can provide full-speed, non-intrusive in-system chip debugging circuits.
2.2 Pins and Package
of C8051F320 The pin arrangement of C8051F320 is shown in Figure 1, and the package is TQFP-32. VDD is the digital power supply; GND is the analog ground; REGIN is the input terminal of the 5V calibrator; RST/C2CK is the reset pin of the device or the clock signal of the EC2 debug interface; P3.0/C2D is the bidirectional signal pin of port P3.0 or EC2 debug interface; VBUS is the USB bus input pin; D+ is the D+ of USB; D- is the D- of USB; P0.2/XTAL1 is port 0.2 or external crystal input;
P0.3/XTAL2 is the output of port P0.3 or external crystal oscillator; P0.6/CNVSTR is
the input pin of port P0.6 or ADC0 external conversion start; P0.7/VRFF is the input or output of port P0.7 or external reference power supply; P0.0, P0.1, P0.4,
P0.5, P1.0~P1.7, P2.0~P2.7 are all corresponding port pins.
3 USB interface circuit design
3.1 USB interface hardware circuit design
Since the C8051F320 microcontroller has an integrated USB receiver, it is simple and easy to use. Therefore,
the hardware design of the USB interface is relatively simple. It mainly includes two parts: one is
the selection of the power supply mode of the interface conversion module, and the other is the connection of the USB pin. Figure 2 is the USB interface circuit diagram. The module selects the self-powered mode.
The power supply of the entire module shown in Figure 2 comes from an external 5V power supply. The USB transceiver in the C8051F320 has integrated
pull-up resistors, which can be directly connected to the USB interface without any external devices.
Figure 2 USB interface connection circuit diagram
3.2 USB Device Firmware Programming
The USB device firmware program is a part that must be implemented by the USB device. Its main purpose is: when the USB device is connected
to the host, the host can discover the new device, then establish a connection and complete the data transmission task, that is, it can enable the host
to detect and identify the USB device normally. Therefore, the purpose of this firmware design is to enable the host to identify the C8051F320
device and communicate with it correctly. At the same time, in order to achieve the maximum transmission speed on the USB, the C8051F320 firmware is designed to be interrupt-driven.
The firmware of C8051F320 is divided into two parts: the foreground main program and the background interrupt service program (ISR). In
the USB firmware
program, the most important work is the definition of USB descriptors and the processing of USB transmission interrupts.
USB descriptors are a set of fixed-structure description languages defined by the USB protocol to describe the functions and properties of devices.
The descriptors in USB2.0 include 8 standard descriptors such as device descriptors, configuration descriptors, interface descriptors, endpoint descriptors,
and some other non-standard descriptors. The USB host completes the identification and configuration of the device type through the USB descriptor, and the client
driver uses this information to correctly access the device and communicate with it. In the configuration of C8051F320, this article
uses endpoint 1 and endpoint 2 in addition to endpoint 0. Their descriptors are shown in Table 1.
The processing of USB transmission interrupts is also an important part. The processing of transmission interrupts
is completed by the ISR and the foreground main program. The data exchange between these two parts is realized through event flags and data buffers [6]. When the USB engine of C8051F320
receives a data packet from the host, an interrupt request will be generated. C8051F320 will respond to the interrupt immediately and
determine the interrupt source (USB
reset interrupt, endpoint 0 interrupt, endpoint 1 input interrupt, endpoint 2 output interrupt)
by reading the three interrupt registers CMINT, IN1INT and OUT1INT of the
USB function controller. Then, according to different interrupt sources, it will jump into the corresponding processing module to perform different interrupt processing and return after processing. Among them, endpoint 0 is the
default control transmission endpoint that every USB device must support. It is mainly used for the host to configure the USB device, obtain status information
and correct device errors. Its interrupt processing module consists of two parts: control output and control input. Each transmission
starts with setting the transaction, then jumps into the corresponding processing module according to the different interrupt sources of the setting transaction data to perform different
interrupt processing, and returns after processing. At the same time, in the ISR, the firmware moves the data packet from
the internal buffer of the USB engine of C8051F320 to a custom data buffer, and then requests to clear its internal buffer so that it can continue to
receive new data packets. Then it returns to the main loop, checks whether there is new data in the custom buffer and starts other
tasks. Due to this structure, the main loop only needs to check the new data that needs to be processed in the custom buffer, focusing on
the processing of new data, and the ISR can also transmit data at the maximum speed. In this way, the program's operation of USB is simpler and it is also
convenient for program maintenance. The control transmission program flow of the main program and endpoint 0 is shown in Figure 3 and Figure 4 respectively. The program flow of endpoint 1 and endpoint
2 is similar.
4 Data reception and display
After installing the driver based on C8051F320 USB device in the host (which can be downloaded from Xinhualong website),
the device will be set as a serial port of the host by default. Therefore, it can be treated as a virtual serial port in the host processing
. Reading its data is as convenient as reading serial port data. A fast communication platform can be established quickly.
The host software is developed by VC++, and the serial communication part is directly written by API function. It
provides the application with a method to send and receive data through the serial interface. The host software uses API file function to control serial communication.
For specific functions and usage, please refer to MSDN.
The USB interface circuit based on C8051F320 is applied to the warehouse video monitoring system, and its system structure diagram is shown in Figure 5.
5 Conclusion
This paper uses the characteristics of C8051F320, such as fast speed, strong processing ability and simple structure, to design a
USB interface solution for data acquisition system based on C8051F320, gives the specific design method of USB interface circuit, and
develops the data and display of the host. Applying the designed USB interface to the warehouse video surveillance system can realize fast and convenient
data transmission, and the data communication can reach a transmission rate of megabytes, meeting the requirements of real-time and fast data transmission.
Previous article:Design of Multi-channel Data Acquisition System Based on PCI Bus
Next article:Serial communication level conversion and isolation circuit
Recommended ReadingLatest update time:2024-11-16 21:59
- 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)
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- 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
- SHT31 Review + Unboxing Test
- How to obtain high-frequency equivalent models of devices such as varistors and TVS transient diodes
- MicroPython uses the new neopixel driver
- Review Weekly Report 20220509: Saifang RISC-V Linux Starlight Board is coming, how is the Xianji 800MHz HPM6750 tested?
- How to set default rules for Altium drawing?
- Matlab and Modelsim co-simulation error
- ST NUCLEO-G071RB evaluation application - Come and experience the new generation of entry-level 32-bit STM32, giving you the best cost-effective experience
- Security innovation, a new verification method. Download Fujitsu's "Spectrum Verification Solution" white paper and get a gift!
- Which forum member has a deeper understanding of MOS tubes? I usually overlook some parameters when reading the specification, and I want to understand them all today. Know...
- How to configure the SSH service of Win10 Linux subsystem