Design and Implementation of Embedded Real-time Control Module Based on C51

Publisher:740322lwjLatest update time:2016-12-13 Source: eefocusKeywords:C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  With the development of modern communication technology, communication test instruments are constantly being innovated. Various new devices have higher and higher requirements for the real-time response capability of the system. The real-time response performance of a communication test instrument has become one of the key factors for the success of system design. The author has successfully applied ARM processors, C51 single-chip microcomputers and other embedded systems as the main control chips in multiple communication test instrument projects to achieve real-time control functions for instrument-related modules. Therefore, a design scheme using C51 single-chip microcomputers to achieve real-time control in a communication test instrument is proposed.

  1 Hardware Design and Implementation

  1.1 Overall design

  In this communication test instrument, the real-time control module mainly realizes the real-time control of the RF receiving frequency synthesis, RF generating frequency synthesis, filter components, RF input module, RF output module, etc. It performs A/D conversion on the RF detection signal to obtain data and communicates with the host computer, etc.

  According to the requirements of the system functions to be implemented, comprehensive consideration of system resources, chip cost-effectiveness and other factors, it was determined to adopt an embedded system solution with C51 microcontroller as the main control chip. The chip is Silicon Labs' C8051F120, which has 128 kB of on-chip Flash memory , 8×1 024+256 Byte of on-chip RAM, an external data memory interface with an addressable 64 kB address space, SPI, UART, timer, clock oscillator , PLL, etc. The on-chip peripheral resources are rich and easy to control.

   System resource allocation: RF receiving and transmitting modules, including DDS, PLL, etc., the external control interface is a microcontroller interface, so the address, data, and control buses of the microcontroller are directly used for control. The working status of the filter components, RF input/output modules, etc. is related to the signal level on the interface, so they are controlled by GPIO. The A/D conversion control uses the serial peripheral interface SPI. The communication with the host computer uses the RS-232 serial port. The overall design block diagram is shown in Figure 1.

  1.2 Design of bus and I/O control

   For the RF receiving frequency synthesis and RF transmitting frequency synthesis modules, bus control is directly adopted. In order to avoid mutual interference when different modules are controlled, the bus address is decoded by 3-8 decoder to generate chip select signals for different modules. At the same time, the data line passes through the bus transceiver to improve the load capacity. For the modules controlled by I/O, such as filter components and RF input/output, the GPIO pins of the 51 chip are not used directly. Instead, the data bus is latched and then simulated with GPIO signals for use by related modules, as shown in Figure 2, where IO_/WR1 is generated by B_/CS7 and the microcontroller write line logic OR.

  1.3 SPI and RS232 control interface

   The C8051F120 chip itself has an A/D converter, but it is only 12 bits, which is not suitable for the needs of the system, so an AD7707 from ADI is added outside the chip. Its resolution is 16 bits, it is a ∑-△ architecture, and it converts the average value of the input level. Three channels, the input level range can reach ±10 mV~±10 V. According to actual requirements, the system uses the AIN3 high-level input port, Unbuffered mode, HICOM and REF- connected to analog ground, VBIAS and REF+ are connected to +2.5 V reference voltage, analog power supply 5 V, digital power supply 3.3 V, and can detect unipolar levels with an input range of 0~10 V. Its control interface is a synchronous serial port, which is directly controlled by the SPI of the 51 chip. Figure 3 is the electrical connection diagram of AD7707.


   The communication between the microcontroller and the host computer uses the universal asynchronous receiver and transmitter UART, and the external MAX3224 converts the UART signal into RS-232 signal for transmission. The MAX3224 works at a low voltage of 3~5.5 V, but can generate ±12 V voltage of RS-232. Asynchronous serial communication can be achieved by simply connecting Tx, Rx and ground wires. There are still some clocks, reset circuits and power supplies in the system, which will not be described here.

  2 Software Design and Implementation

  2.1 Main program framework

  The main program flow chart is shown in Figure 4.

  The main program is a sequential structure and is relatively simple. It is mainly divided into two parts: one is to initialize the various parts of the system so that they can work in a normal state. The other is the normal working cycle state. When receiving the control command from the host computer, it will perform the corresponding operation, and wait when there is no command. For embedded programs, an infinite loop is necessary.

  2.2 Serial communication program

  The serial port communication program realizes the communication function with the host computer. In the specific operation, a circular queue is used to store the received host computer commands. The head pointer and tail pointer are used to point to the head and tail of the queue respectively, and each command byte is taken out to perform the corresponding operation. After the command is executed (the queue is empty), the flag is cleared and new commands are waited for. As shown in Figure 5.

  2.3 SPI communication program

   C51 uses SPI master mode to communicate with AD7707. It is relatively simple to write AD7707 in master mode. The microcontroller first writes 1 Byte of configuration data to AD7707, which will automatically put the data into its own communication register. Then AD7707 determines the register and data size to be written next based on the configuration value, and then puts the data subsequently input by the microcontroller into the specified position. Before sending data, C8051F120 first determines whether it can send data based on the value of the TXBMT bit of the SPICN register, and then writes data to its own SPIDAT register. The hardware will automatically send the data.

   It is difficult to read AD7707 in master mode. When C51 has set the communication register of AD7707, indicating that the next operation is to read a register value of AD7707, C51 writes an arbitrary value to SPIDAT, and then the data will be serially shifted out on the SPI data line (MOSI), and a serial clock will be generated on the clock line. The slave device (AD7707) receives the clock and sends the prepared data to the MISO line to C51, and does not adopt any value sent by the master device. C51 puts the sent serial data in the shift register, and when the last bit is received, it is shifted into the receiving buffer, and then the data can be read by reading SPIDAT.

  2.4 Other software modules

  Other software modules implement related functions by sending required data in sequence to the corresponding allocated address space according to the specific requirements of each hardware part.

  3 Conclusion

  This paper proposes an embedded system with C51 single-chip microcomputer C8051F120 as the core control chip, which has been successfully applied to a communication test instrument. The system has achieved a good real-time control function of the whole machine through interruption and query.


Keywords:C51 Reference address:Design and Implementation of Embedded Real-time Control Module Based on C51

Previous article:Detailed explanation of STARTUP.A51 of Keil C51
Next article:51 MCU low power working mode

Recommended ReadingLatest update time:2024-11-16 14:42

Keil C51 User Tutorial---Library Function Reference (V)
One of the important manifestations of C51's powerful functions and high efficiency is its rich library functions that can be called directly. Using library functions more often makes the program code simple, the structure clear, and easy to debug and maintain. The following introduces C51's library function system
[Microcontroller]
Explanation of code, data, bdata, idata, xdata, and pdata in Keil C51
The 8051 structure provides the user with 3 different storage spaces, program memory ROM, data memory RAM (internal RAM and external RAM). Keil C51 defines different storage types through the following keywords to ensure that users can access the entire storage space of the 51 architecture. code: Access the progra
[Microcontroller]
Explanation of code, data, bdata, idata, xdata, and pdata in Keil C51
Real-time control design of embedded system with C51 microcontroller as the core
With the development of modern communication technology, communication test instruments are constantly being introduced. Various new types of equipment have increasingly higher requirements for the real-time response capability of the system. The real-time response performance of a communication test instrument has be
[Microcontroller]
Real-time control design of embedded system with C51 microcontroller as the core
C51 Programming 25-Application (MCU and computer realize WiFi communication)
This article implements data communication between the microcontroller and the computer using the ESP-01S wifi module.  Set the baud rate of the WiFi module  Since the default baud rate of the ESP-01S wifi module is 115200, and the baud rate of the 51 microcontroller is usually set at 9600, it is necessary to set
[Microcontroller]
C51 Programming 25-Application (MCU and computer realize WiFi communication)
Single chip computer two machine communication c51 program
Project name: Dual-machine communication  Description: This program can realize mutual communication between two single-chip microcomputers; the serial port adopts mode 1         , 10-bit asynchronous reception and transmission, the baud rate is variable, and it is controlled by timer 1; and it contains checksum  Pro
[Microcontroller]
Manual counter design circuit diagram based on C51 single chip microcomputer
  Use AT89S51 single-chip microcomputer to make a manual counter. Connect a touch switch to the P3.7 pin of the AT89S51 single-chip microcomputer as a manual counting button. Connect a common cathode digital tube to the P2.0 - P2.7 of the single-chip microcomputer as the unit digit display of 00-99 counting. Connect a
[Microcontroller]
Manual counter design circuit diagram based on C51 single chip microcomputer
Serial communication between Labview and C51 microcontroller
There are two methods of Labview serial communication, one is to use visa (virtual instrument software framework), and the other is to call activeX control. The first method (VISA) program is shown in the figure First, set the serial port parameters, initialize the serial port, use VISA WITE in the loop to writ
[Microcontroller]
Talk about the memory allocation and optimization of C51 in Keil
After reading this article on memory allocation and optimization of C51, I personally think that the analysis is very thorough, so I share it with you here.   The memory allocation of C51 is different from that of general PC. The memory space is limited and uses overlay and sharing technology. In Keil compiler, after
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号