Patent Description:
Serial Peripheral Interface (SPI) is defined for duplex communication between the SPI host and the SPI device. Currently, SPI has been widely used for communication between the processor and the flash memory device, wherein the processor (acting as the SPI master) sends instructions to the flash memory (acting as the SPI device), and the SPI device returns data for some opcodes.

SPI was originally defined as a single bit (<NUM>-bit) SPI, which uses a wire to send all command phases (command, address and data), this mode is referred to as <NUM>-<NUM>-<NUM>. In order to improve performance, the SPI is then extended to <NUM>-bit and <NUM>-bit SPI, which uses <NUM>-bit sending command and uses <NUM>-bit or <NUM>-bit sending address and data (referred to as <NUM>-<NUM>-<NUM> and <NUM>-<NUM>-<NUM> mode). Afterwards, a new bus mode was added, including a <NUM>-bit peripheral interface (Quad Peripheral Interface; QPI) and <NUM> bits peripheral interface (Octal Peripheral Interface; OPI). In QPI, further using <NUM>-bit to send all command phases (referred to as <NUM>-<NUM>-<NUM> mode), and in OPI, further using <NUM> bits to send all command phases (referred to as <NUM>-<NUM>-<NUM> mode). In addition, sometimes it can be used together with Execute-In-Place (XIP) operating mode, in which the SPI host does not send the operating code (opcode), and the SPI device assumes that the operating code does not change according to the previous command. Generally, an SPI host or SPI device that supports QPI or OPI also supports the at least one SPI mode (such as one of <NUM>-<NUM>-<NUM>, <NUM>-<NUM>-<NUM> or <NUM>-<NUM>-<NUM> mode), and usually the SPI mode will be disposed as default SPI operating mode.

In all cases, the SPI host and the SPI device need to use the same operating mode for operation. When the SPI host and SPI device are in different operating modes due to some error (for example, if the host is reset), the SPI device may execute useless commands, and the SPI host may read data from the SPI device receiving error. When the SPI host changes the operating mode but the SPI device does not change the operating mode (or vice versa), it is considered as a lack of synchronization event.

<CIT> relates to a Serial Peripheral Interface (SPI) operating-mode synchronization between an SPI host and an SPI device that communicate over an SPI bus. In the SPI device, one or more values on the SPI bus are predefined as indicative of lack of synchronization of an SPI operating mode between the SPI host and the SPI device and in response to receiving any of the predefined values in the SPI device, initiating re-synchronization of the SPI operating mode. One or more wires of the SPI bus are connected to pull-up or pull-down devices that force the one or more wires to a defined logic state, and the one or more values indicative of the lack of synchronization comprise the one or more values in which the one or more wires are at the defined logic state.

The following disclosure serves a better understanding of the present invention.

SPI communication between an SPI host and an SPI device may be done in a plurality of protocols and operating modes, which vary in the width of the data bus (in the various phases of the instruction), the length of the address and an Execute-In-Place (XIP) mode.

SPI communication mentioned in the present application may support a bus-width operating mode, an address-width operating mode and an Execute-In-Place (XIP) operating mode. The detail is descripted as the followings.

The bus-width operating mode may include:.

The address-width operating mode should be one of (i) <NUM>-bit address, or (ii) <NUM>-bit address.

The XIP operating mode should be either On or Off.

In an embodiment of the present application, a default SPI operating mode may be defined as SPI mode (one of <NUM>-<NUM>-<NUM> mode, <NUM>-<NUM>-<NUM> mode and <NUM>-<NUM>-<NUM> mode), <NUM>-bit address, and XIP off. Both the SPI host and the SPI device typically start at the default SPI operating mode after resetting.

<FIG> is a block diagram that illustrates an SPI communication system <NUM> with Lost-Sync detection and recovery, in accordance with an embodiment of the present invention. An SPI Host <NUM> (e.g., a processor) communicates over an SPI link with an SPI Device <NUM>, the SPI link comprising a Chip-Select (CS) wire <NUM>, a Clock (CK) wire <NUM>, an Input-Output (I/O) <NUM> wire <NUM>, and I/O1 through I/O7 wires <NUM>.

The communication comprises executing SPI instructions, which may include sending an opcode, sending an address, sending and/or receiving data.

According to the embodiment illustrated in <FIG>, I/O0 wire <NUM> is always used, wherein I/O1 through I/O7 wires <NUM> (dashed lines) may be used in some or all phases of the instruction or may never be used.

To enable detection of Lost-Sync events, I/O wires <NUM> are coupled to Vdd (Supply-high voltage) through resistors <NUM>. The resistors are designed so that, when the SPI device (or the SPI host) drives the corresponding wires low, the SPI host or device will prevail, and the wires will be set low; hence, the resistors are "weak-pull-up" devices.

If the SPI host is in SPI mode (one of <NUM>-<NUM>-<NUM> mode, <NUM>-<NUM>-<NUM> mode or <NUM>-<NUM>-<NUM> mode), and the SPI device does not drive the I/O bus, I/O1 through I/O7 wires <NUM> will be driven high during the opcode phase by the pull-up devices. If, according to the protocol, the SPI device does not expect to receive high levels in I/O1 through I/O7, the SPI device may interpret the received high level as detecting a Lost-Sync event when receiving high levels in I/O1 through I/O7, and will take recovery measures (e.g., switch to the default SPI operating mode).

Thus, when the SPI host is unilaterally changed to the SPI mode and the SPI device is still in non-SPI mode (such as QPI or OPI mode) due to some reasons, the pull-up resistors coupled to I/O1 through I/O7 may drive I/O1 through I/O7 to high level in the opcode phase so that the SPI device may detect a Lost-Sync event and recover to the default SPI operating mode.

In an embodiment, if the SPI device <NUM> supports <NUM>-bit rather than <NUM>-bit bus, the SPI communication device <NUM> may merely configure three pull-up devices. In another embodiment, the pull-up devices may be configured in the SPI host <NUM>; in other embodiments, the pull-up devices may be in the SPI device <NUM>.

In alternative embodiments, pull-down devices (e.g., weak pull-down resistors) can be used instead of pull-up devices. Generally put, the pull-up or pull-down devices force the relevant SPI wires to a defined logic state ("<NUM>" in the case of pull-up, "<NUM>" in the case of pull-down). Thus, when using pull-down devices, the values indicative of lack of sync should also be changed to "<NUM>". In yet another alternative embodiment, pull-down devices are used in combination with negative logic, wherein a low voltage level represents logic-high, and a high voltage level represents logic-low.

In an embodiment, multiple SPI devices may be coupled to a single SPI host, and in another embodiment multiple SPI hosts may be connected to one or more SPI devices.

<FIG> is a waveform diagram <NUM> that illustrates a Lost-Sync event detection and recovery, in accordance with an embodiment of the present invention. Please refer to <FIG>. At a time-point <NUM>, the SPI host sets CS as low level, to indicate the start of a new instruction. Both the SPI host and the SPI device are in the QPI mode (e.g., responsively to a past set-mode instruction). The SPI host sends the opcode starting at time-point <NUM>; then, at a timepoint <NUM>, starts sending the address and, at a timepoint <NUM>, sends the data.

The instruction ends at a time-point <NUM> wherein the SPI Host sets CS as high level and stop the clock. Then, at a time-point <NUM>, the SPI host starts an SPI mode instruction, and the SPI device misses the mode transition and remains in QPI mode.

When in SPI mode, the SPI host does not drive I/O wires <NUM> through <NUM> in the opcode phase, but, since the wires are coupled to pull-up devices <NUM> (<FIG>), the I/O wires <NUM> through <NUM> will assume as a high level. The SPI device in the opcode phase will receive "<NUM>" in the I/O wires <NUM> through <NUM>; assuming the highest order two bits of the current opcode are <NUM>, the SPI device will get <NUM> from I/O0 (i.e., I0=<NUM> and I4=<NUM>), and the opcode gotten will be <NUM> (0xEE). The SPI device will recognize this opcode as a lost-sync indication and, at a time-point <NUM>, switch to the default mode, recovering from the Lost-Sync event.

In some embodiments the bus-width operating mode between time-points <NUM> and <NUM> may be Octal, and I/O wires <NUM> through <NUM> may be added. In an embodiment, the SPI device may detect a Lost-Sync event instantaneously and revert to the default mode in the same clock cycle (and, hence, time-points <NUM> and <NUM> merge). At the time, the time difference between time-points <NUM> and <NUM> may be any suitable number of clock cycles.

In embodiments, when the SPI device has detected a Lost-Sync event and reverts to the default mode, but the SPI host may have sent a first bit (or several first bits) of a SPI mode instruction, they will not be in sync time-wise (e.g., the second bit that the SPI host sends may be interpreted by the SPI device as a first bit of an instruction) although the SPI host and the SPI device will be similarly in the SPI mode.

Therefore, to assure time-sync in case of lost-sync, the SPI device may further comprise parallel decoding circuitry.

<FIG> is a block diagram that illustrates an SPI device <NUM>, in accordance with an embodiment of the present invention. The SPI device <NUM> comprises a configurable mode decoder <NUM>, Lost-Sync detection circuit <NUM>, default-mode decoder <NUM>, selector <NUM>, and instruction execution unit <NUM>.

In an embodiment, the configurable mode decoder <NUM> is coupled to I/O1 through I/O7 and configured to be able to decode SPI instructions in a default SPI operating mode (one of <NUM>-<NUM>-<NUM>, <NUM>-<NUM>-<NUM> or <NUM>-<NUM>-<NUM>) and in either QPI mode (<NUM>-<NUM>-<NUM>) or OPI mode (<NUM>-<NUM>-<NUM>). In some embodiments, the configurable mode decoder <NUM> may decode the SPI instructions in both QPI mode and OPI mode.

The Lost-Sync detection circuit <NUM> is coupled to the configurable mode decoder <NUM> and is configured to detect logic-high level on I/O wires when a logic-low level is expected, and to interpret the detection result as a Lost-Sync event.

The default-mode decoder <NUM> is coupled to I/O0 and configured to decode instructions that the SPI host sends. In addition, the default-mode decoder <NUM> is coupled to the Lost-Sync detection circuit <NUM> and is configured to stop outputting the decode result when the Lost-Sync detection circuit <NUM> fails to detect a loss of synchronization event. Assuming that the SPI host and the SPI device are in a non-SPI mode (e.g., OPI mode or QPI mode), when the SPI host unilaterally switches to the SPI mode (e.g., because of Reset), the default-mode detector <NUM> may still decode the instruction correctly, even though the SPI device is still in a non-SPI mode (e.g., OPI mode or QPI mode).

The selector <NUM> is coupled to the configurable mode decoder <NUM>, the Lost-Sync detection circuit <NUM>, the default-mode decoder <NUM>, and the instruction execution unit <NUM>. The selector <NUM> is configured to connect either the configured-mode decoder <NUM> or the default mode decoder <NUM>, to an instruction execution unit <NUM>, responsively to whether the Lost-Sync detection circuit <NUM> detects a Lost-Sync event.

In the example of <FIG>, the configurable mode decoder <NUM> and the default-mode decoder <NUM> are described in different blocks, but the present invention is not limited thereto.

In an embodiment, the default-mode decoder <NUM> is a part of the configured decoder <NUM>.

In particular, when the SPI host drives an instruction Opcode while in SPI mode, the SPI host drives I/O0 wire only, and does not drive the additional I/O wires that are used in higher bus width modes.

Therefore, pull-up devices <NUM> (<FIG>) will set the value of I/O1 through I/O3 or I/O1 through I/O7 to logic '<NUM>' when the SPI Master drives the instruction Opcode on I/O0.

At the time, if the SPI device is still in QPI mode or OPI mode, and decodes the incoming instruction Opcode accordingly, the SPI device will assume all <NUM> (QPI) or <NUM> (OPI) wires carry valid Opcode bits. However, Since I/O1-I/O3 or I/O1-I/O7 at the time are set to '<NUM>' by the pull-up devices, and only I/O0 is driven by the SPI host, the opcodes that the SPI device may receive and decode merely include: 0xFF, 0xFE, 0xEF, 0xEE (the former two opcodes may be received in QPI and OPI mode, the latter two opcodes may be received only in QPI mode). Therefore, in the embodiment, when the opcodes receive 0xFF, 0xFE, 0xEF and 0xEE, the SPI device may interpret Opcodes as Lost-Sync events.

Performing Lost-Sync recovery that the SPI device responsive to detecting a Lost-Sync event, may set the SPI device to the default mode, to properly decode further instructions. In addition, the SPI device decodes by optionally using the parallel default mode decoding to reconstruct and execute the previous command.

When the same instruction Opcode is executed repeatedly, the SPI communication may open a XIP operating mode to save time. When the XIP operating mode is turned on, the SPI host may skip sending the instruction opcode phase and only sending the address and data. When the XIP mode is turned on, the first byte of the instruction is the MS-Byte of the address. In an embodiment, the SPI host, for example, may enter the XIP operation mode by disposing I/O0 to high logic in the first loop after sending the address related to the instruction.

Since most SPI devices use only a small portion of the address space, the MS-bits of the address are expected to be <NUM>. For example, when 32b addressing mode is used by a 256Mbit SPI device (32MByte), the largest possible address is 0x01FFFFFF, with the seven MS-bits at logic <NUM>.

In an embodiment, pull-up devices set I/O1 through I/O3 (or I/O1 through I/O7) to logic <NUM> when the SPI host is in the SPI mode. Hence, if the SPI device is still in XIP mode turned on, it expects to receive an address in OPI mode or QPI mode, the most significant address byte will be 0xFF, 0xFE, 0xEF or 0xEE. In this embodiment, any address that starts with 0xFF, 0xFE, 0xEF or 0xEE may be interpreted as a Lost-Sync event. In an embodiment, it may define that the MS-bit of the received address range must be <NUM>, otherwise it will be interpreted as the Lost-Sync event; this limits the memory size to 8Mbyte in <NUM>-bit address mode and to 2Gbyte in <NUM>-bit address mode.

In an embodiment, the SPI device, responsively to detecting a Lost-Sync event while in XIP mode turned on, may recovery the operating mode to the default mode. In addition, the previous command can be selectively decoded in parallel so as not to lose any instruction.

In some applications, it may not be possible to exclude address ranges that start with an FF, FE, EF or EE byte. In this embodiment, it is able to send a unique Mode-Reset sequence by the SPI host; the SPI device, when receiving the Mode-Reset sequence, unconditionally switches to the default mode without the pull-up devices, and further recovers the synchronization with the SPI host. In an embodiment, the Mode-Reset sequence is defined as a sequence of all-<NUM> in all available I/O wires, for, for example, sixteen consecutive clock cycles. The SPI device decodes this instruction as opcode 0xFF followed by all-<NUM> address and data, regardless of the current interface operating mode.

Furthermore, when XIP Mode is on, the SPI device should be defined the specific address as illegal and interpret the specific address as Mode-Reset sequence. For example, if the addressing mode is <NUM>-bit, the SPI device may define 0xFFFFFF as the specific address; if the addressing mode is <NUM>-bit, the SPI may define 0xFFFFFFFF as the specific address.

<FIG> is a waveform diagram <NUM> that illustrates sending a mode-reset sequence by an SPI host, in accordance with an embodiment of the present invention.

Please refer to <FIG>. The SPI host, at a time-point <NUM>, sets the CS wire as logic low level, to indicate an instruction. Then, during the next <NUM> clock cycles, the SPI host sets all I/O wires that are connected to the SPI device as logic-<NUM>, to indicate a mode-reset sequence. At a time-point <NUM>, the mode-reset ends, and the SPI host set the CS wire as logic high level.

At time-point <NUM> the SPI device may be in any operating mode, including, for example, QPI mode or OPI mode. At a time-point <NUM>, after receiving logic-<NUM> on all I/O wires for sixteen consecutive clock cycles, the SPI device detects the Mode-reset sequence and reverts to the default mode.

The polarities of the signals described hereinabove is an example that is compatible with the present SPI bus definition and applications. The present invention, however, are not limited thereto. For example, in embodiment, it is valid when the CS wire is logic high level. In another embodiment, when the I/O wire is disposed as low voltage, it means that logic-<NUM> carries negative logic (that is - a logic-<NUM> is signaled by a low voltage, whereas a logic-<NUM> is indicated by a high voltage), and pull-down rather than pull-up devices are coupled to the I/O wires.

In addition, embodiments of the present invention support SPI variants wherein the bus width (number of I/O wires) is different than <NUM>,<NUM>,<NUM> or <NUM>. For example, in an embodiment, the disclosed techniques, mutatis mutandis, may be used in an SPI variant having <NUM> I/O wires.

<FIG> is a flowchart <NUM> that illustrates detecting Lost-Sync events by examining the input data, in accordance with an embodiment of the present invention. Please refer to <FIG>. For instance, the SPI device enters operation <NUM> after power-on or reset (for example, power-on reset). In operation <NUM>, the SPI device at a default-mode execution. Specifically, the SPI device decodes and executes the decoded SPI instruction in the default SPI mode (one of <NUM>-<NUM>-<NUM>, <NUM>-<NUM>-<NUM> and <NUM>-<NUM>-<NUM>).

Next, in operation <NUM>, the SPI device checks if the received SPI instruction is a Switch-Mode instruction (e.g., switch to OPI mode), and, if it is not, reenters operation <NUM>, to decode and execute the next SPI instruction in default mode.

Going back to operation <NUM>, if the SPI device checks that the received instruction is a switch-mode instruction (e.g., checking to OPI instruction ), the SPI device enters operation <NUM>, the SPI device is in the default mode in parallel with the operation mode indicated by the SPI instruction in current operation <NUM> (e.g., OPI mode or QPI mode) to decode the SPI instruction. However, the SPI device executes only the decoded SPI instructions, and stores the decoded SPI instructions by the default mode.

Next, in operation <NUM>, the SPI device checks if the received SPI instruction is a switch-to-default-SPI-mode instruction; if so, the SPI device reenters operation <NUM>, to decode further SPI instructions in the default mode.

Going back to operation <NUM>, if the SPI device does not check the switch-to-default-SPI-mode instruction, the SPI device enters operation <NUM>, the SPI device checks whether the mode-reset sequence is received. If yes, the SPI device enter operation <NUM> to execute the last instruction decoded by default mode (that is, the instruction stored after parallel decoding by default mode in operation <NUM>), and return to operation <NUM>. Therefore, the SPI device can reenter operation <NUM> after operation <NUM> to decode other instructions in the default mode without losing the instruction. Going back to operation <NUM>, if the SPI device does not receive the Mode-reset sequence, the SPI device enters operation <NUM>, where the SPI device checks whether the SPI host indicates to open the XIP mode.

In an embodiment, the SPI host may set I/O0=<NUM> at the first clock cycle following the sending of the address to indicate that the XIP mode is turned on. If, in operation <NUM>, the SPI host does not indicate that the XIP mode is turned on, the SPI device will reenter operation <NUM>, to decode the next instruction in OPI mode.

Going back to operation <NUM>, if the SPI host indicates that the XIP mode is turned on, the SPI device will enter operation <NUM>, and the SPI device will decode and execute the received SPI instruction (only contains address and data, and to execute is to use the last sending opcode) in the current mode (QPI or OPI mode), and decode in the default mode and store SPI instruction decoded by default mode in parallel.

Next, in operation <NUM>, the SPI device checks whether the Lost-Sync event is detected. For instance, the SPI device may be defined an address starting with FF or FE as an illegal address and interpret it as a Lost-Sync event. At the time, the SPI device may check if the MS byte of the received address is an FF or an FE. If the SPI device does not detect the Lost-Sync event, the SPI device reenters operation <NUM> and continues decoding in parallel.

Going back to operation <NUM>, if the Lost-Sync event is checked by the SPI device, the SPI device enters operation <NUM>, the SPI device executes the last default-SPI instruction that was decoded (i.e., the instruction that is decoded in the default mode and stored in parallel in operation <NUM>), and go back to operation <NUM>. Therefore, the SPI device may reenter operation <NUM> after operation <NUM> in default mode to decode and execute further SPI instructions in the default mode without losing the instruction.

<FIG> is a state-diagram <NUM> that illustrates the states of an SPI device, in accordance with an embodiment of the present invention. Each state in <FIG> represents an SPI, a QPI or an OPI operating mode:.

We will first describe "normal" transitions between the states, and then describe transitions in case of Lost-Sync, according to embodiments.

Following a Reset signal, the SPI device is in the SPI state <NUM>. Responsively to an XIP-On indication (e.g., a set I/O0 in the first clock following the address) the SPI device transits to the SPI-XIP state <NUM>, and, responsively to an XIP-off indication (e.g., setting a I/O0 in the first clock loop following the address, receiving the illegal address or specific sequence), the SPI device reverts from SPI-XIP state <NUM> back to state <NUM>.

If the SPI device, while in default-SPI state <NUM>, receives a set-mode-QPI or a set-mode-OPI instruction, the SPI device will transit, respectively, to state <NUM> (QPI) or to state <NUM> (OPI); when in state <NUM> or state <NUM>, the SPI device will return to the state <NUM> upon receipt of a set-mode-SPI instruction.

When in either state <NUM> or in state <NUM>, the SPI device may receive an XIP-On indication, and transit to state <NUM> (QPI-XIP) or to state <NUM>(QPI-XIP), respectively. When in either the state <NUM> or the state <NUM>, the SPI device will, responsively to an XIP-off indication, revert, respectively, to state <NUM> or to state <NUM>.

In embodiments, additional inter-state transitions may be provided, to allow recovery from a Lost-Sync event. If the SPI device is in SPI-XIP state and the SPI host is in SPI (non-XIP) state, the SPI device will receive an address with at least the three MS bits set (driven logic high by pull-up resistors <NUM>) and will, responsively, reverts to state <NUM>.

If the SPI device is in QPI state <NUM> while the SPI host is in SPI (not XIP) mode, the SPI device will receive an opcode with bits <NUM>-<NUM>-<NUM> and <NUM>-<NUM>-<NUM> at logic high level (one of opcodes FF, FE, EF, EE - all defined, according to embodiments, as illegal) and, responsively, reverts to state <NUM>.

If the SPI device in the OPI state <NUM> while the SPI host is in SPI (not XIP) mode, the SPI device will receive an opcode with bits <NUM> through <NUM> at logic high level (one of opcodes FF, FE), and responsively revert to state <NUM>.

If sync is lost while the SPI device is in the OPI-XIP state <NUM>, the SPI device will get an address with MS byte equal FF, FE, EF or EE and responsively revert to default state <NUM>. If sync is lost while the SPI device is in the SPI-XIP state <NUM>, the SPI device will get an address starting with FF or FE (for OPI) or an address starting with FF, FE, EF or EE (for QPI), and responsively revert to the default SPI mode <NUM> (this method will not work to recover from lost sync in single SPI-XIP).

Additionally, when detecting the mode-reset sequence (as described above), the SPI device, from any state, will transit to the state <NUM>.

The different sub-units of SPI host <NUM>, SPI device <NUM>, pull-up devices <NUM> and SPI device <NUM> may be implemented using suitable hardware, such as in one or more Application-Specific Integrated Circuits (ASICs) or Field-Programmable Gate Arrays (FPGAs), using software, using hardware, or using a combination of aforementioned hardware and software.

SPI host <NUM> and/or SPI device (<FIG>) and/or SPI device <NUM> (<FIG>) may comprise one or more general-purpose processors, which are programmed in software to carry out the functions described herein. The software may be downloaded to the processor in electronic form, over a network or from a host, for example, or it may, alternatively or additionally, be provided and/or stored on non-transitory tangible media, such as magnetic, optical, or electronic memory.

In summary, in an embodiment of the present invention, the SPI device is configured to detect whether the SPI host unilaterally switches to the SPI mode. In the embodiment, for example, a weak pull-up device (for example, a resistor coupled to positive supply) can be connected to the portion of data wires; when the SPI host changes to SPI mode, the SPI device will receive logic high level on unused wires (for example, I/O1 to I/O7).

In an embodiment, by not using the operation code starting with one or a plurality of disposed logic high bit, and it can be defined as a Lost-Sync event; as a result, if the SPI device in QPI mode or OPI mode receives an opcode that is disposed as MS byte starting with a logic high bit, it is considered to be detecting the loss of synchronization with the SPI host to recovery to default mode. In other embodiment, it can be defined that the address starting with one or more logic high is illegal; as a result, if the SPI device receives an address starting with one or more logic high when it expects to receive a legal address (e.g., when XIP mode is turned on), it is considered to be detecting the loss of synchronization with the SPI host to recovery to default mode. When the SPI device detects the loss of synchronization when the XIP mode is turned on, the SPI device will abort the current XIP operation in the case of not responding to the SPI host, thereby avoiding possible bus contention.

In an embodiment, in order to avoid losing the data of the first instruction of the SPI host sent after the SPI host changes its mode, the SPI device may comprise a parallel decode circuit in the current configured operation mode (such as QPI or OPI) Neutralize and decode SPI communication in parallel in default mode. When the SPI device detecting loses the synchronization event, the SPI device will execute the instruction decoded in the default mode.

In another embodiment, a unique mode-reset sequence can be defined, for example, all I/O wires of the SPI bus can be disposed to logic "<NUM>" in a longer cycle period (for example, <NUM> clock pulses). In this embodiment, this kind of sequence cannot be used as a proper operation transmit, as a result, the SPI device can interpret it as an instruction to reset the operation mode to default mode.

Claim 1:
A method for Serial Peripheral Interface (SPI) operating-mode synchronization between an SPI host (<NUM>) and an SPI device (<NUM>, <NUM>) that communicate over an SPI bus, the method comprising:
predefining, in the SPI device (<NUM>, <NUM>), one or more values on the SPI bus as indicative of an error caused by the SPI host (<NUM>) and the SPI device (<NUM>, <NUM>) operating in different SPI modes; and
in response to receiving any of the predefined values in the SPI device (<NUM>, <NUM>), initiating a re-synchronization process that causes the SPI device to operate in the same SPI operating mode,
wherein the one or more predefined values comprise one or more SPI instruction operating codes or SPI address operating codes in which a predefined group of bits is at a defined logic state,
wherein one or more wires of the SPI bus are connected to pull-up or pull-down devices that force the one or more wires to a defined logic state, and wherein the one or more values indicative of the error comprise the one or more values in which the one or more wires are at the defined logic state, wherein the pull-up or pull-down devices is pull-up or pull-down resistor.