A serial peripheral interface slave and communication system
By using the clock control module and reset module in the SPI communication system to generate the working clock signal and module reset signal, the problems of high economic cost and power consumption in the SPI communication system are solved, the response speed and flexibility of the slave are improved, and the Fast response and low power consumption.
Patent Information
- Application Number
- CN202411204679.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2044-08-30
AI Technical Summary
The existing SPI communication system needs to be equipped with an internal oscillator or an external clock source in automotive applications and other systems, resulting in high economic and time costs. At the same time, the long-term opening of the external clock source consumes a lot of power consumption, which increases the slave's Power-on and wake-up time.
A serial peripheral interface slave is designed, including a clock control module, a reset module and a data transceiver module. The serial clock signal and chip select signal sent by the host generate a working clock signal, avoiding the use of internal or external clock sources. , and generate a module reset signal based on the system reset signal through the reset module to realize the status register reset of the data transceiver module.
Reduces economic costs and power consumption, avoids data misalignment, improves the response speed and flexibility of the slave, reduces the waiting time for wake-up and working clock establishment, optimizes power consumption, and realizes the fast response of the slave to the bus. .
Smart Images

Figure CN118747162B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a serial peripheral interface slave and a communication system. Background Art
[0002] Serial Peripheral Interface (SPI) is a high-speed, full-duplex data communication interface. Traditional SPI communication often uses a four-wire mode to achieve high-speed synchronous transmission of data between devices with a one-master-multiple-slave bus architecture. For example, SPI communication can be used to read non-volatile storage data.
[0003] In automotive applications and other system applications, the system is equipped with a large number of slaves such as sensors and motor drivers that do not require complex control. The above slaves only need to be configured with a communication interface for configuring internal registers and returning internal status. SPI is used as the communication interface for the above slaves due to its advantages such as fast communication speed, full-duplex and no need to negotiate communication rate.
[0004] At present, the SPI slave needs to be equipped with an internal oscillator or an external clock source to provide the SPI slave with a working clock, which is used to parse the SPI protocol, respond to SPI read and write requests, and record the status of the SPI slave, etc. However, whether it is equipped with an internal oscillator or an external clock source, it will increase the economic cost; at the same time, the long start time of the external clock source will consume a lot of power, and during the slave startup and wake-up process, the external clock source is turned on for a long time, which increases the slave startup time and wake-up time, resulting in increased time cost. Summary of the invention
[0005] The present invention provides a serial peripheral interface slave and a communication system to solve the problems of high economic and time costs of current SPI communication and the problem of high power consumption of an external clock source.
[0006] In a first aspect, the present invention provides a serial peripheral interface slave, wherein the serial peripheral interface slave comprises: a clock control module, a reset module and a data transceiver module;
[0007] The clock control module is connected to the serial clock signal and the chip select signal, and is used to generate a working clock signal according to the serial clock signal and the chip select signal; the working clock signal includes a sampling clock signal and a shift clock signal;
[0008] The reset module is connected to the serial clock signal, the chip select signal and the system reset signal, and is used to generate a module reset signal according to the serial clock signal, the chip select signal and the system reset signal;
[0009] The data transceiver module receives the input data signal and the chip select signal. The data transceiver module is connected to the clock control module and the reset module, and is used to communicate with the host according to the working clock signal, the input data signal and the chip select signal. The data transceiver module is also used to reset according to the module reset signal.
[0010] In a second aspect, the present invention provides a serial peripheral interface communication system, wherein the serial peripheral interface communication system comprises: a host, at least one serial peripheral interface slave provided by the first aspect above, and a state machine;
[0011] The first output end of the host is connected to the first input end of the serial peripheral interface slave; the second output end of the host is connected to the second input end of the serial peripheral interface slave; the third output end of the host is connected to the third input end of the serial peripheral interface slave; the first input end of the host is connected to the first output end of the serial peripheral interface slave; the first output end of the host is used to provide a serial clock signal for the serial peripheral interface slave, the second output end of the host is used to provide a chip select signal for the serial peripheral interface slave, the third output end of the host is used to provide an input data signal for the serial peripheral interface slave, and the first input end of the host is used to communicate with the serial peripheral interface slave;
[0012] The output terminal of the state machine is connected to the fourth input terminal of the serial peripheral interface slave machine, and is used to provide a system reset signal for the serial peripheral interface slave machine.
[0013] The technical solution of the present invention is to set a clock control module to generate a working clock signal of a serial peripheral interface slave according to a serial clock signal and a chip select signal sent by a host, and it is not necessary to set an internal oscillator inside the serial peripheral interface slave or to set an external clock source outside to generate a working clock signal of the serial peripheral interface slave, which effectively reduces economic costs, avoids the problem that a large amount of power is consumed by a long opening time of an external clock source, and can also avoid data misalignment caused by clock deviation of a master-slave system, thereby ensuring strict synchronization of data. At the same time, the host can freely control the frequency of the serial clock signal, and the serial peripheral interface slave can be adapted according to the frequency, so that SPI communication is more flexible, and the waiting time for the slave to wake up and establish the working clock is greatly reduced, the response speed of the slave is effectively improved, and the slave is realized to respond quickly to the bus, and the time cost is reduced. When the host and the slave do not communicate, the generation of the slave working clock signal can be stopped, which effectively reduces the standby power consumption, and the slave can adjust the frequency of the working clock according to the data rate and processing requirements, further optimizing the power consumption. The present invention sets a reset module to generate a module reset signal according to a serial clock signal, a chip selection signal and a system reset signal to reset the status register in the data transceiver module, without the need to set an external reset signal generation source, thereby further reducing economic costs.
[0014] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0016] Figure 1 It is a structural schematic diagram of a serial peripheral interface communication system provided by an embodiment of the present invention.
[0017] Figure 2 It is a schematic diagram of the structure of another serial peripheral interface communication system provided by an embodiment of the present invention.
[0018] Figure 3 It is a structural schematic diagram of a clock control module provided by an embodiment of the present invention.
[0019] Figure 4 It is a structural schematic diagram of another clock control module provided by an embodiment of the present invention.
[0020] Figure 5 It is a schematic diagram of the structure of another serial peripheral interface communication system provided by an embodiment of the present invention.
[0021] Figure 6 It is a structural schematic diagram of a first reset signal generating unit provided by an embodiment of the present invention.
[0022] Figure 7 It is a structural schematic diagram of another first reset signal generating unit provided in an embodiment of the present invention.
[0023] Figure 8 It is a structural schematic diagram of a second reset signal generating unit provided in an embodiment of the present invention.
[0024] Fig. 9 It is a structural schematic diagram of another second reset signal generating unit provided in an embodiment of the present invention.
[0025] Fig.10 The present invention provides a signal timing diagram of a serial peripheral interface communication system.
[0026] Fig.11 The present invention provides a flowchart of a serial peripheral interface slave performing read and write operations.
[0027] Fig.12 The present invention provides a data frame command sending and response sequence diagram. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] Figure 1 is a schematic diagram of the structure of a serial peripheral interface communication system provided by an embodiment of the present invention, such as Figure 1 As shown, the serial peripheral interface communication system includes a host 1, at least one serial peripheral interface slave 2 and a state machine (not shown in the figure). Figure 1 The exemplary serial peripheral interface communication system includes a serial peripheral interface slave 2, and the host 1 interacts with the serial peripheral interface slave 2 through four SPI buses, wherein the four SPI buses include a serial clock signal line, a chip select signal line, a host transmit slave receive line, and a host receive slave transmit line.
[0031] The first output terminal of the host 1 is connected to the first input terminal of the serial peripheral interface slave 2 through the serial clock signal line, and the serial clock signal SCK is sent to the serial peripheral interface slave 2 through the serial clock signal line, so as to realize the synchronous reception and transmission of data between the host 1 and the serial peripheral interface slave 2. The second output terminal of the host 1 is connected to the second input terminal of the serial peripheral interface slave 2 through the chip select signal line, and the chip select signal SSN is sent to the serial peripheral interface slave 2 through the chip select signal line, so that the host 1 selects the serial peripheral interface slave 2 that needs to communicate. The third output terminal of the host 1 is connected to the third input terminal of the serial peripheral interface slave 2 through the host transmission slave receiving line, and the input data signal MOSI is sent to the serial peripheral interface slave 2 through the host transmission slave receiving line, so that the host 1 can send data serially or the serial peripheral interface slave 2 can receive data serially. The first output terminal of the serial peripheral interface slave 2 is connected to the first input terminal of the host 1 through the host receiving slave transmitting line, and the output data signal MISO is sent to the host 1 through the host receiving slave transmitting line, which is used for the host 1 to receive data serially or the serial peripheral interface slave 2 to send data serially. The output terminal of the state machine is connected to the fourth input terminal of the serial peripheral interface slave 2, and is used to provide the system reset signal rst_n for the serial peripheral interface slave 2.
[0032] The serial peripheral interface slave 2 includes: a clock control module 21, a reset module 22 and a data transceiver module 23. The clock control module 21 is connected to the serial clock signal SCK and the chip select signal SSN, and is used to generate a working clock signal according to the serial clock signal SCK and the chip select signal SSN. The working clock signal includes a sampling clock signal smp_clk and a shift clock signal sft_clk. The reset module 22 is connected to the serial clock signal SCK, the chip select signal SSN and the system reset signal rst_n, and is used to generate a module reset signal according to the serial clock signal SCK, the chip select signal SSN and the system reset signal rst_n. The data transceiver module 23 is connected to the input data signal MOSI and the chip select signal SSN. The data transceiver module 23 is connected to the clock control module 21 and the reset module 22, and is used to communicate with the host 1 according to the working clock signal, the input data signal MOSI and the chip select signal SSN; the data transceiver module 23 is also used to reset according to the module reset signal.
[0033] Specifically, when the host 1 needs to communicate with the serial peripheral interface slave 2, the chip select signal SSN sent by the host 1 to the serial peripheral interface slave 2 is at a valid level, and illustratively, the chip select signal SSN is valid when it is at a low level. The clock control module 21 receives the serial clock signal SCK and the chip select signal SSN sent by the host 1. The clock control module 21 can perform a logical operation on the serial clock signal SCK and the chip select signal SSN to output a working clock signal to the data transceiver module 23. The working clock signal can include a sampling clock signal smp_clk and a shift clock signal sft_clk.
[0034] The reset module 22 also receives the serial clock signal SCK and the chip select signal SSN sent by the host 1, and also receives the system reset signal rst_n, which can be sent by the state machine in the serial peripheral interface communication system to the reset module 22. The reset module 22 can perform logic operations on the serial clock signal SCK, the chip select signal SSN and the system reset signal rst_n to output the module reset signal to the data transceiver module 23.
[0035] The data transceiver module 23 receives the working clock signal sent by the clock control module 21 and the input data signal MOSI and the chip select signal SSN sent by the host 1. The chip select signal SSN can be used as a register operation clock signal. The data transceiver module 23 parses the input data signal MOSI according to the working clock signal, and sends the output data signal MISO to realize the communication between the host 1 and the serial peripheral interface slave 2. The serial peripheral interface slave 2 also includes a target register 24. Exemplarily, the data transceiver module 23 parses the input data signal MOSI according to the working clock signal, thereby obtaining a read command or a write command, the address of the target register 24, and the target data. When the data transceiver module 23 obtains the read command, the data transceiver module 23 finds the target register 24 according to the address of the target register 24, and reads the target data in the target register 24, and sends it to the host 1 in the form of the output data signal MISO through the host receiving slave sending line. When the data transceiver module 23 obtains the write command, the data transceiver module 23 finds the target register 24 according to the address of the target register 24, and writes the target data in the input data signal MOSI into the target register 24 according to the chip selection signal SSN.
[0036] The data transceiver module 23 may include a status register, and the data transceiver module 23 receives a module reset signal sent by the reset module 22. Exemplarily, the module reset signal may include a first reset signal ssn_ne_rstn and a second reset signal sck_pe_rstn. The internal status register is reset when the module reset signal is valid.
[0037] The technical solution of the embodiment of the present invention is to set a clock control module to generate a working clock signal of a serial peripheral interface slave according to a serial clock signal and a chip select signal sent by a host, without setting an internal oscillator inside the serial peripheral interface slave or setting an external clock source outside to generate a working clock signal of the serial peripheral interface slave, effectively reducing economic costs, avoiding the problem of a large amount of power consumption due to a long opening time of an external clock source, and also avoiding data misalignment caused by clock deviation of the master-slave system, ensuring strict synchronization of data. At the same time, the host can freely control the frequency of the serial clock signal, and the serial peripheral interface slave can be adapted according to the frequency, making SPI communication more flexible, and greatly reducing the waiting time for the slave to wake up and establish the working clock, effectively improving the response speed of the slave, realizing the fast response of the slave to the bus, and reducing the time cost. When the host and the slave do not communicate, the generation of the slave working clock signal can be stopped, effectively reducing the standby power consumption, and the slave can adjust the frequency of the working clock according to the data rate and processing requirements, further optimizing the power consumption. The embodiment of the present invention sets a reset module to generate a reset signal according to a serial clock signal, a chip select signal and a system reset signal to reset the status register in the data transceiver module, without setting an external reset signal generation source, thereby further reducing economic costs.
[0038] Optionally, based on the above embodiments, Figure 2 FIG. 1 is a schematic diagram of the structure of another serial peripheral interface communication system provided by an embodiment of the present invention. Figure 2 As shown, the working clock signal includes a sampling clock signal smp_clk and a shift clock signal sft_clk. The clock control module 21 includes a sampling clock generating unit 211 and a shift clock generating unit 212. The first input end of the sampling clock generating unit 211 is connected to the chip select signal SSN, the second input end of the sampling clock generating unit 211 is connected to the serial clock signal SCK, and the output end of the sampling clock generating unit 211 is connected to the first input end of the shift clock generating unit 212 and the first input end of the data transceiver module 23. The sampling clock generating unit 211 is used to generate the sampling clock signal smp_clk according to the chip select signal SSN and the serial clock signal SCK. The second input end of the shift clock generating unit 212 is connected to the chip select signal inverting end of the sampling clock generating unit 211, and the output end of the shift clock generating unit 212 is connected to the second input end of the data transceiver module 23. The shift clock generating unit 212 is used to generate the shift clock signal sft_clk according to the chip select inverting signal generated at the chip select signal inverting end and the sampling clock signal smp_clk.
[0039] Specifically, the working clock signal of the serial peripheral interface slave 2 includes a sampling clock signal smp_clk and a shift clock signal sft_clk. The sampling clock signal smp_clk may be output by the sampling clock generating unit 211 , and the shift clock signal sft_clk may be output by the shift clock generating unit 212 .
[0040] When the host 1 needs to communicate with the serial peripheral interface slave 2, the chip select signal SSN sent by the host 1 to the serial peripheral interface slave 2 is at an effective level, illustratively, the chip select signal SSN is effective when it is at a low level. The sampling clock generating unit 211 outputs the sampling clock signal smp_clk at the output end according to the input chip select signal SSN and the serial clock signal SCK.
[0041] The first input terminal of the shift clock generating unit 212 inputs the sampling clock signal smp_clk. When the chip select signal SSN is low level effective, the second input terminal of the shift clock generating unit 212 is connected to the chip select signal inversion terminal of the sampling clock generating unit 211, and the chip select signal inversion terminal can generate a chip select inversion signal with a level opposite to that of the chip select signal SSN. When the chip select signal SSN is high level effective, the second input terminal of the shift clock generating unit 212 can directly access the chip select signal SSN. The shift clock generating unit 212 outputs the shift clock signal sft_clk at the output terminal according to the chip select inversion signal and the sampling clock signal smp_clk.
[0042] Exemplarily, the data transceiver module 23 samples the input data signal MOSI into the internal shift register at the rising edge of the sampling clock signal smp_clk, and parses the command data frame to obtain read control or write control, the target register address and the target data; performs write control at the rising edge of the chip select signal SSN and writes the target data into the target register 24; or performs read control and reads the target data from the target register address, and sends the target data to the host 1 in the form of the output data signal MISO through the host receive slave transmit line at the rising edge of the shift clock signal sft_clk.
[0043] Optionally, based on the above embodiments, Figure 3 is a schematic diagram of the structure of a clock control module provided by an embodiment of the present invention, such as Figure 3 As shown, the sampling clock generating unit 211 includes: a first inverter U1 and a first AND gate U2. The input end of the first inverter U1 is connected to the chip select signal SSN, the output end of the first inverter U1 is used as the chip select signal inversion end of the sampling clock generating unit 211, and is connected to the first input end of the first AND gate U2, the second input end of the first AND gate U2 is connected to the serial clock signal SCK; the output end of the first AND gate U2 is used as the output end of the sampling clock generating unit 211.
[0044] Specifically, based on the premise that the chip select signal SSN is low level effective, the sampling clock generating unit 211 may include a first inverter U1 and a first AND gate U2. The first inverter U1 may be a NOT gate. The input end of the first inverter U1 is used as the first input end of the sampling clock generating unit 211, and is connected to the chip select signal SSN. The output end of the first inverter U1 is used as the chip select signal inversion end of the sampling clock generating unit 211, and is connected to the first input end of the first AND gate U2. The second input end of the first AND gate U2 is used as the second input end of the sampling clock generating unit 211, and is connected to the serial clock signal SCK. The first AND gate U2 is used as the output end of the sampling clock generating unit 211, and is connected to the first input end of the shift clock generating unit 212 and the first input end of the data transceiver module, and outputs the sampling clock signal smp_clk. The sampling clock signal smp_clk is obtained by performing an AND logic operation on the serial clock signal SCK and the chip select inversion signal after the chip select signal SSN is inverted. When the chip select signal SSN is active at a low level, the sampling clock signal smp_clk is the serial clock signal SCK.
[0045] Optionally, based on the above embodiments, Figure 4 is a schematic diagram of the structure of another clock control module provided by an embodiment of the present invention, such as Figure 4 As shown, the shift clock generating unit 212 includes: a second inverter U3 and a second AND gate U4. The input end of the second inverter U3 is connected to the output end of the sampling clock generating unit 211, the output end of the second inverter U3 is connected to the first input end of the second AND gate U4, the second input end of the second AND gate U4 is connected to the inverting end of the chip selection signal of the sampling clock generating unit 211, and the output end of the second AND gate U4 is connected to the second input end of the data transceiver module.
[0046] Specifically, based on the premise that the chip select signal SSN is low level effective, the shift clock generating unit 212 may include a second inverter U3 and a second AND gate U4, and the second inverter U3 may be a NOT gate. The input end of the second inverter U3 is used as the first input end of the shift clock generating unit 212, and is connected to the sampling clock signal smp_clk. The second inverter U3 inverts the phase of the sampling clock signal smp_clk and inputs it to the first input end of the second AND gate U4. The second input end of the second AND gate U4 is used as the second input end of the shift clock generating unit 212, and is connected to the chip select inverted signal. The second AND gate U4 performs an AND logic operation on the chip select inverted signal and the sampling clock signal smp_clk after the phase is inverted to obtain the shift clock signal sft_clk. When the chip select signal is low level effective, the shift clock signal sft_clk is the serial clock signal SCK after the phase is inverted.
[0047] Optionally, based on the above embodiments, Figure 5 FIG. 1 is a schematic diagram of the structure of another serial peripheral interface communication system provided by an embodiment of the present invention. Figure 5 As shown, the module reset signal includes a first reset signal ssn_ne_rstn and a second reset signal sck_pe_rstn. The reset module 22 includes a first reset signal generating unit 221 and a second reset signal generating unit 222. The first input end of the first reset signal generating unit 221 is connected to the chip select signal SSN, the second input end of the first reset signal generating unit 221 is connected to the system reset signal rst_n, and the output end of the first reset signal generating unit 221 is connected to the third input end of the data transceiver module 23. The first reset signal generating unit 221 is used to generate the first reset signal ssn_ne_rstn according to the chip select signal SSN and the system reset signal rst_n. The first input end of the second reset signal generating unit 222 is connected to the serial clock signal SCK, the second input end of the second reset signal generating unit 222 is connected to the chip select signal SSN, the third input end of the second reset signal generating unit 222 is connected to the system reset signal rst_n, and the output end of the second reset signal generating unit 222 is connected to the fourth input end of the data transceiver module 23. The second reset signal generating unit 222 is used to generate a second reset signal sck_pe_rstn according to the serial clock signal SCK, the chip select signal SSN and the system reset signal rst_n. The data transceiver module 23 is used to reset according to the first reset signal ssn_ne_rstn and the second reset signal sck_pe_rstn.
[0048] Specifically, the reset module 22 may include a first reset signal generating unit 221 and a second reset signal generating unit 222. The first input terminal and the second input terminal of the first reset signal generating unit 221 are respectively connected to the chip select signal SSN and the system reset signal rst_n. The first reset signal generating unit 221 may perform a logic operation on the chip select signal SSN and the system reset signal rst_n, thereby outputting a first reset signal ssn_ne_rstn to the data transceiver module 23. The first input terminal, the second input terminal and the third input terminal of the second reset signal generating unit 222 are respectively connected to the serial clock signal SCK, the chip select signal SSN and the system reset signal rst_n. The second reset signal generating unit 222 may perform a logic operation on the serial clock signal SCK, the chip select signal SSN and the system reset signal rst_n, thereby outputting a second reset signal sck_pe_rstn to the data transceiver module 23. The first reset signal ssn_ne_rstn and the second reset signal sck_pe_rstn are used to reset different state registers in the data transceiver module 23.
[0049] Optionally, based on the above embodiments, Figure 6is a structural diagram of a first reset signal generating unit provided by an embodiment of the present invention, such as Figure 6 As shown, the first reset signal generating unit 221 includes: a chip select signal delay component 2211 and a first reset signal generating component 2212. The input end of the chip select signal delay component 2211 is connected to the chip select signal SSN, and the output end of the chip select signal delay component 2211 is connected to the first input end of the first reset signal generating component 2212; the chip select signal delay component 2211 is used to delay the chip select signal SSN for a first duration and generate a chip select delay pulse signal. The second input end of the first reset signal generating component 2212 is connected to the system reset signal rst_n, and the output end of the first reset signal generating component 2212 is connected to the third input end of the data transceiver module; the first reset signal generating component 2212 is used to generate a first reset signal ssn_ne_rstn according to the chip select delay pulse signal and the system reset signal rst_n, and the pulse width of the first reset signal ssn_ne_rstn is the first duration.
[0050] Specifically, the input end of the chip select signal delay component 2211 is used as the first input end of the first reset signal generating unit 221, and is connected to the chip select signal SSN. After the chip select signal delay component 2211 delays the chip select signal SSN for a first time length, it performs necessary logic operations with the chip select signal SSN to generate a chip select delay pulse signal. Exemplarily, the first time length can be 10ns. The chip select signal delay component 2211 outputs the chip select delay pulse signal to the first input end of the first reset signal generating component 2212, and the second input end of the first reset signal generating component 2212 is used as the second input end of the first reset signal generating unit 221, and is connected to the system reset signal rst_n. The first reset signal generating component 2212 outputs the first reset signal ssn_ne_rstn according to the chip select delay pulse signal and the system reset signal rst_n, and the pulse width of the first reset signal ssn_ne_rstn is the first time length. Exemplarily, the chip select signal SSN is valid at a low level, and the first reset signal ssn_ne_rstn can be a reset signal of the falling edge of the chip select signal, and the low level is valid, that is, the first reset signal ssn_ne_rstn can be a reset signal with a pulse width of a first duration generated at the falling edge of the chip select signal SSN, and the pulse width can be the time the low level is maintained.
[0051] Optionally, based on the above embodiments, Figure 7 is a schematic diagram of the structure of another first reset signal generating unit provided by an embodiment of the present invention, such as Figure 7As shown, the chip selection signal delay component 2211 includes: a third inverter U5, a first delay device D1 and a third AND gate U6. The input end of the third inverter U5 and the input end of the first delay device D1 serve as the input end of the chip selection signal delay component 2211, the output end of the third inverter U5 is connected to the first input end of the third AND gate U6, the output end of the first delay device D1 is connected to the second input end of the third AND gate U6, and the output end of the third AND gate U6 serves as the output end of the chip selection signal delay component 2211. The first reset signal generating component 2212 includes: a fourth inverter U7 and a fourth AND gate U8. The input end of the fourth inverter U7 is connected to the output end of the third AND gate U6, the output end of the fourth inverter U7 is connected to the first input end of the fourth AND gate U8, the second input end of the fourth AND gate U8 is connected to the system reset signal rst_n, and the output end of the fourth AND gate U8 is connected to the third input end of the data transceiver module.
[0052] Specifically, based on the chip select signal SSN being effective at a low level, the chip select signal delay component 2211 includes a third inverter U5, a first delay device D1, and a third AND gate U6. The third inverter U5 inverts the phase of the chip select signal SSN and outputs it to the first input end of the third AND gate U6. The first delay device D1 delays the chip select signal SSN for a first duration and outputs it to the second input end of the third AND gate U6. The third AND gate U6 performs an AND logic operation on the signal after the chip select signal SSN is delayed for the first duration and the inverted signal of the chip select signal SSN, and then outputs a chip select delay pulse signal. The chip select delay pulse signal is a pulse signal with a pulse width of a first duration generated at the falling edge of the chip select signal SSN. When the chip select signal SSN is effective at a low level, the pulse width is the duration of the high level.
[0053] The first reset signal generating component 2212 may include a fourth inverter U7 and a fourth AND gate U8. The fourth inverter U7 inverts the phase of the chip select delay pulse signal and outputs it to the fourth AND gate U8. The fourth AND gate U8 performs an AND logic operation on the signal after the chip select delay pulse signal is inverted and the system reset signal rst_n and then outputs the first reset signal ssn_ne_rstn.
[0054] Optionally, based on the above embodiments, Figure 8 is a structural diagram of a second reset signal generating unit provided by an embodiment of the present invention, such as Figure 8As shown, the second reset signal generating unit 222 includes: a serial clock delay component 2221 and a second reset signal generating component 2222. The input end of the serial clock delay component 2221 is connected to the serial clock signal SCK, and the output end of the serial clock delay component 2221 is connected to the first input end of the second reset signal generating component 2222; the serial clock delay component 2221 is used to delay the serial clock signal SCK by the second time length and generate a serial clock delay pulse signal. The second input end of the second reset signal generating component 2222 is connected to the chip select signal SSN, the third input end of the second reset signal generating component 2222 is connected to the system reset signal rst_n, and the output end of the second reset signal generating component 2222 is connected to the fourth input end of the data transceiver module. The second reset signal generating component 2222 is used to generate a second reset signal sck_pe_rstn according to the serial clock delay pulse signal, the chip select signal SSN and the system reset signal rst_n; the pulse width of the second reset signal sck_pe_rstn is the second time length.
[0055] Specifically, the input end of the serial clock delay component 2221 is used as the first input end of the second reset signal generating unit 222, and is connected to the serial clock signal SCK. After the serial clock delay component 2221 delays the serial clock signal SCK for the second time length, it performs necessary logic operations with the serial clock signal SCK to generate a serial clock delay pulse signal. Exemplarily, the second time length can be 10ns. The serial clock delay component 2221 outputs the serial clock delay pulse signal to the first input end of the second reset signal generating component 2222, and the second input end of the second reset signal generating component 2222 is used as the second input end of the second reset signal generating unit 222, and is connected to the chip select signal SSN. The third input end of the second reset signal generating component 2222 is used as the third input end of the second reset signal generating unit 222, and is connected to the system reset signal rst_n. The second reset signal generating unit 2222 generates a second reset signal sck_pe_rstn according to the serial clock delay pulse signal, the chip select signal SSN and the system reset signal rst_n, and the pulse width of the second reset signal sck_pe_rstn is the second duration. Exemplarily, the second reset signal sck_pe_rstn can be a serial clock rising edge reset signal, and the low level is effective, that is, the second reset signal sck_pe_rstn can be a reset signal with a pulse width of the second duration generated at the rising edge of the serial clock signal SCK, and the pulse width can be the time for the low level to be maintained.
[0056] Optionally, based on the above embodiments, Fig. 9 is a schematic diagram of the structure of another second reset signal generating unit provided by an embodiment of the present invention, such as Fig. 9As shown, the serial clock delay component 2221 includes: a second delay device D2, a fifth inverter U9 and a fifth AND gate U10. The input end of the second delay device D2 and the first input end of the fifth AND gate U10 serve as the input end of the serial clock delay component 2221, the output end of the second delay device D2 is connected to the input end of the fifth inverter U9, the output end of the fifth inverter U9 is connected to the second input end of the fifth AND gate U10, and the output end of the fifth AND gate U10 serves as the output end of the serial clock delay component 2221. The second reset signal generating component 2222 includes: a sixth inverter U11, a first OR gate U12 and a sixth AND gate U13. The input end of the sixth inverter U11 is connected to the output end of the fifth AND gate U10, the output end of the sixth inverter U11 is connected to the first input end of the first OR gate U12, and the second input end of the first OR gate U12 is connected to the chip select signal SSN. The output end of the first OR gate U12 is connected to the first input end of the sixth AND gate U13, the second input end of the sixth AND gate U13 is connected to the system reset signal rst_n, and the output end of the sixth AND gate U13 is connected to the fourth input end of the data transceiver module.
[0057] Specifically, based on the chip select signal SSN being effective at a low level, the serial clock delay component 2221 includes a second delayer D2, a fifth inverter U9, and a fifth AND gate U10. The second delayer D2 is connected to the serial clock signal SCK, and outputs the serial clock signal SCK to the fifth inverter U9 after delaying the serial clock signal SCK for a second time period. The fifth inverter U9 continues to perform phase inversion on the input signal and outputs it to the second input end of the fifth AND gate U10. The first input end of the fifth AND gate U10 is connected to the serial clock signal SCK. The fifth AND gate U10 performs an AND logic operation on the serial clock signal SCK and the signal after the serial clock signal SCK is delayed and phase inverted, and outputs a serial clock delay pulse signal. The serial clock delay pulse signal is a pulse signal with a pulse width of the second time period generated at the rising edge of the serial clock signal SCK, and the pulse width can be a high level duration.
[0058] The second reset signal generating component 2222 may include a sixth inverter U11, a first OR gate U12 and a sixth AND gate U13. The sixth inverter U11 inverts the phase of the serial clock delay pulse signal and outputs it to the first input end of the first OR gate U12. The first OR gate U12 performs an OR logic operation on the chip select signal SSN and the serial clock delay pulse signal after phase inversion and outputs the signal to the sixth AND gate U13. The sixth AND gate U13 performs an AND logic operation on the system reset signal rst_n and the signal output by the first OR gate U12 to output a second reset signal sck_pe_rstn.
[0059] The following is a brief description of the working process of the serial peripheral interface communication system, and the following description is based on the chip select signal SSN being pulled low and effective and the chip select signal SSN being the register operation clock signal:
[0060] Optionally, based on the above embodiments, Fig.10 is a signal timing diagram of a serial peripheral interface communication system provided by an embodiment of the present invention, such as Fig.10 As shown, a timing diagram of a serial clock signal SCK, a chip select signal SSN, a sampling clock signal smp_clk, a shift clock signal sft_clk, a register operation clock signal sfr_clk, a first reset signal ssn_ne_rstn, a second reset signal sck_pe_rstn and a serial clock counter sck_cnt is exemplarily shown.
[0061] The data frame length must be an integer multiple of 16. For example, the number of pulses of the serial clock signal SCK received during the period when the chip select signal SSN is pulled low should be 16*n, where n is an integer greater than or equal to 1. After the chip select signal SSN is pulled high, the serial peripheral interface slave 2 will parse the command according to the most recently received 16-bit data frame.
[0062] Fig.11 1 is a flowchart of a serial peripheral interface slave performing read and write operations provided by an embodiment of the present invention, such as Fig.11 As shown, step 50: serial clock signal input; step 51: serial clock signal pulse counting; the data transceiver module 23 records the number of pulses of the received serial clock signal SCK during the data sampling process at the rising edge of the sampling clock signal smp_clk, and the serial clock counter sck_cnt in the data transceiver module 23 is reset and cleared when the first reset signal ssn_ne_rstn is valid, that is, it is reset and cleared at the falling edge of the chip select signal SSN. Fig.10 As shown, the serial clock counter increases by one on the rising edge of the sampling clock signal smp_clk, is cleared when the serial clock counter counts to 15, and then restarts counting. The purpose of resetting the serial clock counter to zero on the falling edge of the chip select signal SSN is to avoid the serial clock signal pulse number received in the previous frame not being an integer multiple of 16, resulting in the serial clock counter counting error when receiving the next frame of data.
[0063] In the embodiment of the present invention, during the period when the chip select signal SSN is pulled low, if the number of pulses of the received serial clock signal SCK is an integer multiple of 16, step 52 is executed: the data frame state is valid; the data frame state register in the data transceiver module 23 is set to 1, indicating that the data frame is valid, and the register is reset and cleared by the second reset signal sck_pe_rstn when receiving a new data frame. When the value in the data frame state register is 1, the response data is assigned to the output shift register in the data transceiver module 23, so the data frame state register needs to be reset and cleared before the rising edge of the second shift clock signal sft_clk arrives, so that the output shift register shifts and outputs at the rising edge of the shift clock signal sft_clk.
[0064] like Fig.10 As shown, at the rising edge of the sampling clock signal smp_clk, the data transceiver module 23 samples the input data signal MOSI and stores the data in the input shift register in the data transceiver module 23. When the chip select signal SSN is pulled high, that is, at the rising edge of the register operation clock signal, the read command or write command in the input shift register is recorded in the read-write status register. Fig.11 In step 53, if the input shift register is a write command and the data frame is valid, the target data is written into the target register address at the rising edge of the register operation clock signal; Fig.11 In step 54, if the input shift register contains a read command and the data frame is valid, the target register address is read before receiving the next frame of data and the target data is stored in the output shift register. The data in the output shift register is output to the host receive and slave transmit lines at the rising edge of the shift clock signal sft_clk.
[0065] Fig.12 is a data frame command sending and response sequence diagram provided by an embodiment of the present invention, such as Fig.12 As shown, in the embodiment of the present invention, the response data of each data frame sent by the host on the slave receiving line is output on the host receiving slave transmitting line of the next data frame, the response frame of the data frame 1 sent by the host on the slave receiving line is output to the host receiving slave transmitting line when receiving data frame 2, the response frame of the data frame 2 sent by the host on the slave receiving line is output to the host receiving slave transmitting line when receiving data frame 3, and the response frame of the data frame 3 sent by the host on the slave receiving line is output to the host receiving slave transmitting line when receiving data frame 4. In particular, in the embodiment of the present invention, the start frame response sequence is specified to be 0X8000, and if the length of the previous data frame is not an integer multiple of 16, its response frame sequence is also 0X8000, indicating that the previous frame is an invalid frame.
[0066] In an embodiment of the present invention, when the clock polarity and clock phase of the SPI slave 2 are both 0, the idle state of the SPI slave 2 is that the serial clock signal SCK is at a low level, data sampling is performed on the rising edge of the serial clock signal SCK, and data shifting is performed on the falling edge of the serial clock signal SCK. During the period when the chip select signal SSN is valid, the sampling clock signal smp_clk can be set to the serial clock signal SCK, and the shift clock signal sft_clk is a signal after the phase of the serial clock signal SCK is inverted.
[0067] When the clock polarity is 0 and the clock phase is 1, the idle state of SPI slave 2 is that the serial clock signal SCK is at a low level, data sampling is performed on the falling edge of the serial clock signal SCK, and data shifting is performed on the rising edge of the serial clock signal SCK. During the period when the chip select signal SSN is valid, the sampling clock signal smp_clk can be set to the signal after the phase of the serial clock signal SCK is inverted, and the shift clock signal sft_clk is the serial clock signal SCK.
[0068] When the clock polarity is 1 and the clock phase is 0, the idle state of SPI slave 2 is that the serial clock signal SCK is at a high level, data sampling is performed on the rising edge of the serial clock signal SCK, and data shifting is performed on the falling edge of the serial clock signal SCK. During the period when the chip select signal SSN is valid, the sampling clock signal smp_clk can be set to the signal after the phase of the serial clock signal SCK is inverted, and the shift clock signal sft_clk is the serial clock signal SCK.
[0069] When the clock polarity is 1 and the clock phase is 1, the idle state of SPI slave 2 is that the serial clock signal SCK is at a high level, data sampling is performed on the falling edge of the serial clock signal SCK, and data shifting is performed on the rising edge of the serial clock signal SCK. During the period when the chip select signal SSN is valid, the sampling clock signal smp_clk can be set to the serial clock signal SCK, and the shift clock signal sft_clk is the signal after the phase of the serial clock signal SCK is inverted.
[0070] The serial peripheral interface communication system provided by any of the above embodiments of the present invention includes a host, at least one serial peripheral interface slave provided by any of the above embodiments of the present invention, and a state machine, and has the beneficial effects of the serial peripheral interface slave provided by any of the above embodiments of the present invention.
[0071] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0072] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A serial peripheral interface slave, characterized in that: include: Clock control module, reset module and data transceiver module; The clock control module receives the serial clock signal and the chip select signal, and is used to generate a working clock signal according to the serial clock signal and the chip select signal; the working clock signal includes a sampling clock signal and a shift clock signal; The reset module is connected to the serial clock signal, the chip select signal and the system reset signal, and is used to generate a module reset signal according to the serial clock signal, the chip select signal and the system reset signal; The data transceiver module receives the input data signal and the chip select signal, and is connected to the clock control module and the reset module, and is used to communicate with the host according to the working clock signal, the input data signal and the chip select signal; the data transceiver module is also used to reset according to the module reset signal; The module reset signal includes a first reset signal and a second reset signal; the reset module includes a first reset signal generating unit and a second reset signal generating unit; The first input end of the first reset signal generating unit is connected to the chip select signal, the second input end of the first reset signal generating unit is connected to the system reset signal, and the output end of the first reset signal generating unit is connected to the third input end of the data transceiver module; the first reset signal generating unit is used to generate the first reset signal according to the chip select signal and the system reset signal; The first input end of the second reset signal generating unit is connected to the serial clock signal, the second input end of the second reset signal generating unit is connected to the chip select signal, the third input end of the second reset signal generating unit is connected to the system reset signal, and the output end of the second reset signal generating unit is connected to the fourth input end of the data transceiver module; the second reset signal generating unit is used to generate the second reset signal according to the serial clock signal, the chip select signal and the system reset signal; the data transceiver module is used to reset according to the first reset signal and the second reset signal.
2. The serial peripheral interface slave according to claim 1, characterized in that: The clock control module includes a sampling clock generating unit and a shift clock generating unit; The first input end of the sampling clock generating unit is connected to the chip selection signal, the second input end of the sampling clock generating unit is connected to the serial clock signal, and the output end of the sampling clock generating unit is connected to the first input end of the shift clock generating unit and the first input end of the data transceiver module; The sampling clock generating unit is used to generate the sampling clock signal according to the chip selection signal and the serial clock signal; The second input end of the shift clock generating unit is connected to the chip select signal inverting end of the sampling clock generating unit, and the output end of the shift clock generating unit is connected to the second input end of the data transceiver module; the shift clock generating unit is used to generate the shift clock signal according to the chip select inverting signal outputted from the chip select signal inverting end and the sampling clock signal.
3. The serial peripheral interface slave according to claim 2, characterized in that: The sampling clock generating unit comprises: a first inverter and a first AND gate; The input end of the first inverter is connected to the chip select signal, the output end of the first inverter serves as the chip select signal inversion end of the sampling clock generating unit and is connected to the first input end of the first AND gate, the second input end of the first AND gate is connected to the serial clock signal; the output end of the first AND gate serves as the output end of the sampling clock generating unit.
4. The serial peripheral interface slave according to claim 2 or 3, characterized in that: The shift clock generating unit comprises: a second inverter and a second AND gate; The input end of the second inverter is connected to the output end of the sampling clock generating unit, the output end of the second inverter is connected to the first input end of the second AND gate, the second input end of the second AND gate is connected to the inverting end of the chip select signal of the sampling clock generating unit, and the output end of the second AND gate is connected to the second input end of the data transceiver module.
5. The serial peripheral interface slave according to claim 1, characterized in that: The first reset signal generating unit comprises: a chip selection signal delay component and a first reset signal generating component; The input end of the chip select signal delay component is connected to the chip select signal, and the output end of the chip select signal delay component is connected to the first input end of the first reset signal generating component; the chip select signal delay component is used to delay the chip select signal for a first time length and generate a chip select delay pulse signal; The second input end of the first reset signal generating component is connected to the system reset signal, and the output end of the first reset signal generating component is connected to the third input end of the data transceiver module; the first reset signal generating component is used to generate the first reset signal according to the chip select delay pulse signal and the system reset signal, and the pulse width of the first reset signal is the first duration.
6. The serial peripheral interface slave according to claim 5, characterized in that: The chip selection signal delay component includes: a third inverter, a first delay device and a third AND gate; The input end of the third inverter and the input end of the first delay device serve as the input end of the chip selection signal delay component, the output end of the third inverter is connected to the first input end of the third AND gate, the output end of the first delay device is connected to the second input end of the third AND gate, and the output end of the third AND gate serves as the output end of the chip selection signal delay component; The first reset signal generating component includes: a fourth inverter and a fourth AND gate; The input end of the fourth inverter is connected to the output end of the third AND gate, the output end of the fourth inverter is connected to the first input end of the fourth AND gate, the second input end of the fourth AND gate is connected to the system reset signal, and the output end of the fourth AND gate is connected to the third input end of the data transceiver module.
7. The serial peripheral interface slave according to claim 1, characterized in that: The second reset signal generating unit comprises: a serial clock delay component and a second reset signal generating component; The input end of the serial clock delay component is connected to the serial clock signal, and the output end of the serial clock delay component is connected to the first input end of the second reset signal generating component; the serial clock delay component is used to delay the serial clock signal for a second time length and generate a serial clock delay pulse signal; The second input terminal of the second reset signal generating component is connected to the chip select signal, the third input terminal of the second reset signal generating component is connected to the system reset signal, and the output terminal of the second reset signal generating component is connected to the fourth input terminal of the data transceiver module; the second reset signal generating component is used to generate the second reset signal according to the serial clock delay pulse signal, the chip select signal and the system reset signal; the pulse width of the second reset signal is the second duration.
8. The serial peripheral interface slave according to claim 7, characterized in that: The serial clock delay component includes: a second delay device, a fifth inverter and a fifth AND gate; The input end of the second delay device and the first input end of the fifth AND gate serve as the input end of the serial clock delay component, the output end of the second delay device is connected to the input end of the fifth inverter, the output end of the fifth inverter is connected to the second input end of the fifth AND gate, and the output end of the fifth AND gate serves as the output end of the serial clock delay component; The second reset signal generating component includes: a sixth inverter, a first OR gate and a sixth AND gate; The input end of the sixth inverter is connected to the output end of the fifth AND gate, the output end of the sixth inverter is connected to the first input end of the first OR gate, and the second input end of the first OR gate is connected to the chip select signal; the output end of the first OR gate is connected to the first input end of the sixth AND gate, the second input end of the sixth AND gate is connected to the system reset signal, and the output end of the sixth AND gate is connected to the fourth input end of the data transceiver module.
9. A serial peripheral interface communication system, characterized in that: include: A host, at least one serial peripheral interface slave according to any one of claims 1 to 8, and a state machine; The first output terminal of the host is connected to the first input terminal of the serial peripheral interface slave; The second output terminal of the host is connected to the second input terminal of the serial peripheral interface slave; The third output terminal of the host is connected to the third input terminal of the serial peripheral interface slave; The first input end of the host is connected to the first output end of the serial peripheral interface slave; the first output end of the host is used to provide a serial clock signal for the serial peripheral interface slave, the second output end of the host is used to provide a chip select signal for the serial peripheral interface slave, the third output end of the host is used to provide an input data signal for the serial peripheral interface slave, and the first input end of the host is used to communicate with the serial peripheral interface slave; The output end of the state machine is connected to the fourth input end of the serial peripheral interface slave, and is used to provide a system reset signal for the serial peripheral interface slave.
Citation Information
Patent Citations
Low power consumption data acquisition transmission system based on clock chip and implementation method
CN107818676A
Address expansion circuit and I2C communication interface chip
CN108959155A
Serial-to-parallel conversion circuit, driving method thereof and display panel
CN110912549A
Design method of conversion circuit for converting parallel data into serial data
CN111224658A
Circuit structure of slave chip for realizing full duplex communication of serial interface
CN113626355A
