CN111241020B - Serial port switching device and method based on FPGA and storage medium - Google Patents

Serial port switching device and method based on FPGA and storage medium Download PDF

Info

Publication number
CN111241020B
CN111241020B CN201911416066.8A CN201911416066A CN111241020B CN 111241020 B CN111241020 B CN 111241020B CN 201911416066 A CN201911416066 A CN 201911416066A CN 111241020 B CN111241020 B CN 111241020B
Authority
CN
China
Prior art keywords
serial port
fpga
switching
module
logic
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
CN201911416066.8A
Other languages
Chinese (zh)
Other versions
CN111241020A (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.)
Guangzhou Devecent Information Technology Co ltd
Original Assignee
Guangzhou Devecent Information Technology 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 Guangzhou Devecent Information Technology Co ltd filed Critical Guangzhou Devecent Information Technology Co ltd
Priority to CN201911416066.8A priority Critical patent/CN111241020B/en
Publication of CN111241020A publication Critical patent/CN111241020A/en
Application granted granted Critical
Publication of CN111241020B publication Critical patent/CN111241020B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Computer Hardware Design (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a serial port switching device, a serial port switching method and a storage medium based on an FPGA (field programmable gate array), wherein the serial port switching device comprises the following components: the FPGA serial port switching module can receive a logic switching instruction sent by the master control MCU through the SPI interface so as to switch a serial port communication mode according to the logic switching instruction so as to realize the communication between the master control MCU and a target peripheral module; the FPGA serial port switching module can receive a serial port connection setting updating instruction sent by the main control MCU through the JTAG interface so as to increase a new serial port connection mode according to the serial port connection setting updating instruction. The device realizes the switching of serial port channels through the FPGA, can realize that the port switches nanosecond level time delay, simultaneously, when having new serial port connection demand, can update the serial port intercommunication mode in the FPGA serial port switches the module.

Description

Serial port switching device and method based on FPGA and storage medium
Technical Field
The invention relates to the technical field of serial port switching, in particular to a serial port switching device and method based on an FPGA and a storage medium.
Background
At present, in the surveying and mapping industry and the driving test and training industry, complete machine instruments and equipment usually comprise a plurality of modules, communication needs to be carried out between the modules and a main control CPU in the stacking and integrating process of the modules, and the most common communication mode is an RS232 serial port. Aiming at the problem that the number of serial ports and peripheral equipment of an ARM embedded processor (such as STM32) is limited, the requirement of the number of the serial ports required by the design of a peripheral complete machine cannot be met; meanwhile, in the rapid development era of the technology updating, the updating and upgrading of software of each module all exist, and with the miniaturization of highly integrated equipment, the number of external interfaces of products is less and less, and when a certain corresponding peripheral firmware has bug or needs to be updated in function updating, the disassembling operation is often needed, which causes troubles in the upgrading and maintenance of the products.
The traditional industry generally adopts a relay or an analog switch to switch a serial port, the relay cannot be used under a platform with more interfaces due to larger volume, and meanwhile, electromagnetic conduction interference exists in the on-off switching process of the relay and the on-off switching frequency is too slow; the analog switch has a large on-off delay, and thus cannot meet the use requirement of a platform with a high communication speed requirement.
Disclosure of Invention
In order to overcome the defects of the prior art, one of the purposes of the invention is to provide a serial port switching device based on an FPGA, which realizes the switching of serial port channels through the FPGA, can realize nanosecond delay of port switching, and can update the serial port connection mode in an FPGA serial port switching module when new serial port connection requirements exist.
The invention also aims to provide a serial port switching method based on the FPGA, which realizes the switching of serial port channels through the FPGA, can realize nanosecond delay of port switching, and can update the serial port communication mode in the FPGA serial port switching module when new serial port connection requirements exist.
The invention also aims to provide a computer readable storage medium, which can realize the switching of serial port channels through the FPGA when a program in the storage medium runs, realize nanosecond delay of port switching, and update the serial port communication mode in the FPGA serial port switching module when a new serial port connection requirement exists.
One of the purposes of the invention is realized by adopting the following technical scheme:
the utility model provides a serial ports auto-change over device based on FPGA, this serial ports auto-change over device is applied to in the complete machine equipment, and the complete machine equipment includes a plurality of peripheral hardware modules and main control MCU, includes: the FPGA serial port switching module is connected with the first serial port channel, the SPI interface, a plurality of second serial port channels and an FPGA serial port switching module, the logic switching instruction sent by the main control MCU can be received by the FPGA serial port switching module through the SPI interface, and a serial port communication mode can be switched according to the logic switching instruction so as to realize the communication between the main control MCU and a target peripheral module; the FPGA serial port switching module can receive a serial port connection setting updating instruction sent by the main control MCU through the JTAG interface so as to add a new serial port connection mode according to the serial port connection setting updating instruction.
Furthermore, the system also comprises an external serial port used for independently upgrading each peripheral module, the external serial port is connected with the FPGA serial port switching module, and an external device can pass through the external serial port to be connected with the target peripheral module so as to upgrade the target peripheral module.
Further, the first serial port channel is provided with a plurality of second serial port channels, and the number of the second serial port channels is more than that of the first serial port channels.
Furthermore, the main control MCU adopts an ARM embedded processor.
Further, the main control MCU specifically adopts an STM32 singlechip.
The second purpose of the invention is realized by adopting the following technical scheme:
a serial port switching method based on FPGA is applied to the serial port switching device based on FPGA, and comprises the following steps:
receiving a logic switching instruction, and judging whether a serial port communication mode corresponding to the logic switching instruction is effective or not;
if not, returning an error response message;
and if so, switching to a corresponding serial port communication mode according to the logic switching instruction, and sending a confirmation response message.
Further, before determining whether the serial port communication mode corresponding to the logic switching instruction is valid, the method further includes the steps of:
judging whether the serial port communication mode corresponding to the logic switching instruction is consistent with the currently working serial port communication mode or not;
if yes, judging whether a serial port communication mode corresponding to the logic switching instruction is effective or not;
if not, the current switching process is ended.
Further, when the serial port communication mode corresponding to the logic switching instruction is consistent with the currently working serial port communication mode, a confirmation response message is returned.
Further, before receiving the logic switching instruction, the method comprises the initialization steps of: and entering a default serial port communication mode after power-on.
The third purpose of the invention is realized by adopting the following technical scheme:
a computer-readable storage medium, in which an executable computer program is stored, and when the computer program runs, the method for switching a serial port based on an FPGA can be implemented.
Compared with the prior art, the invention has the beneficial effects that:
the serial port switching device based on the FPGA realizes the switching of the serial port channel through the FPGA, can realize the nanosecond delay of port switching, and meanwhile can update the serial port communication mode in the FPGA serial port switching module when new serial port connection requirements are met.
Drawings
Fig. 1 is a block diagram of a serial port switching device based on an FPGA according to the present invention;
fig. 2 is a schematic flow chart of a serial port switching method based on an FPGA according to the present invention.
Detailed Description
The present invention will be further described with reference to the accompanying drawings and the detailed description, and it should be noted that any combination of the embodiments or technical features described below can be used to form a new embodiment without conflict.
Referring to fig. 1, a serial port switching device based on FPGA is applied to a complete machine device, the complete machine device includes a plurality of peripheral modules and a main control MCU, and includes: the FPGA serial port switching module is connected with the first serial port channel, the SPI interface, a plurality of second serial port channels and an FPGA serial port switching module, the logic switching instruction sent by the main control MCU can be received by the FPGA serial port switching module through the SPI interface, and a serial port communication mode can be switched according to the logic switching instruction so as to realize the communication between the main control MCU and a target peripheral module; the FPGA serial port switching module can receive a serial port connection setting updating instruction sent by the main control MCU through the JTAG interface so as to add a new serial port connection mode according to the serial port connection setting updating instruction.
The FPGA-based serial port switching device uses the FPGA as a high-speed channel switching switch for communicating a peripheral module with a master control MCU port, and is equivalent to designing a special serial port channel switching and expanding chip by using VHDL language; the FPGA serial port switching module is communicated with the main control MCU through an SPI interface, different serial ports are conducted according to different requirements, and nanosecond delay of port switching can be realized; meanwhile, when a new serial port connection requirement is met, the serial port connection mode in the FPGA serial port switching module can be updated, namely, a circuit solidified inside the FPGA can be upgraded through the main control MCU, and the subsequent new function upgrading work is greatly expanded.
The main control MCU sends a logic switching instruction through the MOSI, the FPGA receives the logic switching instruction, then logic conduction switching is carried out according to a corresponding serial port communication mode, a confirmation instruction is sent to the main control MCU end through the MISO after switching, and the switching of the whole logic process is in a nanosecond level.
In the early stage of design, the working modes of all the serial port connections stacked inside can be preset and the connections of the logic circuits are arranged according to the requirements of design requirements, the FPGA acquires the requirements of the MCU real-time serial port communication mode through communication with the master control MCU, and then the connection conditions of the internal logic circuits are switched according to the serial port communication mode, so that the flexible and efficient port switching function is realized.
In the aspect of function expansion, the main control MCU simulates one JTAG interface to be connected with a JTAG interface of the FPGA, if a new port is required to be connected for updating subsequently, based on the programmable configurable characteristic of the FPGA, the design can be modified by the VHDL again aiming at the new logic circuit requirement, and then the corresponding circuit is solidified into the FPGA through the simulated JTAG interface of the MCU so as to achieve the purpose of upgrading.
It should be noted that, the number of the first serial ports may also be multiple, but the number of the second serial ports is greater than that of the first serial ports, so as to achieve the effect of serial port expansion. The main control MCU adopts an ARM embedded processor, and specifically adopts an STM32 singlechip.
As a preferred implementation mode, the system further comprises an external serial port used for independently upgrading each peripheral module, the external serial port is connected with the FPGA serial port switching module, and an external device can be connected with the target peripheral module through the external serial port to upgrade the target peripheral module. Through this mode, it is outside to remain a serial ports and pass through FPGA and be connected to the host computer for switch on the serial ports of each peripheral module to outside serial ports, realize carrying out firmware upgrading and debugging to each module of host computer inside under the condition of not tearing open the machine, avoided the trouble of tearing open the machine, the customer operation of being more convenient for.
Correspondingly, referring to fig. 2, the present invention further provides a serial port switching method based on FPGA, which is applied to the serial port switching device based on FPGA, and includes the following steps:
receiving a logic switching instruction, and judging whether a serial port communication mode corresponding to the logic switching instruction is effective or not;
if not, returning an error response message;
and if so, switching to a corresponding serial port communication mode according to the logic switching instruction, and sending a confirmation response message.
The serial port switching is carried out based on the FPGA chip, the switching speed is high, the time delay is short, nanosecond time delay of port switching can be realized, and the method is very suitable for occasions with high requirements on data real-time performance and large data volume, such as surveying and mapping and driving test driving training.
As a preferred embodiment, before determining whether the serial port connectivity mode corresponding to the logic switching instruction is valid, the method further includes the steps of:
judging whether the serial port communication mode corresponding to the logic switching instruction is consistent with the currently working serial port communication mode or not;
if yes, judging whether a serial port communication mode corresponding to the logic switching instruction is effective or not;
if not, the current switching process is ended.
Before switching, whether the serial port communication mode is consistent with the current serial port communication mode is judged, if so, no operation is needed, and useless work is avoided. Of course, when the serial port communication mode to be switched is consistent with the current serial port communication mode, a confirmation response message may also be returned to the main control MCU.
Particularly, when the system is initially powered on, the system can automatically initialize and enter a default serial port communication mode.
The invention also provides a computer readable storage medium, wherein the computer readable storage medium stores an executable computer program, and the computer program can realize the serial port switching method based on the FPGA when running.
The computer-readable storage medium stores a computer program in which the method of the present invention, if implemented in the form of software functional units and sold or used as a stand-alone product, can be stored. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer storage medium and used by a processor to implement the steps of the embodiments of the method. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer storage medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer storage media may include content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer storage media that does not include electrical carrier signals and telecommunications signals as subject to legislation and patent practice.
The above embodiments are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited thereby, and any insubstantial changes and substitutions made by those skilled in the art based on the present invention are within the protection scope of the present invention.

Claims (9)

1. The utility model provides a serial ports auto-change over device based on FPGA, this serial ports auto-change over device is applied to in the complete machine equipment, and the complete machine equipment includes a plurality of peripheral hardware modules and main control MCU, its characterized in that includes: the FPGA serial port switching module is connected with the first serial port channel, the SPI interface, a plurality of second serial port channels and an FPGA serial port switching module, the logic switching instruction sent by the main control MCU can be received by the FPGA serial port switching module through the SPI interface, and a serial port communication mode can be switched according to the logic switching instruction so as to realize the communication between the main control MCU and a target peripheral module; the FPGA serial port switching module can receive a serial port connection setting updating instruction sent by a main control MCU through the JTAG interface so as to add a new serial port connection mode according to the serial port connection setting updating instruction;
the serial port switching device further comprises an external serial port used for independently upgrading each peripheral module, the external serial port is connected with the FPGA serial port switching module, and external equipment can pass through the external serial port and be connected with the target peripheral module so as to upgrade the target peripheral module.
2. The FPGA-based serial port switching device of claim 1, wherein the first serial port channel has a plurality of channels, and the second serial port channel is more than the first serial port channel in number.
3. The FPGA-based serial port switching device of claim 1, wherein the main control MCU employs an ARM embedded processor.
4. The FPGA-based serial port switching device of claim 3, wherein the main control MCU specifically adopts an STM32 singlechip.
5. An FPGA-based serial port switching method applied to the FPGA-based serial port switching device of any one of claims 1 to 4, comprising the following steps:
receiving a logic switching instruction, and judging whether a serial port communication mode corresponding to the logic switching instruction is effective or not;
if not, returning an error response message;
and if so, switching to a corresponding serial port communication mode according to the logic switching instruction, and sending a confirmation response message.
6. The serial port switching method based on the FPGA as claimed in claim 5, wherein before determining whether the serial port connectivity mode corresponding to the logic switching instruction is valid, the method further comprises the steps of:
judging whether the serial port communication mode corresponding to the logic switching instruction is consistent with the currently working serial port communication mode or not;
if yes, judging whether a serial port communication mode corresponding to the logic switching instruction is effective or not;
if not, the current switching process is ended.
7. The FPGA-based serial port switching method according to claim 6, wherein when the serial port connection mode corresponding to the logic switching instruction is consistent with the currently working serial port connection mode, a confirmation response message is returned.
8. The FPGA-based serial port switching method according to claim 5, comprising an initialization step before receiving the logic switching instruction: and entering a default serial port communication mode after power-on.
9. A computer-readable storage medium, wherein the computer-readable storage medium stores an executable computer program, and when the computer program runs, the method for switching the serial port based on the FPGA according to any one of claims 5 to 8 is realized.
CN201911416066.8A 2019-12-31 2019-12-31 Serial port switching device and method based on FPGA and storage medium Active CN111241020B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911416066.8A CN111241020B (en) 2019-12-31 2019-12-31 Serial port switching device and method based on FPGA and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911416066.8A CN111241020B (en) 2019-12-31 2019-12-31 Serial port switching device and method based on FPGA and storage medium

Publications (2)

Publication Number Publication Date
CN111241020A CN111241020A (en) 2020-06-05
CN111241020B true CN111241020B (en) 2022-04-22

Family

ID=70879651

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911416066.8A Active CN111241020B (en) 2019-12-31 2019-12-31 Serial port switching device and method based on FPGA and storage medium

Country Status (1)

Country Link
CN (1) CN111241020B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111865839B (en) * 2020-06-23 2022-07-12 国汽(北京)智能网联汽车研究院有限公司 Communication method, device and equipment of electronic control unit and computer storage medium
CN111813725A (en) * 2020-07-08 2020-10-23 济南浪潮数据技术有限公司 Computer equipment, serial port connection method, system and related equipment
CN112506840B (en) * 2020-12-07 2022-11-18 天津津航计算技术研究所 Many-to-many SPI bus switching method
CN112506839B (en) * 2020-12-07 2023-02-03 天津津航计算技术研究所 One-to-many SPI bus switching method and device
CN113625617A (en) * 2021-07-16 2021-11-09 思源电气股份有限公司 GMAC channel multiplexing system based on domestic MCU chip

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104320594A (en) * 2014-11-21 2015-01-28 连明昌 Serial port matrix switcher based on FPGA
CN204350149U (en) * 2014-11-21 2015-05-20 连明昌 Based on the serial ports matrix switcher of FPGA
WO2017193705A1 (en) * 2016-05-10 2017-11-16 中兴通讯股份有限公司 Method and apparatus for monitoring communication power supply device, and storage medium
CN107704285A (en) * 2017-09-27 2018-02-16 中国科学院微电子研究所 Field programmable gate array multi version configuration chip, system and method
CN108519889A (en) * 2018-03-22 2018-09-11 深圳华中科技大学研究院 A kind of FPGA program remote upgrading system and methods based on JTAG standard

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104320594A (en) * 2014-11-21 2015-01-28 连明昌 Serial port matrix switcher based on FPGA
CN204350149U (en) * 2014-11-21 2015-05-20 连明昌 Based on the serial ports matrix switcher of FPGA
WO2017193705A1 (en) * 2016-05-10 2017-11-16 中兴通讯股份有限公司 Method and apparatus for monitoring communication power supply device, and storage medium
CN107704285A (en) * 2017-09-27 2018-02-16 中国科学院微电子研究所 Field programmable gate array multi version configuration chip, system and method
CN108519889A (en) * 2018-03-22 2018-09-11 深圳华中科技大学研究院 A kind of FPGA program remote upgrading system and methods based on JTAG standard

Also Published As

Publication number Publication date
CN111241020A (en) 2020-06-05

Similar Documents

Publication Publication Date Title
CN111241020B (en) Serial port switching device and method based on FPGA and storage medium
WO2021098485A1 (en) Method and system for power-on and power-off control of pcie device
CN104483959A (en) Fault simulation and test system
CN104035803A (en) Method, device and programmer for updating CPLD/FPGA firmware
CN104199707A (en) System and method for upgrading FPGAs
CN101102566B (en) A design method and debugging method for mobile phone JTAG debugging interface signals
CN103927256A (en) Method for controlling multiple Android devices
CN103605542A (en) Online updater of FPGA configuration files
JP2007323648A (en) Device and method for operating usb interface equipment
CN103970569A (en) Server BIOS offline upgrading method
CN110888767A (en) Interface multiplexing module verification platform architecture and quick expansion implementation method
CN104407882A (en) Board card device
CN107480023A (en) A kind of method and system of disk failure injection
TWM427609U (en) USB port testing apparatus
CN108153626B (en) USB, serial port multiplexing and safety isolation system
CN110427206B (en) ZYNQ-based algorithm dynamic updating method
WO2024103635A1 (en) Cpld program upgrading method and apparatus for motor controller, motor controller and vehicle
CN105490844A (en) PCIe port reconstruction method
CN111025046B (en) Test system, method for controlling matrix switch and storage medium
CN102664836A (en) Prototype verification platform for broadband wireless communication digital baseband processor
CN111008102A (en) FPGA accelerator card high-speed interface SI test control device, system and method
CN110647431B (en) Test box for board card and complete machine diagnosis test
CN102955724A (en) BIOS (basic input output system) test fixture and method using same for BIOS test
US20170185705A1 (en) Method and device for simulating disk drive
CN204066094U (en) To the system that FPGA upgrades

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