Heterogeneous single-chip computers share external memory and their communication method with microcomputer

Publisher:浅唱梦幻Latest update time:2013-10-16 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

TMS320 series digital signal processing microcontrollers (DSP) have been increasingly widely used in the fields of measurement and control, instrumentation, image processing, computer vision and sound signal processing. There are generally two ways for DSP to obtain raw data and output processing results: one is through the serial port, and the other is to read and write the off-chip memory through the data bus. This paper introduces the method of obtaining raw data by using the signal processing target board based on DSP and the multi-channel synchronous data acquisition board based on the single-chip microcomputer AT89C51 to achieve inter-board communication through sharing the off-chip random access memory, and gives the bus isolation hardware circuit and software control flow. It also introduces the method of transmitting the processing results of DSP to the control system based on MCS-51 single-chip microcomputer or microcomputer. This paper also briefly analyzes the software and hardware design of serial port communication between AT89C51 and microcomputer. By expanding AT89C51, the communication between TMS320C32 and single-chip microcomputer or microcomputer is indirectly realized, which is much simpler and more reliable than directly communicating with single-chip microcomputer or microcomputer through the serial port of TMS320C32. Unless otherwise specified below, MCU refers to AT89C51 and DSP refers to TMS320C32.

1 Hardware interface circuit and software control flow of inter-board shared memory
1.1 Hardware interface circuit of signal processing board The
signal processing board based on DSP can run many signal processing algorithms according to application requirements, such as signal preprocessing, target recognition and tracking and positioning, Kalman filtering, etc. The raw signal data to be processed is obtained from the data acquisition board through inter-board communication. Here, the inter-board shared memory method is used to complete data exchange. The DSP can read the collected data from the shared memory and write the processing results (such as new program-controlled magnification value, tracking and positioning results, etc.) to the shared memory for MCU to read.
TMS320C32 has a bidirectional serial port, which can be set to send and receive 8/16/24/32 bits of data per frame at the same time. The synchronous clock can be generated by the internal serial port timer or input from the outside. The overall function and working mode of the serial port are controlled by setting the serial port global control register; the function of the 6 pins of the serial port is controlled by setting the FSX/DX/CLKX port control register and the FSR/DR/CLKR port control register. Each pin can be set as a general I/O pin or a serial port communication pin by software. TMS320C32 has two general I/O pins XF0 and XF1. Since the shared memory interface circuit requires four control lines for handshake communication between DSP and MCU, the two pins FSR0 and FSX0 of the serial port are set as general I/O pins for control lines. The interface circuit schematic is shown in Figure 1. 
 

In the figure, RAM0~RAM3 are four 8-bit high-speed RAMs (chip model CY7C1049-17VC) with a capacity of 512K, forming a memory with a data width of 32 bits. The programs and data of the DSP are all in these four RAMs when it is running. FLASH (chip model Am29F016) is used to store programs and initialization data. Even if the power is off, the content will not be lost. When the DSP is powered on, the built-in BOOT LOADER program takes the program from FLASH and runs it in the four RAMs. The collected data read from the shared memory is also temporarily stored in these four RAMs.
1.2 Data acquisition board hardware interface circuit The
data acquisition board based on the single-chip microcomputer AT89C51 is under the global control of the single-chip microcomputer. Through program-controlled amplification, low-pass filtering, synchronous sampling and holding, and A/D conversion of the weak signals output by the multi-channel acoustic sensors, it collects multiple signals in real time and synchronously, and stores the collected signal data in the 128K shared memory (chip model CY7C109-12VC) on the data acquisition board.
The shared memory and its bus isolation circuit are designed on the data acquisition board. At a certain moment, the shared memory can only be accessed by one party, otherwise a bus conflict will occur. Here, the MCU switches to select the DSP bus or the single-chip microcomputer bus to access the shared memory in time-sharing. The bus isolation chip uses the common bidirectional bus isolation/driver chip 74HC245, which has an output enable pin (E) and a data transmission direction (DIR) pin. The MCU completes the bus isolation and data transmission direction control functions by controlling these two pins. The interface circuit schematic is shown in Figure 2. In the figure, the bus isolation on the MCU side is completed by a 74HC373 and two 74HC245s, and the DSP side is completed by three 74HC245s to isolate the data bus and address bus. P1.2 controls which group of buses to select. When P1.2 is low, the shared memory can only be accessed by the MCU; when P1.2 is high, the shared memory can only be accessed by the DSP when P1.3 is also high (indicating that the MCU agrees to give up the shared memory). Since DSP needs to read or write shared memory, the data transmission direction of the data bus isolation chip 74HC245 needs to be set by software, which is accomplished by setting the level state of the DSPDIR signal line (high level for reading, low level for writing). Since the data transmission direction of the address bus is always unidirectional, the DIR end of the isolation chip can be fixedly connected to a low level or a high level, depending on the actual wiring of the 74HC245.

[page]
 
1.3 Software Control Flow
When the DSP on the signal processing board needs to collect signal data, it sends a request signal to the MCU on the data acquisition board. After the single-chip microcomputer receives the request signal, if it agrees to give up the shared memory, it sends a response signal to the DSP, isolates the bus on the MCU side, and suspends data acquisition. After receiving the response signal, the DSP can access the shared memory. After the DSP quickly reads and writes the data, it sends an end signal to the single-chip microcomputer. After receiving the end signal, the single-chip microcomputer reclaims the shared memory, isolates the bus on the DSP side, and continues to collect. In this way, data collection and signal processing can be carried out at the same time. Different from the general serial working mode of collecting one section and processing one section, it realizes zero waiting for data collection and increases the throughput of the system. Referring to the wiring diagram of Figure 3, a complete communication process is described in detail as follows. Note that when the DSP program is initialized, XF0, XF1, and FSR0 should be set to the corresponding invalid state.


 
1. When DSP needs to collect signal data, it sends a request signal to MCU (set XF0 to low level), triggers MCU's INT0 interrupt, and waits for MCU response (DSP detects the status of XF1 in a loop).
2. If MCU agrees to give up the shared memory, it responds to the interrupt, otherwise it waits. In the interrupt service program, set P1.3 (i.e. DSPACK) to a high level to indicate a response. At the same time, set P1.2 to a high level to select the DSP bus. The MCU then loops to detect the status of P1.4 (i.e. DSPEOR).
3. When DSP receives the response signal (i.e., XF1 is detected to be high level), it immediately reads and writes the shared memory quickly. Before the read operation, set FSX0 to a high level, and before the write operation, set FSX0 to a low level. After reading and writing, it sends an end signal to MCU (set FSR0 to a high level), and DSP immediately performs other processing operations.
4. After MCU receives the end signal (i.e., it detects P1.4 to be high level), it sets P1.2 to a high level, isolates the DSP bus, reclaims the shared memory, and continues to collect.

2 Communication between signal processing board and control system
After the signal processing board obtains the collected data from the data acquisition board, it performs a series of signal processing algorithms on it, and the processing results need to be transmitted to the control system based on the single-chip microcomputer or microcomputer. Since the amount of processing result data here is very small, it is simplest to use the serial communication method for data transmission. We can directly program the serial port of the DSP on the signal processing board to communicate with the control system. However, since the serial port of the DSP is a synchronous serial port, and the serial port of the single-chip microcomputer or microcomputer is usually an asynchronous serial port, it is necessary to use software to simulate the asynchronous communication timing of the DSP serial port, which has a large software workload and unreliable communication. Here, the method of expanding the single-chip microcomputer and shared memory solves this problem well. The DSP writes the processing results to the shared memory and immediately performs the next round of processing. The single-chip microcomputer takes out the processing results from the shared memory and transmits them to the control system. This saves the time required for the DSP to perform serial communication and maximizes the high-speed data processing capability of the DSP. This is particularly important in situations where real-time requirements are very high. By expanding a small amount of hardware, not only the system speed is improved and the overall performance is optimized, but also the software implementation is much simpler.
2.1 Hardware circuit of serial communication between signal processing board and control system The
signal processing board uses the extended single-chip microcomputer AT89C51 to communicate with the control system based on microcomputer or MCU in full duplex. Figure 4 shows the serial communication circuit of AT89C51. The "serial port selection" dial switch is used to select whether to communicate with the control system based on microcomputer or the control system based on MCU.


 
In the IBM PC/XT microcomputer system, its serial port complies with the RS-232C interface standard. In order to improve the anti-interference ability, the RS-232C standard adopts negative logic, the low level between -5V and -15V (usually represented by -12V) is logic "1", and the high level between +5V and +15V (usually represented by +12V) is logic "0". The above level is called EIA level, which is different from TTL level and CMOS level. In order to enable AT89C51 to communicate serially with the microcomputer, the common MC1488 and MC1489 can be used for level conversion. MC1488 converts TTL level to RS-232C level, and MC1489 converts RS-232C level to TTL level. However, since MC1488 and MC1489 require a power supply voltage of ±12V, the complexity of the power supply circuit is increased. As shown in Figure 4, MAX232, which only requires a single +5V voltage, is selected here to complete the level conversion, simplifying the hardware circuit.
When the signal processing board communicates with the MCU-based control system, only three wires are needed: a transmit wire (TXD), a receive wire (RXD), and a common ground wire (GND). The ground wires of both parties are connected together, and the transmit wires and receive wires of both parties are cross-connected. When the signal processing board communicates with the microcomputer-based control system, the nine-pin serial port of the microcomputer is used for communication, and their serial port cable connections are shown in Figure 5. The transmit wire and the receive wire here do not cross because they have already crossed during the level conversion (see Figure 4). 
 

2.2 Software Programming of Serial Communication between Signal Processing Board and Control System
There are two types of software programming for serial communication between single-chip microcomputer and single-chip microcomputer or microcomputer: query mode and interrupt mode. Here, the sender (signal processing board) adopts the query mode, and the receiver (control system) adopts the interrupt mode. The communication program mainly completes the functions of serial port initialization (including selecting serial port mode, setting data transmission format, setting baud rate, etc.), establishing connection, transmitting data and disconnecting. To ensure reliable communication, both parties agree on the following communication protocol.
1 After the signal processing board is powered on, it keeps sending the request connection signal \'R\' and waits for the control system to send the response signal \'A\'. If the signal processing board receives the response, it means that the hardware connection of both parties is correct and the connection is successful.
2 Run the serial communication program of the control system. If it is communicating with a microcomputer, it will first automatically detect which serial port (COM1 or COM2) is connected. After detection, it will send the response signal \'A\' to the signal processing board; if it is not detected, it will display an error message, prompting you to check whether the wiring is correct. If it is communicating with a single-chip microcomputer, if no response is received within the specified time (such as within 10s), the indicator light will flash, and it is considered an error and needs to be reset.
3. After receiving the response, the signal processing board first sends the total number of data to be transmitted to the control system, and then sends each data in turn until it is finished.
4. After the control system sends the online response signal, it is in the receiving state. First receive the total number of data, and then receive each data in turn. The control system sends a confirmation signal to the signal processing board every time it receives a data. The signal processing board will send the next data only after receiving the confirmation signal.
In addition, when communicating between the single-chip microcomputer and the microcomputer, both parties must correctly select the same baud rate. Moreover, the selection of the SMOD bit affects the accuracy of the single-chip microcomputer baud rate, that is, the error range of the baud rate. Therefore, when setting the baud rate of the single-chip microcomputer, the selection of SMOD should also be appropriately considered. In order to ensure the reliability of communication, the relative error of the baud rate is usually not greater than 2.5%. When communicating between the single-chip microcomputer and the microcomputer, this point should be paid special attention to. For example, the clock fOSC of the MCU is 12MHz, the serial port mode is mode 1, and the baud rates of the MCU and the microcomputer are both 9600bps. When SMOD=0, the relative error of the baud rate is 8.5%, and when SMOD=1, the relative error of the baud rate is 6.99%. Experiments show that, regardless of SMOD=0 or 1, the MCU and the microcomputer cannot achieve normal transmission and reception under this condition. If the baud rates of both parties are 4800bps, and SMOD=1, the relative error of the baud rate is 0.16%, and the experiment proves that the communication is completely reliable.

Reference address:Heterogeneous single-chip computers share external memory and their communication method with microcomputer

Previous article:Application of embedded TCP/IP protocol microcontroller technology in network communication
Next article:I/O port multiplexing techniques for EM78P156 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号