1 MSP430 multiprocessor
MSP430 is an ultra-low-power mixed-signal controller with a 16-bit RISC structure and rich on-chip peripherals, including watchdogs, timers, comparators, hardware multipliers, LCD driver, ADC, I/0 port, serial port (USART), etc., also integrates 64 KB of Flas'E-ROM and 2 KB of RAM. It has powerful functions and a wide range of applications. However, in large and complex situations or situations with high real-time requirements, using one processor to handle all services always seems to be somewhat insufficient. Introducing the cooperative working mode of multiple MsP430 processors can improve the real-time performance, reliability and applicability of the system.
In most cases, MSP430 does not need to expand FlashROM or RAM for each processor. It is not the best choice to use shared memory data exchange to form a multi-processor system. In addition, MSP430 includes two serial ports (USART). In the application of MSP430, one of the two serial ports can be used for external communication, and the other serial port can be used for internal communication. It is an ideal choice to form a multi-processor system using serial communication in a serial bus.
2 Technical Points
2.1 MSP430 multi-processor composition
MSP430 has two serial ports (USART), one of which can be used as a communication port between multi-processors. Due to the architectural limitations of serial communication, a multi-processor system composed of MSP430 using UART serial communication mode must establish a master processor and several slave processors. The TXD terminal of the master processor is connected to the RXD terminals of all slave processors, and the TXD terminals of all slave processors are connected to the RXD terminals of the master processor. The MSP43O multiprocessor topology is shown in Figure 1.
In this structure, the main processor sends an instruction message through the TXD end and transmits it to the RXD receiving end of the slave processor; the slave processor unpacks the instruction message and responds to the instruction message. The response message from the slave processor is sent to the RXD receiving end of the main processor through TXD, and the main processor obtains the response message to confirm whether the instruction is executed correctly. From this structure, the master processor can communicate with any slave processor, and any slave processor can also communicate with the master processor, but direct communication between slave processors is not possible.
2.2 Multi-processor system serial communication protocol
In the serial communication method of multi-processor system, there are several communication protocols to choose from, such as ModBus, Brooks, industrial bus protocol, etc. Here, the industry-wide MocBus communication protocol can be selected as the communication protocol between processors.
2.3 ModBus communication protocol
Modbus protocol supports traditional RS232, RS422, RS485 and Ethernet devices. The ModBus protocol includes ASCII, RTU, TCP and other message formats, and does not specify the physical layer. This protocol defines the message structure that controllers can understand and use regardless of the network over which they communicate. The ASCII and RTU protocols of ModBtls stipulate the structure of messages and data, the command and response methods, and the data communication adopts the Master/Slave method. The Master sends a data request message, and after the Slave receives the correct message, it can send data to the Mastez to respond to the request; the Master can also directly send a message to modify the data on the Slave to achieve bidirectional reading and writing.
2.4 ModBus message format in multi-processor systems
Since it is a system in which one master server corresponds to multiple slave processors, the message transmission between processors must clearly mark the destination address and source address to avoid irrelevant messages. Misleading operations between processors. In addition, in order to improve the processing capability of the main processor and avoid the problem of differences in message speeds between different processors and differences in processing volume between different instruction tasks, asynchronous communication mode must be used for communication. To meet the asynchronous communication mode, the 16-bit identifier of the request message (which can be called a handle) must be added to each communication operation in the message, and these handles must be recorded at the same time.
2.4.1 Data read request message format
Source address: Main processor address.
Destination address: instruction destination address (slave processor).
Handle: instruction request identification number.
Function code: operation instruction code.
Start address: Read the starting address of the slave processor data register.
Number of Bytes: Register words involved in the operation.
Check code: CRC check code or LRC check code.
2.4.2 Data read response message format
Source address: Slave processor address.
Destination Address: Main processor address.
Handle: instruction request identification number.
Function code: operation instruction code.
Number of data bytes: The number of register bytes involved in the operation.
Data 1 to Data n: data.
Check code: CRC check code or LRC check code.
Among them, the destination address in the response message is equivalent to the source address in the request message, and the source address in the response message is equivalent to the destination address in the request message.
2.5 Check code
In ModBus, the common verification methods are LRC verification for ASCII protocol and CRC verification for RTU protocol.
2.5.1 LRC verification
LRC verification is relatively simple. It is used in the ASCII protocol and detects the content in the message field except the starting colon and the ending carriage return and line feed. It just superimposes each data that needs to be transmitted by byte and then inverts and adds 1. The following is its C code:
BYTE GetCheckCode(const char*pSendBuf, Int nEnd)
{ //Get the check code
BYTE byLrc=O.
char pBuf[4];
int nData=0
for(i=1;i
pBuf[O]=pSendBuf[i];
pBu=pSendBuf;
pBuf[2]=, O';
sscanf(pBuf, "%x" , & nData);
bvLrc+=nData;
byhc=~byLrc;
byLrc++;
return byLrc;
}
2.5.2 CRC check
CRC is to first transfer into a 16-bit register whose value is all "1", and then call a process to convert the message into Consecutive 8-bit bytes and the value currently in the register are processed. Only the 8 bits of data in each character are valid for CRC, the start and stop bits and parity bits are not valid.
During the CRC generation process, each 8-bit character is ORed individually with the register content, the result is moved in the direction of the least significant bit, and the most significant bit is filled with 0s. The LSB is extracted and detected. If the LSB is 1, the register is ORed individually with the preset value; if the LSB is 0, no operation is performed. The entire process is repeated 8 times. After the last bit (bit 8) is completed, the next 8-bit byte is ORed individually with the current value of the register. The value in the final register is the CRC value after all bytes in the message have been executed.
When a CRC is added to a message, the low byte is added first, then the high byte. The following is its C code:
WORD GetCheckCode(const char*pSendBuf, int nEnd)
{ //Get the check code
WORD wCrc=WORD(0xFFFF);
for(int i=O; i
for(Intj=O;j<8;J++){
if(wCrc&1){
wCrc>>=l;
wCrc^一OxA00l:
}
else{
wCrc>>=1 ;
retIlrIl wCrc:
3 Message Demonstration
ModBus includes two message formats, ASCII and RTU. The RTU message is shorter, but there is no boundary definition; the ASCII message is longer, but the boundary is clear. In multi-processor communication, because the communication distance is short and the interference is small, a higher communication rate can be selected. The communication rate has increased, and the longer message length has little impact on communication, so the ASCII message format can be selected for communication.
The ASCII read request message format of ModBus is as follows:
The ASCII read request message format of ModBus is as follows:
Assume that the host address is 01, and the slave address 02 needs to be communicated to read the two register values of addresses 247 and 248, and this communication is the first communication, and the serial number is set to 000l.
Conclusion:
The multi-processor collaborative working mode and communication protocol have been successfully applied to CNG dispensers, making system information exchange faster and more reliable, and improving the performance of the entire system.
Previous article:Communication methods and protocols between MSP430 multi-processors
Next article:Data communication between CY7C68013 and FPGA in Ports mode
Recommended ReadingLatest update time:2024-11-16 22:56
- 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
- Control design of intelligent car based on MSP430 single chip microcomputer
- About RX62T PWM output problem
- [GD32F310 Review] ADC Configuration and Use
- How to display animation?
- Sinlinx A33 development board Linux kernel waiting queue poll --- blocking and non-blocking
- Can miniusb be used?
- Xi'an Sitan Instrument Co., Ltd. Recruitment
- 15% off on NI's popular data acquisition products
- Auto Repair Crankshaft Position Sensor Signal and Waveform Analysis Method - Oscilloscope
- Ask for guidance in learning