introduction
With the rapid development of computer and information technology, digital signal processing technology has developed rapidly. Digital control makes power electronic conversion control more flexible. When the CPU computing speed allows, complex control algorithms that are difficult to achieve with analog control can be realized. Designers can easily change controller parameters according to their own system requirements. Even if the control object changes, there is no need to modify the controller hardware. Just change some software parameters, which greatly enhances the compatibility of the system. With the gradual popularization of DSP applications, DSP has been widely used in UPS and inverter control to replace dedicated PWM integrated circuits in analog circuits.
As intelligent equipment, human-computer interaction devices such as LCD screens and keyboards are indispensable for digital power supply systems. DSP has a high working frequency and a short read-write cycle. It is mainly used to handle critical tasks with strict real-time requirements and complex algorithms, such as the control of power switch tubes, data collection, analysis, and processing. The tasks of LCD display and keyboard scanning can be completed by ordinary 51 series microcontrollers, and the data exchange between DSP and 51 microcontrollers can adopt asynchronous communication mode, that is, the system adopts a dual CPU structure.
1 System structure principle
The DSP and MCU used in this paper are TI's TM S320F2812 and MCS51 series. In the system, DSP realizes asynchronous serial communication with MCU. MCU transmits the user's original setting data to DSP, and DSP returns the collected real-time data information to MCU. MCU continuously refreshes the LCD display. The basic structure of the system is shown in Figure 1.
Figure 1 System basic structure diagram
1.1 Serial port introduction
In this paper, DSP realizes communication based on the serial communication interface module SCI. SCI supports data communication between CPU and other asynchronous peripherals using standard format. SCI only needs 2 data lines for data transmission. Although the transmission speed is not fast, it can meet the general communication requirements, and the peripheral interface circuit is very simple. The length of the transmitted data is also variable within a certain range.
The MCS51 series microcontroller has a full-duplex serial port inside. The serial port has 4 working modes, which can be set by software. The baud rate is generated by the on-chip timer/counter. The serial port's receiving and sending data can trigger interrupts, and contains a receiving and sending buffer SBUF, which share the same address.
1.2 Communication interface circuit between MCU and DSP
The SCI interface is divided into two pins, RXD and TXD. Traditionally, two devices use RS 232 or RS 485 for asynchronous communication, and the corresponding RS 232 and RS 485 driver chips must be configured separately. However, in the digital power supply device with dual CPU structure mentioned in this article, the DSP and 51 single-chip microcomputer are located in the same device, and the distance is short. The RS 232 and RS 485 driver chips can be omitted, and the RXD and TXD of the two CPUs can be directly cross-connected. However, it should be noted that since the operating voltage of the DSP is 3.3 V, and the operating voltage of the MCS51 single-chip microcomputer is 5 V, the communication circuit between the two needs to be converted at a level, as shown in Figure 2.
Figure 2 Level conversion circuit
In this circuit, the voltage of the TXD terminal of the MCU is higher than that of the RXD terminal of the DSP, so only a voltage divider circuit is needed to calculate the appropriate resistance value to meet the requirements. When transmitting data from the DSP to the MCU, the level needs to be increased, so an optocoupler circuit is used to increase the level to the working level of the MCU. In this way, the level conversion can be achieved with a simple circuit. It should be noted that the optocoupler rate used must be higher than the data transmission rate, so as to ensure accurate and efficient data transmission to avoid data loss.
1.3 Software implementation of communication between MCU and DSP
In asynchronous communication, three things must be specified first: First, the character format, that is, the format of each frame of data transmitted; second, the communicating parties must be set to the same baud rate, and the baud rate must be able to adapt to the clock frequency of both parties; third, the communicating parties must have an agreed communication protocol, that is, both parties must confirm each other before transmitting data.
In this design, the data frame format used by DSP and MCU is 1 start bit, 8 data bits and 1 stop bit. Since the data packet is checked by checksum, no parity bit is set in the data frame format. Therefore, the MCS51 MCU should be set to work in serial port mode 1, and the serial port is an 8-bit asynchronous communication interface. In order to ensure that the data transmission has a high rate and a relatively low transmission bit error rate, the baud rate is selected to be 9600 b/s. The initial value of the register at the initialization of DSP and MCU can be calculated through the corresponding baud rate setting calculation formula to complete the setting. In this way, the unified frame format and baud rate of the two communicating parties are guaranteed, so that the data communication is correct and reliable.
The DSP serial port initialization setting procedure is as follows:
EALLOW;
GpioMuxReg s. GPGMUX. bit. SCIRXDB_GPIOG5 = 1; // Set the SCI??RX pin peripheral function
GpioMuxReg s. GPGMUX. bit. SCIT XDB_GPIOG4 = 1; // Set SCI??TX pin peripheral function EDIS;
ScibRegs.SCICCR.all = 0x07; // 1 stop bit, no parity, 8-bit character length, use idle line mode protocol
ScibRegs.SCICTL1.all = 0x 03; // Enable transmit and receive buffers
ScibRegs.SCICTL2.all=0x02; // Enable RXRDY interrupt, disable TXRDY interrupt
ScibRegs.SCIPRI.all = 0x0000; // Disable receive error interrupt and sleep mode
ScibRegs.SCIH BAUD = 0x01; // LSPCLK = 37.5 MHz, baud rate is set to 9 600 b/s
ScibRegs. SCILBAUD = 0xE1; ??
ScibRegs.SCICTL1.all = 0x 0023; // Re-enable SCI
51 The microcontroller serial port initialization procedure is as follows:
TMOD = 0x 21; // Timer 1 works in mode 2, used to generate the baud rate of serial port 0
SCON = 0x 50; //Serial port 0 works in mode 1, allows receiving, clears flag bit
TH 0 = 0xfd; // Crystal oscillator 12 MH z, set baud rate to 9 600 b/s
TH 1= 0xfd; PS= 1; //Serial port interrupt priority
PCON| = 0x 00; // The baud rate is not doubled
TR1= 1;
In this design, a self-defined communication protocol is adopted. First, DSP sends a handshake signal. After receiving the handshake signal, C51 enters the interrupt subroutine to determine whether the handshake signal is correct. If it is correct, the handshake is successful and the data packet is received. After receiving, the data is summed and verified. If it is correct, the display data storage area of the LCD is refreshed; if it is wrong, the data is abandoned and the receiving data storage area is cleared to zero, waiting for the next communication. The program flow chart is shown in Figure 3.
Figure 3 Flowchart of the communication program between DSP and MCU
The timing sending procedure from DSP to MCU is as follows:
ScibRegs.SCITXBUF = Sci_VarRx[i]; //Write the data packet to the transmit buffer
i+ + ; // Send data packets in sequence
if (i == 12) i = 0; // Re-count
IER | = M_INT1; // Clear interrupt flag
ONE;
PieCtr lReg s. PIEACK. all = PIEACK_GROUP1;
51 The microcontroller serial port interrupt service program is as follows:
Rx0_Buffer[ Rx0_Ptr] = SBUF; // Read data into the receive array
RI= 0; // Clear the receive flag
Rx0_Ptr++; //Count up by 1
Rx_flag= 1;
Previous article:Design of instant messaging system client based on Android platform
Next article:Stepper Motor Driver Based on S3C2440 Embedded Linux
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- 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
- EEWORLD University ---- Introduction to Intelligent Control
- Free application: National Technology dual-core, with CAN Bluetooth N32WB452 is here
- Unboxing experience of ST MEMS sensor board (IKS01A3) based on STM32F411RE!
- Smart locks and electric cars are trending on the Internet because the weather in Beijing is too cold!
- 101 Examples of Application Skills of Simulation Technology
- MSP430 common program architecture
- [ESP32-Audio-Kit Audio Development Board Review] 2. Download Audio Firmware
- [Construction Monitoring and Security System] 7. Kaluga Test TCP Client
- Solution to packet loss when connecting to server in WinXP system
- Common Misconceptions About 802.11ax