How to implement embedded real-time control module

Publisher:美好回忆Latest update time:2023-09-04 Source: elecfansKeywords:Embedded 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 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 become one of the key factors for the success of the system design. The author has successfully used embedded systems such as ARM processors and C51 microcontrollers as main control chips in multiple communication test instrument projects to achieve real-time control of instrument-related modules. Therefore, a design scheme is proposed to use C51 microcontroller to achieve real-time control in a certain communication test instrument.


1 Hardware design and implementation

1.1 Overall scheme design

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


According to the functional requirements of the system to be implemented, comprehensive consideration of system resources, chip cost performance and other factors, it is 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 on-chip Flash memory, 8TImes ; 1 024+256 Byte on-chip RAM, which can address external data memory interfaces, SPI, UART, timers, clock oscillators, PLL, etc. in the 64 kB address space. The on-chip peripherals are rich in resources and easy to control.

System resource allocation: RF receiving and transmitting integrated modules, including DDS, PLL, etc. The external control interface is a micro-control interface, so the three buses of address, data and control of the microcontroller are directly used for control. The working status of filter components, RF input/output modules, etc. is related to the signal level on the interface, so it is 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.

How to implement embedded real-time control module

1.2 Design of bus and I/O control

For the radio frequency receiving frequency synthesis and radio frequency transmitting frequency synthesis modules, bus control is directly used. In order to avoid mutual interference when different modules are controlled, a 3-8 decoder is used to decode the bus address and 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 I/O-controlled modules such as filter components and radio frequency input/output, the GPIO pins of the 51 chip are not directly used. Instead, the data bus is latched and the simulated GPIO signal is used by the relevant modules, as shown in Figure 2. , among them, IO_/WR1 is generated by B_/CS7 and the microcontroller write line logical OR.

How to implement embedded real-time control module

1.3 SPI and RS232 control interface

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

How to implement embedded real-time control module

The communication between the microcontroller and the host computer uses a universal asynchronous receiver-transmitter UART, and is connected to an external MAX3224 to convert the UART signal into an RS-232 signal for transmission. The MAX3224 operates at a low voltage of 3~5.5 V, but can generate the ±12 V voltage of RS-232. , just connect Tx, Rx and ground wires to achieve asynchronous serial communication. There are still some clocks, reset circuits and power supplies in the system, which will not be described in detail here.


2 Software design and implementation

2.1 Main program framework

The main program flow chart is shown in Figure 4.

How to implement embedded real-time control module

The main program has a sequential structure and is relatively simple. It is mainly divided into two parts: First, initialize and set up each part of the system so that it can work in a normal state. The second is the normal working cycle state. When receiving the control command from the host computer, it will perform the corresponding operation. If there is no command, it will wait. For embedded programs, infinite loops are necessary.

2.2 Serial communication program

The serial communication program implements 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. Each command byte is taken out and the corresponding operation is performed. After the command is executed (the queue is emptied), the flag bit is cleared and waiting for new commands. As shown in Figure 5.

How to implement embedded real-time control module

2.3 SPI communication program

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

Reading the AD7707 in master mode is more difficult. When C51 has set the communication register of AD7707, indicating that the next operation is to read a register value of AD7707, C51 writes any value to SPIDAT, and then the data will be serially shifted out on the SPI data line (MOSI), and at the same time, a serial number will be generated on the clock line. Row clock, the slave device (AD7707) receives the clock, sends the prepared data to the MISO line and hands it to C51, and does not accept any value sent by the master device. C51 places the sent serial data in the shift register. When the last bit is received, it is moved into the receiving buffer, and then the SPIDAT can be read to read the data.


2.4 Other software modules

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


3 Conclusion

The article proposes an embedded system with C51 microcontroller C8051F120 as the core control chip, which has been successfully used in a communication test instrument. The system has achieved real-time control of the entire machine through interrupts and queries.


Keywords:Embedded Reference address:How to implement embedded real-time control module

Previous article:51 microcontroller general assembly delay subroutine,
Next article:Understand the assembly program and source code of the 51-controlled MT8880 dual audio transceiver in one minute

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号