A token ring based SPI backplane bus communication method

By using the token ring SPI backplane bus communication method, the problems of data garbled characters and high cost in multi-slave SPI communication are solved, achieving cost reduction and reliable and stable data transmission, and expanding the number of slave devices.

CN115658584BActive Publication Date: 2026-06-26CHINA RAILWAY CONSTR HEAVY IND +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA RAILWAY CONSTR HEAVY IND
Filing Date
2022-10-28
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In SPI communication with multiple slave devices, sharing a single CS signal line among multiple slave devices may lead to data corruption, increasing the number of signal lines and cost.

Method used

The SPI backplane bus communication method using token rings constructs a ring shift register consisting of a master device and a slave device. The token ring controls the slave device's access to the SPI bus, reducing the number of chip select signal lines. No dedicated chip select signal line connection is required between the master device and the slave device.

Benefits of technology

It reduces the cost of SPI communication, increases the scalability of slave devices, ensures the reliability and stability of data transmission, and does not reduce the data transmission rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115658584B_ABST
    Figure CN115658584B_ABST
Patent Text Reader

Abstract

The application provides a token ring-based SPI backplane bus communication method, and constructs a token ring composed of a master device and slave devices; the master device comprises a master device single-chip microcomputer; the slave devices comprise slave device single-chip microcomputers; the master device single-chip microcomputer and all the slave device single-chip microcomputers are respectively connected with a flip-flop; all the flip-flops are serially cascaded to form a ring shift register for delivering tokens; a communication line is arranged between the master device single-chip microcomputer and the slave device single-chip microcomputers; a slave device obtaining a token obtains the right to access the SPI bus and performs SPI communication with the master device. The application has the advantages that the chip selection signal line is not required to be arranged between the master device and the slave devices, the pin burden of the master device is reduced; the different slave devices do not interfere with each other in communication, the master device reduces the number of chip selection signal lines, the cost is reduced, the transmission of data between the slave devices is ensured to be reliable and stable, and the application does not reduce the data transmission rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of communication technology, and more specifically to an SPI backplane bus communication method based on token ring. Background Technology

[0002] SPI (Serial Peripheral Interface) is mainly used between EEPROM, Flash, Real-Time Clock (RTC), Digital-to-Analog Converter (ADC), Network Controller, MCU, Digital Signal Processor (DSP), and Digital Signal Decoder to achieve high-speed, full-duplex transmission of communication data.

[0003] SPI uses a master-slave communication mode, consisting of one master device and one or more slave devices. SPI uses four communication lines: MOSI (Master Output, Slave Input), MISO (Master Input, Slave Output), CLK (Clock), and CS (Chip Select). Both the master and slave devices have a serial shift register. At the tick of the clock signal, the master device writes one byte to its serial shift register, initiating a transfer. The register transmits the byte to the slave device identified by the chip select signal via the MOSI line. The corresponding slave device also transmits the contents of its shift register to the master device via the MISO line, thus completing the master-slave communication.

[0004] In traditional master-slave communication, if multiple slave devices share a single CS signal line, data corruption may occur during master-slave communication. Therefore, each slave device needs a dedicated CS signal line to connect to the master device, which increases the number of signal lines and thus increases costs, making it difficult to control the cost of SPI communication.

[0005] In summary, given the aforementioned problems encountered when using SPI communication with a master-slave architecture, it is essential to research a method that can reduce the cost of SPI communication while ensuring data transmission rate and quality. Summary of the Invention

[0006] The purpose of this invention is to provide an SPI backplane bus communication method based on token ring, and the specific technical solution is as follows:

[0007] A token ring-based SPI backplane bus communication method first establishes a communication connection consisting of a master device and at least one slave device. The master device includes a master device microcontroller, and the slave devices include slave device microcontrollers. Each of the master device microcontroller and all the slave device microcontrollers is connected to a flip-flop. All the flip-flops are serially cascaded to form a ring shift register for transmitting tokens. A communication line is set between the master device microcontroller and the slave device microcontrollers.

[0008] The SPI backplane bus communication method based on the token ring is as follows: the bit bits of the master device and the slave device are initialized, the token starts from the master device and passes through the flip-flop on the ring shift register, the slave device microcontroller obtains the token through the ring shift register and the corresponding slave device and master device communicate once.

[0009] Preferably, the SPI backplane bus communication method further includes slave device status detection based on the token ring. The slave device status detection includes slave device number detection, specifically: the token starts from the master device, passes through the flip-flops on the ring shift register, and returns to the master device. The number of flip-flops that the token passes through minus 1 is the total number of slave devices.

[0010] Preferably, the slave device status detection further includes slave device communication detection, specifically: the master device configures address information for all slave devices, the master device obtains the number of communicable slave devices and compares it with the total number of slave devices to determine whether there are any slave devices that cannot perform data communication.

[0011] Preferably, the token passing process is as follows: the master device sends a clock signal to drive the communication request in the master device to move in the ring shift register. For each rising edge of the clock signal, the ring shift register moves forward by 1 bit, thereby realizing the token passing.

[0012] Preferably, different slave device microcontrollers are connected in parallel, and the slave device communicates directly with the master device through a signal line after obtaining the token.

[0013] Preferably, a single communication process between the master device and the slave device is as follows:

[0014] The ring shift register sends the token to the slave device with the same bit as the master device via the MOSI signal line, and the slave device returns the contents of the corresponding flip-flop to the master device via the MISO signal line.

[0015] Preferably, the trigger is a D trigger chip.

[0016] The application of the technical solution of the present invention has the following beneficial effects:

[0017] The triggers in this invention are serially cascaded to form a ring shift register, or token ring, which controls the slave device's access to the SPI bus. Furthermore, the master and slave devices do not need to be connected via chip select signal lines, reducing the number of chip select signal lines, lowering costs, reducing the pin load on the master device, and thus allowing for an expansion of the number of slave devices.

[0018] Before communication between the master and slave devices, the master device configures unique address information for each slave device. A shift register is used to specify the slave device communicating with the master. When the master device issues a communication request, the previous slave device has already completed communication with the master. Therefore, different slave devices in the SPI bus will not interfere with each other's communication, data transmission between the master and slave devices is reliable and stable, and this invention does not reduce the data transmission rate.

[0019] The token ring in this invention can detect the communication status and number of slave device modules in real time. Each time a token is returned, the master device checks whether the number of triggers matches the expected number and whether there are any slave devices that cannot communicate with data, thereby obtaining the communication status and number of slave device modules in real time.

[0020] In addition to the objectives, features, and advantages described above, the present invention has other objectives, features, and advantages. The invention will now be described in further detail with reference to the figures. Attached Figure Description

[0021] The accompanying drawings, which form part of this application, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings:

[0022] Figure 1 This is a schematic diagram of a token ring-based communication connection;

[0023] Figure 2 This is a schematic diagram of a token ring;

[0024] Figure 3 This is a diagram illustrating the token transfer process. Detailed Implementation

[0025] In traditional SPI communication with one master and multiple slave devices, if multiple slave devices share a single CS signal line, data corruption may occur during communication between the master and slave devices. Therefore, each slave device requires a dedicated CS signal line to connect to the master device, which increases the number of chip select signal lines and thus raises costs, hindering cost control in SPI communication. The embodiments of the present invention are described in detail below with reference to the accompanying drawings; however, the present invention can be implemented in many different ways as defined and covered by the claims.

[0026] Example 1:

[0027] See Figure 1 This embodiment discloses an SPI backplane bus communication method based on token ring, which solves the problems of garbled characters caused by simultaneous communication of slave devices and excessive cost of chip select signal lines when using SPI communication with one master and multiple slave devices.

[0028] First, a token ring consisting of one master device and n slave devices is constructed. The master device includes a master device microcontroller, and each slave device includes a slave device microcontroller. The master device microcontroller and all the slave device microcontrollers are each connected to a flip-flop via a chip select signal line. All the flip-flops are cascaded serially to form a ring shift register for transmitting tokens, i.e., the token ring. A communication line is set between the master device microcontroller and the slave device microcontrollers.

[0029] It should be noted that, in this embodiment, each slave device microcontroller and master device microcontroller is preferably equipped with a communication line, and different slave device microcontrollers are connected in parallel, so that the slave device microcontrollers and master device microcontrollers can communicate one-to-one.

[0030] Specifically, the master device microcontroller has pins such as CLK-1, MISO, MOSI, RI, RO, and CLK-2, while the slave device microcontroller has pins such as CKL, MISO, MOSI, and CS. The trigger is a D flip-flop chip. The MISO pin on the master device microcontroller connects to the MOSI pin on the slave device microcontroller for signal input from the master device to the slave device. The MOSI pin on the master device microcontroller connects to the MISO pin on the slave device microcontroller for signal input from the slave device to the master device. CLK-1 connects to CKL to output a CKL-1 clock signal to maintain synchronization between MOSI and MISO for data transmission. RI and RO are the shift-in and shift-out ports of the shift register, respectively. CKL-2 connects to the D flip-flop chip on the slave device to drive the token in the ring shift register. CS connects to the D flip-flop chip to input the token to the slave device microcontroller, enabling the slave device microcontroller to obtain communication permission. In this embodiment, the preferred D flip-flop chip is the SN74LVC1G74 model.

[0031] The specific implementation steps of the SPI backplane bus communication method based on token ring for communication between the master and slave devices are as follows:

[0032] The first step is to initialize the token. Specifically, the master device initializes the token by setting the master device's bit to 1 and all other slave devices' bits to 0. At this point, the token is located in the master device.

[0033] The second step is device initialization. Specifically, upon initial power-on or power-back, the master device initializes the configuration of all slave devices, and each slave device obtains unique address information. Simultaneously, the master device can obtain the total number of slave devices through the token ring. During the process of allocating address information to slave devices, the master device can also obtain the slave device status and establish configuration information. The specific methods are as follows:

[0034] ① Obtain the total number of slave devices:

[0035] like Figure 1Driven by the CLK-2 clock signal, the token starts from the RO of the master device's microcontroller, passes through the D flip-flop chips of each slave device in sequence, and finally returns to the master device via the RI. The number of shifts (number of D flip-flop chips) that the token has passed through minus 1 is the total number of slave devices.

[0036] ②Detection from equipment status:

[0037] Each time a token is returned, the master device checks whether the number of slave devices matches the total number of slave devices, whether there are any slave devices that cannot communicate with data, and whether a slave device has gone offline.

[0038] ③ Create a configuration information table:

[0039] Each slave device inputs its own address information to the master device. The master device then builds a configuration information table based on this address information, ensuring inter-station network communication compatibility. The data area is divided into uplink and downlink data areas according to the transmission direction, and the master device maintains a configuration information table for each slave device. This embodiment uses a token ring to detect device status, which is highly efficient and can promptly identify any communication anomalies among slave devices.

[0040] The third step is to set the parameters. Specifically, the CLK-1 clock signal is used to keep the data transmission of MOSI and MISO synchronized. Before the CLK-1 clock signal is issued, the clock frequency is selected by programming the D flip-flop chip of the master device to determine the transmission speed of the entire SPI bus.

[0041] The fourth step is token transfer, specifically: (e.g.) Figure 2 and Figure 3 As shown, driven by the CLK-2 clock signal, the token moves in the ring shift register via RO. For each rising edge of the CLK-2 clock signal, the ring shift register moves forward by 1 bit, thereby enabling the token to be transferred between the slave devices.

[0042] The fifth step is to determine the slave device for communication. Specifically, when the slave device's bit is 1, it obtains a token and enables the SPI bus chip select signal, giving the slave device permission to access the SPI bus. Other slave devices, whose chip select signals are not enabled, will not drive the bus, thus avoiding bus conflicts.

[0043] The sixth step involves communication between the master and slave devices. Specifically, the ring shift register sends the communication request from the master device to the corresponding slave device via the MOSI signal line. Simultaneously, the slave device returns the contents of its D flip-flop chip to the master device via the MISO signal line. This completes one communication cycle between the master and slave devices. It should be noted that in this embodiment, the preferred communication request is a bit sequence sent by the master device.

[0044] The token ring-based SPI backplane bus communication method disclosed in this embodiment uses a token ring to control the communication between the master and slave devices. This eliminates the need for slave devices to have dedicated chip select signal lines to connect to the master device, reducing the pin load on the master device and lowering costs without compromising communication efficiency. It also increases the number of scalable slave devices. It should be noted that when the number of slave devices exceeds seven, the number of pins in the master device's microcontroller does not increase with the number of slave devices, thus reducing the pin load on the master device's microcontroller.

[0045] Before communication between the master and slave devices in this embodiment, the master device configures unique address information for each slave device. A shift register is used to specify the slave device communicating with the master. For example, when the master device communicates with slave device m, the master device's communication request sequentially iterates through slave devices 1 to n in the ring shift register. When a bit of slave device m is 1, slave device m obtains the token and then begins communication between the master and slave device m. The advantage is that when the master device issues a communication request, the previous slave devices have already completed communication with the master. Therefore, different slave devices in the SPI bus will not interfere with each other's communication with the master device. Data transmission between the master and slave devices is reliable and stable, and this embodiment does not reduce the data transmission rate.

[0046] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A token ring-based SPI backplane bus communication method, characterized in that, First, a communication connection is established consisting of a master device and at least one slave device. The master device includes a master device microcontroller, and the slave device includes a slave device microcontroller. Each of the master device microcontroller and all the slave device microcontrollers is connected to a trigger. All the flip-flops are cascaded in series to form a ring shift register for passing tokens, and a communication line is set between the master device microcontroller and the slave device microcontroller; SPI communication based on the token ring specifically involves: initializing the bit bits of the master device and the slave device; the token originates from the master device and passes through the flip-flop on the ring shift register; the slave device microcontroller obtains the token through the ring shift register and the corresponding slave device and master device communicate once. The communication process between the master device and the slave device includes: The first step is to initialize the token. Specifically, the master device initializes the token by setting the master device's bit to 1 and all other slave devices' bits to 0. At this time, the token is located in the master device. The second step is device initialization. Specifically, upon initial power-on or power-back, the master device initializes the configuration of all slave devices, and each slave device obtains unique address information. Simultaneously, the master device can obtain the total number of slave devices through the token ring. During the process of allocating address information to slave devices, the master device can also obtain the slave device status and establish configuration information. The specific methods are as follows: Driven by the CLK-2 clock signal, the token starts from the RO of the master device's microcontroller, passes through the D flip-flop chips of each slave device in sequence, and finally returns to the master device via the RI. The number of shifts the token has passed through minus 1 is the total number of slave devices. Each time a token is returned, the master device checks whether the number of slave devices matches the total number of slave devices to determine if a slave device has gone offline. Each slave device inputs its own address information to the master device. The master device establishes a configuration information table based on the address information to ensure inter-station network communication compatibility. The data area is divided into uplink data area and downlink data area according to the transmission direction. The master device maintains a configuration information table for the slave devices. The third step is to set the parameters. Specifically, the CLK-1 clock signal is used to keep the data transmission of MOSI and MISO synchronized. Before the CLK-1 clock signal is issued, the clock frequency is selected by programming the D flip-flop chip of the master device to determine the transmission speed of the entire SPI bus. The fourth step is token transfer, which is as follows: Driven by the CLK-2 clock signal, the token moves in the ring shift register via RO. For each rising edge of the CLK-2 clock signal, the ring shift register moves forward by 1 bit, thereby realizing the transfer of the token between the slave devices. The fifth step is to determine the slave device for communication. Specifically, when the slave device's bit is 1, it obtains a token and enables the SPI bus chip select signal of the slave device, thus giving the slave device the right to access the SPI bus. The sixth step is the communication between the master and slave devices. Specifically, the ring shift register sends the communication request from the master device to the corresponding slave device through the MOSI signal line. At the same time, the slave device also returns the contents of its own D flip-flop chip to the master device through the MISO signal line. Thus, the master and slave devices have completed one communication.

2. The SPI backplane bus communication method according to claim 1, characterized in that, It also includes slave device status detection based on the token ring. The slave device status detection includes slave device number detection. Specifically, the token travels from the master device, passes through the triggers on the ring shift register, and returns to the master device. The number of triggers the token passes through minus 1 is the total number of slave devices.

3. The SPI backplane bus communication method according to claim 2, characterized in that, The slave device status detection also includes slave device communication detection, specifically: the master device configures address information for all slave devices, the master device obtains the number of communicable slave devices and compares it with the total number of slave devices to determine whether there are any slave devices that cannot communicate with each other.

4. The SPI backplane bus communication method according to claim 1, characterized in that, The token passing process is as follows: the master device sends a clock signal to drive the token to move in the ring shift register. For each rising edge of the clock signal, the ring shift register moves forward by 1 bit, thereby realizing the token passing.

5. The SPI backplane bus communication method according to claim 1, characterized in that, Different slave device microcontrollers are connected in parallel, and after obtaining a token, the slave device communicates directly with the master device through a signal line.

6. The SPI backplane bus communication method according to claim 5, characterized in that, A single communication process between the master device and the slave device is as follows: The ring shift register sends the communication request from the master device to the slave device that acquires the token via the MOSI signal line, and the slave device returns the contents of the corresponding trigger to the master device via the MISO signal line.

7. The SPI backplane bus communication method according to any one of claims 1-6, characterized in that, The trigger is a D trigger chip.