Background
With the development of embedded system technology, communication products mostly include a CPU (Central Processing Unit), an EPLD (Erasable programmable logic Device), and the like. In order to communicate with a computer by a CPU of an embedded device or accept configuration of the computer by an embedded system, the CPU needs to be connected with the computer through a serial port, and an RJ45 interface is mostly selected as a connection interface.
As shown in fig. 1, a block diagram of the interior of an embedded system currently selecting RJ45 for serial port communication is presented. The RJ45 interface includes 8 connection pins, and in serial communication, the pin 4 or 5 is often used as the signal ground GND, or the two pins 4 and 5 are simultaneously used as the signal ground GND, the pin 3 is used as the transmission signal line TX, and the pin 6 is used as the reception signal line RX. Therefore, in the embedded system, 4 or 5 pins of the RJ45 are not used, and are in an idle state. In fig. 1, when the pins 4 and 5 are simultaneously used as the signal ground GND, 4 pins are in an idle state.
Meanwhile, most embedded systems include a programmable logic device EPLD. The program downloading of these programmable logic devices is mainly realized by a downloading connection socket on a PCB board inside the system at present. In fig. 1, the download socket of the programmable logic device and the serial communication connector RJ45 are separate and independent from each other. When the programmable logic device needs to download or upgrade the program, the embedded device is usually powered off, the shell is disassembled, a download cable connected with the computer is connected to the download connecting socket, then the embedded device is powered on, and the program is downloaded to the programmable logic device through the computer. After downloading, powering down the equipment, pulling out the downloading cable from the downloading socket, reassembling the equipment, and powering up again for operation.
Therefore, when a program is downloaded or upgraded to a programmable logic device in an existing embedded device, the operation is complicated, and time-consuming and labor-consuming operations such as power-off and box opening are also required, and for devices using the programmable logic device and RJ45 as serial port communication, such as communication network devices such as switches and routers, the power-on and power-off operations may cause communication or network interruption.
Disclosure of Invention
The technical problem to be solved by the invention is to provide the embedded equipment and the method for downloading the program of the programmable logic device therein, solve the problems that the programmable logic device in the existing embedded equipment needs to be powered off and unpacked when downloading the program, and simply and conveniently realize the downloading of the programmable logic device.
In order to solve the above problems, the present invention provides an embedded device, which includes a CPU, a programmable logic device, and an RJ45 serial port connector, wherein:
a download signal line of the programmable logic device is connected to an idle pin of an RJ45 serial port connector;
the signal ground GND of the programmable logic device is connected with the signal ground GND of the RJ45 serial port connector.
A download signal line of the programmable logic device is connected to an idle pin of an RJ45 serial port connector in a direct connection mode; or the download signal line of the programmable logic device is connected to the idle pin of the RJ45 serial port connector through a gate control circuit.
A downloading signal line TCK of the programmable logic device is connected to a 1 st pin of an RJ45 serial port connector; a download signal line TMS of the programmable logic device is connected to a 2 nd pin of the RJ45 serial port connector; a download signal line TDI of the programmable logic device is connected to a 7 th pin of an RJ45 serial port connector; a load signal line TDO of the programmable logic device is connected to an 8 th pin of an RJ45 serial port connector; the signal ground GND of the programmable logic device is connected to the signal ground GND on the 4 th and/or 5 th pin of the RJ45 serial connector.
The gate control circuit is one of a triode, an MOS tube, an electronic switch, a relay or a logic chip. The control signal DCL of the gate control circuit is controlled by a programmable logic device, or by a CPU, or by other logic circuits.
When a control signal DCL of the gate control circuit is in a closed state, the gate control circuit is closed, the programmable logic device is communicated with the RJ45 serial port connector and can receive a program downloaded by a computer;
when a control signal DCL of the gate control circuit is in an off state, the gate control circuit is disconnected, and the programmable logic device is disconnected from the RJ45 serial port connector.
The invention also provides a method for downloading the program by the programmable logic device in the embedded equipment, which comprises the following steps:
connecting a download signal line of the programmable logic device to an idle pin of an RJ45 serial port connector; connecting a signal ground GND of the programmable logic device with a signal ground GND of an RJ45 serial port connector;
an external computer is connected with the RJ45 serial port connector, and programs needed by the programmable logic device are downloaded to the programmable logic device through the RJ45 serial port connector.
A download signal line of the programmable logic device is connected to an idle pin of an RJ45 serial port connector in a direct connection mode; or the download signal line of the programmable logic device is connected to the idle pin of the RJ45 serial port connector through a gate control circuit.
A downloading signal line TCK of the programmable logic device is connected to a 1 st pin of an RJ45 serial port connector; a download signal line TMS of the programmable logic device is connected to a 2 nd pin of the RJ45 serial port connector; a download signal line TDI of the programmable logic device is connected to a 7 th pin of an RJ45 serial port connector; a load signal line TDO of the programmable logic device is connected to an 8 th pin of an RJ45 serial port connector; the signal ground GND of the programmable logic device is connected to the signal ground GND on the 4 th and/or 5 th pin of the RJ45 serial connector.
When a download signal line of the programmable logic device is directly connected to an idle pin of an RJ45 serial port connector, if a program needs to be downloaded, then:
the equipment is powered off, a downloading cable connected with a computer is inserted into an RJ45 serial port connector, so that downloading signal lines TCK, TMS, TDI, TDO and GND are communicated, and after the equipment is powered on again, downloading or upgrading of the programmable logic device is completed.
When a download signal line of the programmable logic device is connected to an idle pin of an RJ45 serial port connector through a gate control circuit, if a program needs to be downloaded, the method comprises the following steps:
firstly, a download cable connected with a computer is inserted into an RJ45 serial port connector of an embedded device, a command is output through a serial port of the computer, a CPU outputs a gate control signal DCL, gate control switches are all in a closed state, and a programmable logic device is communicated with the RJ45 serial port connector;
then, the computer outputs the downloading program of the programmable logic device to the programmable logic device through the parallel port to realize downloading or upgrading of the programmable logic device;
and finally, outputting a command through a serial port of the computer, so that the CPU changes a gate control signal DCL, the gate control switches are all in a disconnected state, and the programmable logic device is disconnected from the RJ45 serial port connector.
In the prior art, because the download socket of the programmable logic device is arranged on the PCB inside the equipment, when the programmable logic device downloads or upgrades a program, the operation is complicated, time-consuming and labor-consuming operations such as power-off and box-opening are needed, and the production and maintenance are not utilized. Compared with the prior art, the invention uses the idle 4 pins in the serial port connector RJ45 as the downloading signal lines TCK, TMS, TDI and TDO of the programmable logic device, uses the signal ground GND used by the serial port as the signal ground GND downloaded by the programmable logic device, and directly realizes the program downloading and upgrading of the programmable logic device on the serial port connector RJ 45.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to the accompanying drawings.
In order to solve the inconvenience that a programmable logic device program needs to be powered off and unpacked when being downloaded or upgraded in an embedded device or a network device system using RJ45 for serial port communication, idle 4 pins in a serial port connector RJ45 can be used as download signal lines of the programmable logic device. When the programmable logic device program needs to be downloaded, a downloading cable does not need to be connected to a socket on the PCB, so that the shell of the equipment does not need to be opened. The downloading can be completed only by connecting the downloading cable to the serial port connector RJ45, and even the downloading of the program of the programmable logic device is completed under the condition of not shutting down and powering off, thereby supporting the hot plug characteristic. Through the improvement, the serial port connector RJ45 has the dual functions of serial port communication and program downloading of the programmable logic device, the function of the serial port is not influenced, and program downloading of the programmable logic device is facilitated.
Specifically, the spare 4 pins in the serial port connector RJ45 are used as the downloading signal lines of the programmable logic device (the downloading signals are TCK, TMS, TDI and TDO); the signal ground GND used for serial port communication in the serial port connector RJ45 is used as the signal ground GND downloaded by the programmable logic device (i.e. the signal ground GND on the 4 th and/or 5 th pins in the RJ45 is shared with the serial port).
The signal line between the serial port connector RJ45 and the programmable logic device can be directly connected, and can also be indirectly connected through a gating circuit by adding control of the gating circuit. The gate control circuit can be one of a triode, a MOS tube, an electronic switch, a relay or a logic chip. The control signal DCL of the gate control circuit may be controlled by a programmable logic device, may be controlled by the CPU, or may be controlled by another logic circuit.
Fig. 4 shows a connection cable for connecting the embedded device to the computer, the connection cable is used for connecting between the computer and the serial port, and is 1 cable, and two interfaces are separated from one end close to the computer, which are respectively a serial port connector and a parallel port connector. The serial connector is connected with pins 3, 6 and 4 of the RJ45 crystal head, and the parallel connector is connected with pins 1, 2, 5, 7 and 8 of the RJ45 crystal head.
The invention also provides another connecting cable for connecting the embedded device to the computer. The two cables are a serial port cable shown in fig. 5 and a parallel port cable shown in fig. 6, and the two cables are independent. Pins 3, 6, 4 and 5 of the crystal header of the serial port cable shown in fig. 5 are connected to the serial port of the computer; pins 1, 2, 4 and 5, 7, 8 of the crystal head of the parallel port cable shown in fig. 6 are connected to the parallel port of the computer.
Example 1
As shown in fig. 2, idle 4 pins in the serial port connector RJ45 are used as the downloading signal lines TCK, TMS, TDI and TDO of the programmable logic device, and the signal ground GND used by the serial port is used as the signal ground GND downloaded by the programmable logic device, so that program downloading and upgrading of the programmable logic device on the serial port connector RJ45 are directly realized.
In the directly connected application scenario shown in fig. 2, when a program of the programmable logic device needs to be downloaded, only the corresponding signal line in the download cable needs to be connected to the 5 signal lines (TCK, TMS, TDI, TDO, and GND) in the serial port connector RJ 45. And the serial communication still uses 4 pins (only three signals: TX, RX and GND) in the original RJ 45.
When a program of the programmable logic device needs to be downloaded, the crystal plug of the download cable in fig. 4 is inserted into the serial port connector RJ45 in fig. 2 under the condition that the device is powered off, so that the connection of the 5 download signal lines TCK, TMS, TDI, TDO and GND is realized. After the power is on, the programmable logic device can be downloaded or upgraded.
After downloading is completed, the power supply of the embedded device needs to be turned off, the RJ45 crystal plug on the cable is pulled out from the RJ45 of the serial port connector of the device, and then the device is powered on again, so that the device can normally operate. In this case, it is more appropriate to use a structure in which the serial cable shown in fig. 5 and the parallel cable shown in fig. 6 are independently separated.
Example 2
As shown in fig. 3, the spare 4 pins in the serial port connector RJ45 are used as the loading signal lines TCK, TMS, TDI and TDO of the programmable logic device, the signal ground GND used by the serial port is used as the signal ground GND downloaded by the programmable logic device, and a gate control circuit is added to the signal line between the serial port connector RJ45 and the programmable logic device, and controls the four switches S1, S2, S3 and S4.
The gate control circuit can be one of a triode, a MOS tube, an electronic switch, a relay or a logic chip. The control signal DCL of the gate control circuit may be controlled by a programmable logic device, may be controlled by the CPU, or may be controlled by another logic circuit. The gate control signal DCL controls the four switches S1, S2, S3, S4 to be closed or opened.
For example, when the control signal DCL of the gate control circuit is controlled by the CPU, if the CPU outputs the gate control signal DCL to make the four switches S1, S2, S3, and S4 all in a closed state, the programmable logic device is connected to the RJ45, and then the program downloaded by the computer is received; if the CPU outputs the gate control signal DCL to make the four switches S1, S2, S3 and S4 in the off state, the programmable logic device is disconnected from the RJ45, and the program downloaded by the computer cannot be received.
In specific implementation, if a user needs to download or upgrade a program to a programmable logic device, the downloading or upgrading can be completed according to the following procedures without power failure:
firstly, inserting an RJ45 crystal head of a serial port cable (also a parallel port cable) connected with the computer in the figure 4 into a serial port RJ45 of the embedded equipment;
then, a command is output through a serial port of the computer, so that the CPU outputs a gate control signal DCL, and the gate control signal DCL enables the four switches S1, S2, S3 and S4 to be in a closed state, thereby realizing the communication between the programmable logic device and the RJ 45;
then, the computer outputs the downloading program of the programmable logic device to the programmable logic device through the parallel port to realize the program downloading or upgrading of the programmable logic device;
finally, through a serial port output command of the computer, the CPU changes a gate control signal DCL, so that the four switches S1, S2, S3 and S4 are all in an off state, and the programmable logic device is disconnected from the RJ 45.
Therefore, the programmable logic device can be downloaded or upgraded without power failure, and even the normal operation of the system service can not be influenced.
Compared with the prior art, the invention uses the idle 4 pins in the serial port connector RJ45 as the downloading signal lines TCK, TMS, TDI and TDO of the programmable logic device, and uses the signal ground GND used by the serial port as the signal ground GND downloaded by the programmable logic device, thereby realizing the program downloading and upgrading of the programmable logic device on the serial port connector RJ 45. In addition, the control of the gate control circuit can be added to the signal line between the serial port connector RJ45 and the programmable logic device, and the control signal of the gate control circuit is controlled by the programmable logic device, the CPU, or other logic circuits. Therefore, only when the programmable logic device needs to download the program, the signal line between the serial port connector RJ45 and the programmable logic device can be conducted, and the program can be downloaded. Therefore, the function of the serial port is not influenced, and the advantages of safety, reliability and convenience in operation are achieved.
In a word, the invention realizes the program downloading or upgrading of the programmable logic device by using the serial port connector RJ45, simplifies the operation of the programmable logic device during production and maintenance, and is convenient for the operation of users.
The above description is only an example of the present invention, and is not intended to limit the present invention, and it is obvious to those skilled in the art that various modifications and variations can be made in the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.