CN116737635B - Interface expansion method, electronic system, electronic device and medium of power distribution terminal - Google Patents

Interface expansion method, electronic system, electronic device and medium of power distribution terminal Download PDF

Info

Publication number
CN116737635B
CN116737635B CN202310987705.6A CN202310987705A CN116737635B CN 116737635 B CN116737635 B CN 116737635B CN 202310987705 A CN202310987705 A CN 202310987705A CN 116737635 B CN116737635 B CN 116737635B
Authority
CN
China
Prior art keywords
serial port
expansion
bus
receiving
cpld
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310987705.6A
Other languages
Chinese (zh)
Other versions
CN116737635A (en
Inventor
辛海斌
刘海涛
袁琳琳
魏钰柏
盖世
姚嘉楠
胡敬洋
尚京
王娟
赵贺
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shijiazhuang Kelin Electric Co Ltd
Original Assignee
Shijiazhuang Kelin Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shijiazhuang Kelin Electric Co Ltd filed Critical Shijiazhuang Kelin Electric Co Ltd
Priority to CN202310987705.6A priority Critical patent/CN116737635B/en
Publication of CN116737635A publication Critical patent/CN116737635A/en
Application granted granted Critical
Publication of CN116737635B publication Critical patent/CN116737635B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4004Coupling between buses
    • G06F13/4022Coupling between buses using switching circuits, e.g. switching matrix, connection or expansion network
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4063Device-to-bus coupling
    • G06F13/4068Electrical coupling
    • G06F13/4072Drivers or receivers
    • G06F13/4077Precharging or discharging

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Information Transfer Systems (AREA)

Abstract

The application provides an interface expansion method of a power distribution terminal, an electronic system, an electronic device and a medium. The power distribution terminal comprises an MCU and a CPLD which are connected through a bus, and the interface expansion method is applied to the CPLD and comprises the following steps: determining the state of a bus, wherein the state comprises an idle state and a working state; when the bus is converted from an idle state to a working state, receiving and analyzing a data frame sent by the MCU, wherein the data frame does not contain a starting byte, and the data frame comprises serial port information of a plurality of expansion serial ports and effective data corresponding to each expansion serial port; based on the serial port information of each expansion serial port, the effective data corresponding to each expansion serial port is sent to a sending buffer area of the corresponding expansion serial port. The application can improve the working reliability of the power distribution terminal.

Description

Interface expansion method, electronic system, electronic device and medium of power distribution terminal
Technical Field
The present application relates to the field of serial port expansion technologies, and in particular, to an interface expansion method, an electronic system, an electronic device, and a medium for a power distribution terminal.
Background
With the gradual increase of intelligent products, the power distribution terminals are connected with more and more external devices, and the serial ports required inside the power distribution terminals are also more and more.
In order to be compatible with more external devices, the existing power distribution terminal mostly adopts processor chips with multiple serial ports, or the number of the processor chips is increased, so that the hardware development cost of the power distribution terminal is increased, and the maintenance difficulty of the power distribution terminal is increased along with the continuous increase of the number of the processor chips, which is not beneficial to mass production.
Disclosure of Invention
The application provides an interface expansion method, an electronic system, an electronic device and a medium of a power distribution terminal, which are used for solving the problem that the maintenance difficulty is increased due to the fact that the number of processor chips is increased for the existing power distribution terminal to be compatible with more external equipment.
In a first aspect, the present application provides an interface extension method of a power distribution terminal, where the power distribution terminal includes an MCU and a CPLD connected by a bus, and the interface extension method is applied to the CPLD, and includes:
determining the state of a bus, wherein the state comprises an idle state and a working state;
when the bus is converted from an idle state to a working state, receiving and analyzing a data frame sent by the MCU, wherein the data frame does not contain a starting byte, and the data frame comprises serial port information of a plurality of expansion serial ports and effective data corresponding to each expansion serial port;
based on the serial port information of each expansion serial port, the effective data corresponding to each expansion serial port is sent to a sending buffer area of the corresponding expansion serial port.
In one possible implementation, the bus includes a receive bus of the CPLD, determining a state of the bus, including:
when the duration of the continuous high level of the receiving bus is longer than or equal to the first duration, judging that the receiving bus is in an idle state; the first time length is determined according to the serial port baud rate of the receiving bus serial port of the CPLD;
and when the duration that the receiving bus is continuously in the low level is greater than or equal to the second duration, judging that the receiving bus is in the working state.
In one possible implementation, when the bus is converted from the idle state to the working state, receiving and analyzing the data frame sent by the MCU includes:
and after the duration of the continuous high level of the receiving bus is greater than or equal to the first duration, if the duration of the continuous low level of the receiving bus is greater than or equal to the second duration, receiving and analyzing the data frame sent by the MCU to obtain the serial port information of each expansion serial port and the effective data corresponding to each expansion serial port.
In one possible implementation manner, the interface extension method further includes:
receiving device data sent by external devices, and storing each device data into a receiving buffer area corresponding to each expansion serial port according to a receiving sequence;
when the uploading condition is met, determining the uploading priority of each piece of equipment data according to the serial port information of each expansion serial port;
and uploading the device data of each receiving buffer zone to the MCU according to the uploading priority.
In one possible implementation, the serial port information includes a serial port baud rate, and determining an uploading priority of each device data according to the serial port information of each extended serial port includes:
sequencing the serial port priorities of the expansion serial ports from high to low according to the serial port baud rate from high to low;
the uploading priority of each device data corresponds to the serial port priority of the expansion serial port corresponding to the receiving buffer area one by one;
the serial port information further comprises a serial port number, and when the serial port baud rates are the same, the method further comprises:
and for the extended serial ports with the same serial port baud rate, sequencing the serial port priority of each extended serial port from high to low according to the serial port number of each extended serial port from low to high.
In one possible implementation, the uploading condition includes:
for each expansion serial port, the equipment data received by the receiving buffer area of the expansion serial port reaches or exceeds a preset byte, and/or the receiving idle time of the expansion serial port reaches a third time; and the third duration is determined according to the serial port baud rate of the extended serial port.
In one possible implementation, the serial port information further includes a configuration command, a data bit number, a check bit, and a stop bit number.
In a second aspect, the present application provides an interface expansion device for a power distribution terminal, where the power distribution terminal includes an MCU and a CPLD connected by a bus, and the serial port expansion device is applied to the CPLD, and may include:
the state judging module is used for determining the state of the bus, wherein the state comprises an idle state and a working state;
the data analysis module is used for receiving and analyzing a data frame sent by the MCU when the bus is converted from an idle state to a working state, wherein the data frame does not contain a starting byte, and the data frame comprises serial port information of a plurality of expansion serial ports and effective data corresponding to each expansion serial port;
and the information sending module is used for sending the effective data corresponding to each expansion serial port to the sending buffer area of the corresponding expansion serial port based on the serial port information of each expansion serial port.
In a third aspect, the present application provides an electronic device, including a memory and a processor, where the memory stores a hardware program executable on the processor, and the processor implements the steps of the interface extension method of the power distribution terminal as described above in the first aspect or any one of the possible implementations of the first aspect when the processor executes the hardware program.
In a fourth aspect, the present application provides an electronic system, including the electronic device of the third aspect, further including an MCU, the electronic device including a CPLD; the MCU is connected with the CPLD through a bus, and the CPLD is provided with N configuration storage areas, N transmission cache areas and N receiving cache areas;
each transmitting buffer area corresponds to one expansion serial port, and each receiving buffer area corresponds to one expansion serial port.
In a fifth aspect, the present application provides a computer readable storage medium storing a hardware program, which when executed by a processor implements the steps of the interface extension method of the power distribution terminal according to the first aspect or any one of the possible implementations of the first aspect.
The application provides an interface expansion method, an electronic system, an electronic device and a medium of a power distribution terminal, wherein the interface expansion method is applied to CPLD, and when the bus is converted from an idle state to a working state, a data frame sent by MCU is received and analyzed, and the data frame does not contain a starting byte; based on the serial port information of each expansion serial port, the effective data corresponding to each expansion serial port is sent to a sending buffer area of the corresponding expansion serial port. The CPLD can be utilized to realize serial port expansion without adding too many processor chips, thereby avoiding complex control logic, reducing research and development cost, facilitating batch production and improving the working reliability of the power distribution terminal. In addition, when the bus is switched from the idle state to the working state, the data frame sent by the MCU is analyzed to obtain the configuration information of the extended serial port, the data frame does not need to contain a start bit, an additional communication line is not required to be established with the MCU, and the number of interfaces of the CPLD or the MCU can be reduced on the premise of improving the data transmission efficiency and the reliability.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic structural diagram of a power distribution terminal according to an embodiment of the present application;
fig. 2 is a flowchart of an implementation method of an interface extension method of a power distribution terminal according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an interface expansion device of a power distribution terminal according to an embodiment of the present application;
FIG. 4 is a schematic diagram of an electronic device provided by an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic system according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the following description will be made by way of specific embodiments with reference to the accompanying drawings.
Fig. 1 is a schematic structural diagram of a power distribution terminal according to an embodiment of the present application, where, as shown in fig. 1, the power distribution terminal may include an MCU and a CPLD, and the MCU and the CPLD are connected through a bus. N paths of expansion serial ports with different levels and different configurations are expanded by the CPLD. T1 represents the transmission of the expanded 1 st expansion serial port, R1 represents the reception of the expanded 1 st expansion serial port, and the like, tn represents the transmission of the expanded N th expansion serial port, and Rn represents the reception of the expanded N th expansion serial port.
Specifically, the CPLD has a reception bus Rbus connected to a transmission bus T of the MCU, and the transmission bus Tbus connected to a reception bus R of the MCU. The MCU can send data to the CPLD through a sending bus T, and the MCU can receive the data of the CPLD through a receiving bus R.
For example, the external baud rate of the MCU serial port may be 115200bps, rbus represents a receiving bus of the CPLD, tbus represents a transmitting bus of the CPLD, and the baud rate is 115200bps.
In the embodiment of the application, the serial port baud rate of the main serial port is generally higher than that of each expansion serial port.
N sending buffer areas and N receiving buffer areas can be arranged in the CPLD, each sending buffer area corresponds to a sending expansion serial port, and each receiving buffer area corresponds to a receiving expansion serial port. That is, the CPLD may have 2N expansion serial ports, and may connect N external devices to interact with the N external devices. Wherein N is generally not less than 2 and is an integer.
The MCU can realize communication with N external devices through the CPLD, can realize control of the N external devices and receive device data of the N external devices.
Correspondingly, in order to realize interaction between the MCU and N pieces of external equipment, the embodiment of the application provides an interface expansion method which is mainly applied to the CPLD of the power distribution terminal. Referring to fig. 2, a flowchart of an implementation method of an interface extension method of a power distribution terminal according to an embodiment of the present application is shown. As shown in fig. 2, an interface extension method of a power distribution terminal, which is applied to a CPLD, may include S101 to S103.
S101, determining the state of a bus, wherein the state comprises an idle state and an operating state.
The CPLD may include a receiving bus and a transmitting bus, and the states of the buses may include an idle state and an operating state, that is, may include an idle state of the receiving bus, an operating state of the receiving bus, an idle state of the transmitting bus, and an operating state of the transmitting bus. In the embodiment of the application, the receiving bus is mainly determined to be in an idle state or a working state.
Alternatively, the CPLD may determine that the bus is in an idle state when it detects that the bus is at a high level. When the CPLD detects that the bus is in a low level, the CPLD can determine that the bus is in a working state. Or, the CPLD may determine that the bus is in an idle state when detecting that the bus is continuously at a high level for longer than a certain period of time. And when the CPLD detects that the duration of the bus continuously in the low level exceeds a certain duration, the CPLD can judge that the bus is in a working state. Specifically, the selection can be performed according to actual conditions.
S102, when the bus is converted from an idle state to a working state, receiving and analyzing a data frame sent by the MCU, wherein the data frame does not contain a start byte, and the data frame comprises serial port information of a plurality of expansion serial ports and effective data corresponding to each expansion serial port.
In consideration of the fact that limiting the length of a data frame and checking data can prolong the time of data transmission, in order to enable the data frame to be transmitted more quickly and smoothly and improve the synchronism of input and output, the CPLD receives the data frame comprising serial port configuration information until effective data is sent to external equipment through a corresponding expansion serial port, and in the embodiment of the application, the data frame of the MCU can be free of length and checking data and has no start bit.
In the actual application process, when the CPLD detects that the bus is switched from the idle state to the working state, the MCU is indicated to send a data frame to the CPLD. The CPLD may parse a data frame received after the bus is converted from the idle state to the working state, where the data frame includes serial port information of multiple extended serial ports and valid data of each extended serial port. The effective data may be a control signal for controlling the external device, a communication signal for communicating with the external device, or the like, and the specific effective data may be set according to actual situations.
Illustratively, the packed format of the data frames may be as shown in Table 1 below:
table 1 data frame packing format
Wherein the data stream is a string of multi-byte data for transmission. The data is not additionally provided with check bytes, because the total length of the string of data cannot be obtained when the string of data is transmitted, and therefore, the length and the check content of the string of data are not available when the string of data is transmitted.
From the above, the data frame sent by the MCU in the embodiment of the present application may not have a length, no check data, and no start bit. Therefore, the embodiment of the application analyzes the first data frame converted into the working state by the bus, does not need to verify the start bit, reduces the data analysis steps and improves the data transmission efficiency.
S103, based on the serial port information of each expansion serial port, the effective data corresponding to each expansion serial port is sent to a sending buffer area of the corresponding expansion serial port.
The CPLD analyzes the received data frame to obtain serial port information of the extended serial port, wherein the serial port information can comprise serial port numbers of the extended serial port, serial port baud rates of the extended serial port and the like. After the analysis is completed, the CPLD may store each valid data into a transmission buffer area corresponding to the corresponding expansion serial port, so as to send the relevant valid data to the corresponding external device.
For example, as shown in fig. 1, the CPLD parses a data frame sent by the MCU to obtain valid data 1 of the extended serial port 1 and the external device 1, valid data 2 of the extended serial port 2 and the external device 2, and valid data 3 of the extended serial port 3 and the external device 3.
The CPLD stores the valid data 1 of the external device 1 in the COM1 transmission buffer, and transmits the valid data 1 to the external device 1 through the transmission expansion serial port T1.
The CPLD stores the valid data 2 of the external device 2 in the COM2 transmission buffer, and transmits the valid data 2 to the external device 2 through the transmission expansion serial port T2.
The CPLD stores the valid data 3 of the external device 3 in the COM3 transmission buffer, and transmits the valid data 3 to the external device 3 through the transmission expansion serial port T3.
In the embodiment of the application, the MCU transmits the data frame to the CPLD in a serial transmission mode, and the CPLD analyzes the data frame and can synchronously transmit each effective data to each external device. The embodiment of the application realizes one-to-many parallel expansion of the serial port based on the real-time performance of the CPLD and the high-efficiency operation capability of the digital circuit, avoids a complex serial port expansion circuit, and expands one output signal into multiple synchronous output signals through AND gate operation in the CPLD. Meanwhile, a starting bit is not arranged in the data frame sent by the MCU, the CPLD detects, receives and analyzes the data frame through detecting the state of the bus, and the data transmission efficiency is improved on the premise of ensuring the data transmission reliability.
In some embodiments of the application, where the bus comprises the receive bus of the CPLD, determining the status of the bus may include:
when the duration of the continuous high level of the receiving bus is longer than or equal to the first duration, judging that the receiving bus is in an idle state; the first time length is determined according to the serial port baud rate of the receiving bus serial port of the CPLD.
And when the duration that the receiving bus is continuously in the low level is greater than or equal to the second duration, judging that the receiving bus is in the working state.
Optionally, the first duration may be determined according to a serial port baud rate of the receiving bus serial port, and a calculation formula of the first duration ST1 may be as follows:
wherein ST1 represents a first time period, B i The serial port baud rate of the CPLD receiving bus is represented, and Z represents the byte number of the receiving bus transmission.
As can be seen from the above formula, the serial port baud rate of the receiving bus is actually set, so that the byte number and the first duration can be converted from each other. And judging whether the bus is idle according to the byte number.
Illustratively, the logic to determine that the bus is idle may further be: and judging that the receiving bus is in an idle state when the time length of the continuous high level of the receiving bus is greater than or equal to 32 Bytes.
The second time period may be set according to actual conditions, and the second time period may be lower than the first time period.
According to the embodiment of the application, the first time length matched with different baud rates is set as the limit of bus idle judgment, so that the serial ports matched with various baud rates can be targeted, the serial ports with different baud rates can correspond to different first time lengths, the matching degree is higher, and the method is beneficial to being suitable for scenes with various baud rates.
In addition, a unified first time length can be set as a limiting condition, however, in order to be compatible with all baud rates, the unified first time length is set very long, which is not beneficial to the CPLD to analyze related data frames in time, and may cause the reduction of transmission efficiency between the MCU and the CPLD. The method can be specifically selected and used according to actual conditions.
In some embodiments of the present application, when the bus is switched from the idle state to the working state, receiving and parsing a data frame sent by the MCU includes:
and after the duration of the continuous high level of the receiving bus is greater than or equal to the first duration, if the duration of the continuous low level of the receiving bus is greater than or equal to the second duration, receiving and analyzing the data frame sent by the MCU to obtain the serial port information of each expansion serial port and the effective data corresponding to each expansion serial port.
Illustratively, as shown in FIG. 1, ebus is considered idle when the high level on the Rbus line continues to be greater than 32 Bytes. The data frame received by the CPLD again may then be considered as the starting data, which may be parsed according to the message format.
In some embodiments of the present application, the interface extension method further includes:
receiving device data sent by external devices, and storing each device data into a receiving buffer area corresponding to each expansion serial port according to a receiving sequence;
when the uploading condition is met, determining the uploading priority of each piece of equipment data according to the serial port information of each expansion serial port;
and uploading the device data of each receiving buffer zone to the MCU according to the uploading priority.
The uploading priority may be determined according to the serial port baud rate of each expansion serial port, or according to the serial port number of each expansion serial port. In the embodiment of the application, the uploading priority can be predetermined, and the solidified uploading priority is directly used in the actual use process so as to ensure the efficiency of uploading the equipment data.
After the expansion serial port of the CPLD receives the device data of the external device, each device data may be stored in a receiving buffer area corresponding to the expansion serial port according to the receiving order, and each receiving expansion serial port may correspond to one receiving buffer area.
For example, as shown in fig. 1, the external device 1 may send device data to the COM1 receiving buffer through the CPLD's extended receiving serial port R1, the external device 2 may send device data to the COM2 receiving buffer through the CPLD's extended receiving serial port R2, and the external device 3 may send device data to the COM3 receiving buffer through the CPLD's extended receiving serial port R3.
When the CPLD receives enough external device data, the CPLD can upload the external device data to the MCU through a serial bus between the MCU and the CPLD according to the uploading priority. Or when the CPLD receives the data of each external device, the CPLD sequentially uploads the data of each external device to the MCU through the serial bus according to the receiving sequence, so that the MCU can acquire the related data of each external device in time. The device data may include status data of each external device or other data, which is not limited herein.
When device data of a plurality of external devices are received, the CPLD can determine the uploading priority according to the serial port information of each expansion serial port, so that the device data of the expansion serial port with higher priority is preferentially uploaded, the expansion serial port with higher priority is connected with the external device with higher priority, the data of important external devices can be preferentially processed, the power distribution terminal can conveniently and timely make feedback, and the working reliability of the power distribution terminal is ensured.
In some embodiments of the present application, the serial port information includes a serial port baud rate, and determining an uploading priority of each device data according to the serial port information of each extended serial port includes:
sequencing the serial port priorities of the expansion serial ports from high to low according to the serial port baud rate from high to low;
the uploading priority of each device data corresponds to the serial port priority of the expansion serial port corresponding to the receiving buffer area one by one;
the serial port information further comprises a serial port number, and when the serial port baud rates are the same, the method further comprises:
and for the extended serial ports with the same serial port baud rate, sequencing the serial port priority of each extended serial port from high to low according to the serial port number of each extended serial port from low to high.
In some embodiments of the application, the upload conditions include:
for each expansion serial port, the equipment data received by the receiving buffer area of the expansion serial port reaches or exceeds a preset byte, and/or the receiving idle time of the expansion serial port reaches a third time; and the third duration is determined according to the serial port baud rate of the extended serial port.
When the extended serial port receives the device data, the device data are sequentially stored in a receiving buffer area in the CPLD according to the receiving sequence, and when the device data in the receiving buffer area reach 32bytes or the idle time of a receiving pin reaches 4bytes, the device data are triggered to be sent to the main serial port MCU to enter a priority queuing stage, and then all the device data are uploaded according to the uploading priority.
In the embodiment of the application, the uploading priority can be determined according to the serial port baud rate of each expansion serial port, the higher the baud rate is, the higher the priority is, and when the equipment data received by a plurality of expansion serial ports are queued at the same time, the priority is sent from high to low in sequence; and when the priorities are consistent, polling and sending are carried out according to the serial numbers of the extended serial ports.
In some embodiments of the application, the serial port information further includes a configuration command, a data bit number, a check bit, and a stop bit number.
The working process of the interface expansion method provided by the embodiment of the application is as follows:
s01, initializing configuration of the virtual serial port.
The MCU transmits the parameters of the virtual serial COMn to the configuration memory area of the COMn of the CPLD (n=1, 2, 3 …) through the transmission bus T according to the configuration command format.
S02, effective data of the MCU are sent.
And an extended serial port driver in the MCU realizes frame interruption according to the 32bytes idle time interval between two agreed frames. And packing the virtual expansion serial number and the data according to the data frame format, sending the virtual expansion serial number and the data through a T pin of the virtual expansion serial number and receiving the virtual expansion serial number and the data through an Rbus pin of the CPLD.
The CPLD analyzes COM numbers N (N=1, 2 and 3 …) in the data frames according to the data frame format, then sends the data to a corresponding COMN sending buffer area, configures the baud rate of a storage area according to the COMN, and outputs the data from the sending buffer area to a pin TN.
S03, receiving equipment data of the MCU.
After receiving data, the RN of the COMN port expanded by the CPLD is firstly placed in a corresponding receiving buffer, and when the CPLD detects that the receiving bus Tbus is idle, the CPLD determines the uploading priority according to a polling and preempting mode.
And the virtual expansion serial port with the highest priority is used for packaging the COM number and the data in the receiving buffer according to a data frame format and then transmitting the data through the Tbus of the CPLD.
After the R pin of the MCU receives the data, analyzing the function code and the virtual COM number according to the format of the data frame, and storing the data received after the COM number into a receiving buffer which is virtually obtained by a corresponding MCU driver until 32bytes are idle.
The interface expansion method of the embodiment of the application also comprises the processing of abnormal conditions.
Illustratively, when the CPLD is transmitting the device data received by the extended COM1 port to the MCU, the COM1 continuously receives the device data, and the data is transferred to the COM1 receiving buffer.
Meanwhile, the COM1 receives the buffered data and transmits the buffered data to the MCU through the Tbus of the CPLD. The Tbus cannot acquire the idle gap of 32bytes, and a new priority arbitration is triggered, so that the currently-expanded COM1 continuously occupies the Tbus pins and cannot be released.
To solve the above problem, the maximum frame length limit may be increased. That is, each frame of data of the Tbus has the maximum frame length limit (such as 1024 bytes), and when the data transmitted by the Tbus reaches 1024bytes, the Tbus pin is forcibly released to enter a new round of priority arbitration.
The embodiment of the application realizes a method for expanding a plurality of serial ports by a single serial port through a CPLD. CPLD with low cost, stable operation, fast operation speed, abundant I/O resources, and can be configured as I/O except power, ground and clock pins, and the external interface can be designed in diversified manner.
Based on the real-time performance of the CPLD and the high-efficiency operation capability of the digital circuit, the embodiment of the application combines various conversion chips to convert into various bus interfaces, such as RS232, RS485 and the like, realizes one-to-many parallel expansion of serial ports, omits a complex serial port expansion circuit, expands one output signal into multiple paths of synchronous output signals through AND gate operation in the CPLD, and similarly, converges multiple paths of input signals into one input signal.
The power distribution terminal in the embodiment of the application comprises a processor MCU and a CPLD. And a serial port unit in the MCU expands multiple serial ports through the CPLD, and the CPLD sets the output signal level to realize the connection with the peripheral equipment with different levels and realize the synchronous control of different external equipment.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
The following are device embodiments of the application, for details not described in detail therein, reference may be made to the corresponding method embodiments described above.
Fig. 3 is a schematic structural diagram of an interface expansion device of a power distribution terminal according to an embodiment of the present application, and for convenience of explanation, only a portion related to the embodiment of the present application is shown, which is described in detail below:
as shown in fig. 3, the power distribution terminal includes an MCU and a CPLD connected through a bus, and an interface expansion device 20 of the power distribution terminal is applied to the CPLD, and may include:
a state judging module 201, configured to determine a state of the bus, where the state includes an idle state and an operating state;
the data parsing module 202 is configured to receive and parse a data frame sent by the MCU when the bus is converted from an idle state to a working state, where the data frame does not include a start byte, and the data frame includes serial port information of multiple expansion serial ports and valid data corresponding to each expansion serial port;
the information sending module 203 is configured to send, based on serial port information of each extended serial port, valid data corresponding to each extended serial port to a sending buffer area of the corresponding extended serial port.
In some embodiments of the present application, where the bus comprises the receive bus of the CPLD, the state determination module 201 may include:
the first judging unit is used for judging that the receiving bus is in an idle state when the duration of the continuous high level of the receiving bus is longer than or equal to the first duration; the first time length is determined according to the serial port baud rate of the receiving bus serial port of the CPLD;
and the second judging unit is used for judging that the receiving bus is in a working state when the duration of the continuous low level of the receiving bus is longer than or equal to the second duration.
In some embodiments of the present application, the data parsing module 202 is specifically configured to: and after the duration of the continuous high level of the receiving bus is greater than or equal to the first duration, if the duration of the continuous low level of the receiving bus is greater than or equal to the second duration, receiving and analyzing the data frame sent by the MCU to obtain the serial port information of each expansion serial port and the effective data corresponding to each expansion serial port.
In some embodiments of the present application, the apparatus 20 may further include:
the data receiving module is used for receiving the equipment data sent by the external equipment and storing the equipment data into the receiving buffer areas corresponding to the expansion serial ports according to the receiving sequence;
the priority judging module is used for determining the uploading priority of each device data according to the serial port information of each expansion serial port when the uploading condition is met;
and the data uploading module is used for uploading the equipment data of each receiving buffer zone to the MCU according to the uploading priority.
In some embodiments of the present application, the serial port information includes serial port baud rate, and the priority judging module is specifically configured to sort serial port priorities of the extended serial ports from high to low according to the serial port baud rate from high to low; the uploading priority of each device data corresponds to the serial port priority of the expansion serial port corresponding to the receiving buffer area one by one;
in some embodiments of the present application, the serial port information further includes a serial port number, and the apparatus 20 may further include:
and the peer sequencing module is used for sequencing the serial port priorities of the expansion serial ports with the same serial port baud rate from high to low according to the serial port numbers of the expansion serial ports from low to high when the serial port baud rates are the same.
In some embodiments of the application, the upload conditions include:
for each expansion serial port, the equipment data received by the receiving buffer area of the expansion serial port reaches or exceeds a preset byte, and/or the receiving idle time of the expansion serial port reaches a third time; and the third duration is determined according to the serial port baud rate of the extended serial port.
In some embodiments of the application, the serial port information further includes a configuration command, a data bit number, a check bit, and a stop bit number.
Fig. 4 is a schematic diagram of an electronic device according to an embodiment of the present application. As shown in fig. 4, the electronic device 30 of this embodiment includes: a processor 300 and a memory 301, the memory 301 storing a hardware program 302 executable on the processor 300. The processor 300 implements the steps in the above-described interface extension method embodiment of each power distribution terminal when executing the hardware program 302, for example, S101 to S103 shown in fig. 2. Alternatively, the processor 300 may implement the functions of the modules/units in the above-described embodiments of the apparatus, such as the functions of the modules 201 to 203 shown in fig. 3, when executing the hardware program 302.
For example, the hardware program 302 may be partitioned into one or more modules/units, which are stored in the memory 301 and executed by the processor 300 to complete the present application. One or more of the modules/units may be a series of hardware program instruction segments capable of performing specific functions that describe the execution of the hardware program 302 in the electronic device 30. For example, the hardware program 302 may be partitioned into modules 201 through 203 shown in fig. 3.
The electronic device 30 may include, but is not limited to, a processor 300, a memory 301. It will be appreciated by those skilled in the art that fig. 4 is merely an example of the electronic device 30 and is not limiting of the electronic device 30 and may include more or fewer components than shown, or certain components may be combined, or different components.
Memory 301 may be an internal storage unit of electronic device 30, such as a memory of electronic device 30. The memory 301 is used to store hardware programs and other programs and data required by the CPLD. The memory 301 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The embodiment of the application also provides an electronic system, which comprises the electronic device 30 and the MCU, wherein the electronic device 30 can comprise a CPLD.
The MCU is connected with the CPLD through a bus, and the CPLD is provided with N configuration storage areas, N transmission buffer areas and N receiving buffer areas.
Each transmitting buffer area corresponds to one expansion serial port, and each receiving buffer area corresponds to one expansion serial port.
Fig. 5 is a schematic structural diagram of an electronic system according to an embodiment of the present application, and as shown in fig. 5, the MCU and the CPLD are connected through a bus for communication.
The MCU is connected with a receiving bus Rbus of the CPLD, and the receiving bus R is connected with a transmitting bus Tbus of the CPLD.
The MCU sends the serial port configuration information to the CPLD through the sending bus T, and the CPLD analyzes the serial port configuration information to obtain serial port information of N expansion serial ports and effective data to be output by each expansion serial port.
The CPLD respectively stores the serial port information and the effective data of each extended serial port into a configuration storage area, and the configuration storage area can store the configuration information of the extended serial ports, wherein the configuration information comprises serial port numbers, baud rates, data bits, check bits and stop bit arrays.
After the analysis is completed, the stored content of each configuration storage area can be sent to a relevant sending buffer area, for example, the COM1 configuration storage area can send the stored relevant information of the expansion serial port 1 to the COM1 sending buffer area, and the COM1 sending buffer area sends the effective data to the connected external device 1 through the expansion serial port T1, so as to realize the control or communication of the external device 1.
The external device 1 may also transmit data to the COM1 transmission buffer of the CPLD through the expansion serial port R1. After the uploading condition is met, the CPLD can sequentially upload the device data of the external devices 1-N to the MCU according to the uploading priority, so that the MCU can acquire the device data of each external device in real time through N expansion serial ports.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the procedures in the methods of the foregoing embodiments, or may be implemented by instructing related hardware by a hardware program, where the hardware program may be stored in a computer readable storage medium, and the hardware program may implement the steps of the interface extension method embodiments of each power distribution terminal when executed by a processor. Wherein the hardware program comprises hardware program code, which may be in the form of source code, object code, executable files, some intermediate form, or the like. The computer readable medium may include: any entity or device capable of carrying hardware program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), an electrical carrier wave signal, a telecommunication signal, a software distribution medium, and so forth.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (9)

1. An interface expansion method of a power distribution terminal, wherein the power distribution terminal comprises an MCU and a CPLD which are connected through a bus, the interface expansion method is applied to the CPLD, and the interface expansion method comprises the following steps:
determining a state of the bus, the state including an idle state and an operational state;
when the bus is converted from an idle state to a working state, receiving and analyzing a data frame sent by the MCU, wherein the data frame does not contain a starting byte, and the data frame comprises serial port information of a plurality of expansion serial ports and effective data corresponding to each expansion serial port;
based on serial port information of each expansion serial port, transmitting effective data corresponding to each expansion serial port to a transmission buffer area of the corresponding expansion serial port;
the bus includes a receive bus of the CPLD, and the determining the state of the bus includes:
when the duration that the receiving bus is continuously in the high level is greater than or equal to the first duration, judging that the receiving bus is in an idle state; the first time length is determined according to the serial port baud rate of the receiving bus serial port of the CPLD;
when the duration that the receiving bus is continuously in the low level is greater than or equal to the second duration, judging that the receiving bus is in a working state;
the calculation formula of the first duration is as follows:
ST1 represents the first timeLength, B i The serial port baud rate of the CPLD receiving bus is represented, and Z represents the byte number of the receiving bus transmission.
2. The interface extension method of the power distribution terminal according to claim 1, wherein the receiving and analyzing the data frame sent by the MCU when the bus is converted from the idle state to the working state includes:
and after the duration of the continuous high level of the receiving bus is greater than or equal to the first duration, if the duration of the continuous low level of the receiving bus is greater than or equal to the second duration, receiving and analyzing the data frame sent by the MCU to obtain the serial port information of each expansion serial port and the effective data corresponding to each expansion serial port.
3. The interface extension method of a power distribution terminal according to claim 1, further comprising:
receiving device data sent by external devices, and storing each device data into a receiving buffer area corresponding to each expansion serial port according to a receiving sequence;
when the uploading condition is met, determining the uploading priority of each piece of equipment data according to the serial port information of each expansion serial port;
and uploading the equipment data of each receiving buffer zone to the MCU according to the uploading priority.
4. The interface expansion method of the power distribution terminal according to claim 3, wherein the serial port information includes serial port baud rate, and the determining the uploading priority of each device data according to the serial port information of each expansion serial port includes:
sequencing the serial port priorities of the expansion serial ports from high to low according to the serial port baud rate from high to low;
the uploading priority of each device data corresponds to the serial port priority of the expansion serial port corresponding to the receiving buffer area one by one;
wherein, the serial port information further includes a serial port number, and when serial port baud rates are the same, the method further includes:
and for the extended serial ports with the same serial port baud rate, sequencing the serial port priority of each extended serial port from high to low according to the serial port number of each extended serial port from low to high.
5. The interface extension method of a power distribution terminal according to claim 3, wherein the uploading condition includes:
for each expansion serial port, the equipment data received by the receiving buffer area of the expansion serial port reaches or exceeds a preset byte, and/or the receiving idle time of the expansion serial port reaches a third time; and the third time length is determined according to the serial port baud rate of the extended serial port.
6. The interface extension method of a power distribution terminal according to any one of claims 1 to 5, wherein the serial port information further includes a configuration command, a data bit number, a check bit, and a stop bit number.
7. An electronic device comprising a memory and a processor, the memory having stored therein a hardware program executable on the processor, characterized in that the processor, when executing the hardware program, implements the steps of the interface extension method of the power distribution terminal as claimed in any one of the preceding claims 1 to 6.
8. An electronic system comprising the electronic device of claim 7, further comprising an MCU, the electronic device comprising a CPLD;
the MCU is connected with the CPLD through a bus, and the CPLD is provided with N configuration storage areas, N sending cache areas and N receiving cache areas;
each transmitting buffer area corresponds to one expansion serial port, and each receiving buffer area corresponds to one expansion serial port.
9. A computer readable storage medium storing a hardware program, characterized in that the hardware program when executed by a processor implements the steps of the interface extension method of the power distribution terminal according to any one of the preceding claims 1 to 6.
CN202310987705.6A 2023-08-08 2023-08-08 Interface expansion method, electronic system, electronic device and medium of power distribution terminal Active CN116737635B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310987705.6A CN116737635B (en) 2023-08-08 2023-08-08 Interface expansion method, electronic system, electronic device and medium of power distribution terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310987705.6A CN116737635B (en) 2023-08-08 2023-08-08 Interface expansion method, electronic system, electronic device and medium of power distribution terminal

Publications (2)

Publication Number Publication Date
CN116737635A CN116737635A (en) 2023-09-12
CN116737635B true CN116737635B (en) 2023-11-07

Family

ID=87906268

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310987705.6A Active CN116737635B (en) 2023-08-08 2023-08-08 Interface expansion method, electronic system, electronic device and medium of power distribution terminal

Country Status (1)

Country Link
CN (1) CN116737635B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007150396A (en) * 2005-11-24 2007-06-14 Matsushita Electric Works Ltd Communication device
CN108089491A (en) * 2017-11-28 2018-05-29 武汉合康智能电气有限公司 A kind of multi-channel-CAN communication bus ports-Extending method and system
JP2020051381A (en) * 2018-09-28 2020-04-02 株式会社荏原製作所 Pump unit
CN112051758A (en) * 2019-06-06 2020-12-08 广东省大金创新电子有限公司 IO extension chip
CN112395230A (en) * 2020-12-21 2021-02-23 太原智林信息技术股份有限公司 UART interface extension circuit based on programmable logic device
CN115599733A (en) * 2022-10-21 2023-01-13 深圳市康必达控制技术有限公司(Cn) Circuit, method and device for expanding multi-path serial port and terminal equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007150396A (en) * 2005-11-24 2007-06-14 Matsushita Electric Works Ltd Communication device
CN108089491A (en) * 2017-11-28 2018-05-29 武汉合康智能电气有限公司 A kind of multi-channel-CAN communication bus ports-Extending method and system
JP2020051381A (en) * 2018-09-28 2020-04-02 株式会社荏原製作所 Pump unit
CN112051758A (en) * 2019-06-06 2020-12-08 广东省大金创新电子有限公司 IO extension chip
CN112395230A (en) * 2020-12-21 2021-02-23 太原智林信息技术股份有限公司 UART interface extension circuit based on programmable logic device
CN115599733A (en) * 2022-10-21 2023-01-13 深圳市康必达控制技术有限公司(Cn) Circuit, method and device for expanding multi-path serial port and terminal equipment

Also Published As

Publication number Publication date
CN116737635A (en) 2023-09-12

Similar Documents

Publication Publication Date Title
CN110224789B (en) Multi-mode HDLC controller based on FPGA
US20140068134A1 (en) Data transmission apparatus, system, and method
CN115296965B (en) Method, system and device for reducing delay and achieving timer balance configuration
CN110209613B (en) NVMe SSD reading speed and optical fiber interface speed self-adaptive matching method
CN111352887B (en) PCI bus-to-configurable frame length serial bus adaptation and transmission method
CN116737635B (en) Interface expansion method, electronic system, electronic device and medium of power distribution terminal
CN109450761B (en) Multifunctional 1553B communication module
CN203434983U (en) Fiber-channel data interface card with configurable FPGA (Field Programmable Gate Array)
CN111352888A (en) Interrupt signal generating method and device for asynchronous transceiver
CN116155843B (en) PYNQ-based pulse neural network chip data communication method and system
CN116074406B (en) Instruction sending method and device
CN108667706A (en) The adjustable Ethernet serial server of serial ports quantity dynamic and its data transmission method
CN107846709B (en) Wireless communication device and wireless communication method based on LoRa
CN116436526A (en) Method, device, system, storage medium and electronic equipment for controlling signal transmission
JP2003050788A (en) Apparatus and method for distribution of signal from high level data link controller to multiple digital signal processor core
CN115903744A (en) Automobile remote detection method and device, electronic equipment and storage medium
CN112800001A (en) High-performance Internet of things hardware platform and method based on ARM platform architecture
CN108614756A (en) FC-AE-ASM protocol processing chips with temp monitoring function
CN111830874A (en) Multi-channel serial digital signal transmission control device and method for train control system
CN221543743U (en) Distributed elevator key control device with super-strong anti-interference capability
CN110532110A (en) A kind of UART master control system for automatically switching to send data outside in multicore scene
WO2023160691A1 (en) Connector-based port management method and related device
CN221448409U (en) Ethernet multi-data channel switching system
CN110022380B (en) Access terminal for communication of safety and stability control system
US12057965B2 (en) Data communication method and apparatus, electronic device, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant