Communication methods and protocols between MSP430 multi-processors

Publisher:皮球Latest update time:2006-10-18 Source: 单片机及嵌入式系统应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
In a single-chip computer system, multi-processor refers to multiple single-chip computers of the same type or different types cooperating to handle different tasks of the same system. They must have certain data exchange and collaborative processing capabilities to complete a systematic work together. Different processors can communicate using data exchange, parallel bus, and serial bus methods. Among them, the data exchange method can also be called the shared memory exchange method; the serial bus method can be divided into a single bus method, a communication method between integrated circuits, and a UART method.

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{//Each two ASCII codes that need to be sent are converted into a hexadecimal number
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; iwCrc^=WoRD(BYTE(pSendBuf[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.

Reference address:Communication methods and protocols between MSP430 multi-processors

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

29. Basics of memory
Classification of memory: Memory has become an indispensable component in PC or embedded hardware platform due to its advantages of fast access speed and simple access method. Before starting to learn how to use memory, it is very necessary to understand the classification of memory: DRAM: Its basic
[Microcontroller]
29. Basics of memory
System expansion: MCU RAM expansion
    An expansion of the 8051 microcontroller's data memory.   51 Data storage expansion A0-A12 are address lines, a total of 13, so the physical storage space of the memory is 2 to the 13th power, that is, 8K. D0-D7 is the data bus, with a total of 8 lines, that is, each storage unit of the memory has 8 bits of da
[Microcontroller]
System expansion: MCU RAM expansion
The role of ROM, RAM and FLASH in microcontrollers
1. The role of ROM, RAM and FLASH in a single chip ROM - stores the firmware (stores instruction codes and some fixed values, which cannot be changed after the program is running) All the code in c files and h files, global variables, local variables, constant data defined by the 'const' qualifier, and the code in the
[Microcontroller]
Application of internal extended RAM in stc51 MCU
When I was writing the snake program, I couldn't always determine all the 100 point-type quantities that stored the snake's body data, so I could only determine the maximum length to be around 10 or 20. Suddenly, I remembered the stc extension function in Guo Tianxiang's book, and after a search, I found that using xda
[Microcontroller]
Application of internal extended RAM in stc51 MCU
Red Magic 7 is online: Snapdragon 8+18G memory is unique
      On January 14, Nubia's gaming phone Red Magic 7 was registered with the Ministry of Industry and Information Technology, and its ID photo was officially announced.   The overall design of the phone continues the previous generation's design language, with the cameras arranged vertically. The biggest change is th
[Mobile phone portable]
【stm32f407】Memory management based on SRAM
1. Memory Management Principles Memory management refers to the technology of allocating and using computer memory resources when software is running. Its main purpose is to allocate memory efficiently and quickly, and to release and recycle memory resources when appropriate. There are many ways to implement memory ma
[Microcontroller]
【stm32f407】Memory management based on SRAM
Example of transfer instructions (4) between accumulator A and external data memory RAM - mcs51 single
Instructions for transferring data between accumulator A and external data memory RAM (4 instructions)     These 4 instructions are used to transfer data between accumulator A and external RAM. Use register addressing mode: MOVX @DPTR,A; (A) → ((DPTR)) The contents in the accumulator are sent to the address where the
[Microcontroller]
Demand for memory and flash memory has soared, and prices are about to rise again
In the past two years, demand for DRAM memory chips and NAND flash memory chips has been weak, causing prices to remain at a low level, and memory and SSD hard drive products have become increasingly cheaper. However, these good times seem to be coming to an end. According to TrendForce's latest research report, it is
[Semiconductor design/manufacturing]
Latest Industrial Control Articles
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号