C8051F320 MCU principle, pins and package

Publisher:fengtingLatest update time:2012-04-16 Keywords:C8051F320 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:C8051F320 Reference address:C8051F320 MCU principle, pins and package

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

MCU Implementation of Satellite TV Receiver Control
STC001 is a high-performance, low-cost satellite TV receiver control chip. Different from the traditional ASIC implementation, it implements related functions in the form of 8-bit MCU with software. An obvious advantage over ASIC is that it can realize multiple functions of the chip by modifying the equipped softwar
[Microcontroller]
MCU Implementation of Satellite TV Receiver Control
Design of constant current source controlled by C8051FF330D single chip microcomputer
  0 Preface   In the rapidly developing electronic and telecommunication technology systems, the quality of the power supply determines the performance and life of telecommunication equipment to a certain extent. Therefore, people's demand for programmable constant current devices is becoming increasingly urgent. Al
[Microcontroller]
Design of constant current source controlled by C8051FF330D single chip microcomputer
Playing with STM8 microcontroller (Part 2)
Now when learning STM8, since ST has provided standard driver library functions, the requirement for C language ability is very weak. As long as you have taken a college C language course, you can program it. But I suggest you learn C language in depth. Its core is pointers. If you can play with pointers, you will u
[Microcontroller]
[Self-study 51 single-chip microcomputer] 8 -- Key learning, single-chip microcomputer minimum system
1. MCU minimum system power supply 5v and 3.3v are common in MCU. "5v" and "3.3v" are just their typical values ​​for normal operation. 5v and 3.3v MCU are also named after their typical values ​​for normal operation. The standard range of their normal operating voltage should be checked in the MCU manual. Crystal O
[Microcontroller]
[Self-study 51 single-chip microcomputer] 8 -- Key learning, single-chip microcomputer minimum system
Pluggable Battery Charging Station Based on RA6M1/RA6M3 Microcontroller
With the development of new energy vehicles and power battery industries, pluggable battery charging methods may become the future trend of electric vehicle (EV) battery charging. This small charging station is not only highly autonomous but also easy to operate. Under ideal conditions, users can greatly shorten the
[Embedded]
Pluggable Battery Charging Station Based on RA6M1/RA6M3 Microcontroller
Analysis of single chip microcomputer interface technology for reading LCD electrode data
Picking up the measured signal through the measuring instrument is a common data acquisition method in the design of the single-chip microcomputer forward channel. Usually, the interface circuit obtains the relevant analog signal from the instrument circuit and sends it to the single-chip microcomputer after A/D con
[Microcontroller]
Analysis of single chip microcomputer interface technology for reading LCD electrode data
STC series MCU program burning method
The STC microcontroller has the function of programming through the serial port. It is so simple that the program can be burned into the microcontroller through three wires of the serial port 3. This greatly facilitates the developers and saves the expensive and complicated programmer. When debugging the program, the
[Microcontroller]
STC series MCU program burning method
Application design of single chip microcomputer in electromagnetic cooker
1 Introduction   The electromagnetic cooker is an advanced electronic cooker for cooking food in modern families, which uses the principle of electromagnetic induction for heating. It is very convenient to use and can be used for various cooking operations such as boiling, frying, frying, steaming, and stir-frying.
[Microcontroller]
Application design of single chip microcomputer in electromagnetic cooker
Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号