Serial communication protocol
10990559 · 2021-04-27
Assignee
Inventors
- Shaoxuan WANG (Beijing, CN)
- Yuchuan Shi (Beijing, CN)
- Ze Han (Beijing, CN)
- Lingxin Kong (Beijing, CN)
- Nailong Wang (Beijing, CN)
Cpc classification
International classification
Abstract
A serial communication protocol for daisy-chained slave devices does away with the requirement for an entire byte of dummy clocks to be cycled between a slave's input and output, instead requiring a shorter set of dummy clock cycles which improves efficiency of a serial communication system. According to a specification of a serial communications protocol, data is exchanged between master and slave devices in communication frames. Each communication frame has a command portion and a data portion, and each respective portion may comprise packages of one or more bytes.
Claims
1. A serial communication apparatus, comprising: a master device having a master input and a master output; and a plurality of slave devices, each comprising a slave input and a slave output, said plurality being arranged in a daisy chain configuration, wherein a first slave device is arranged to receive data from the master output at its slave input, and one or more successive slave devices are arranged to receive data from a slave output of a preceding slave device, wherein the master device is arranged to send a communication frame that comprises a sub-byte syllable which selectively triggers transmission of data from a slave input to a slave output, the communication frame including a device address byte defining a slave device address, and said sub-byte syllable being provided as an initial portion of said address byte; and the triggered transmission of data from slave input to slave output commences before the remainder of the device address byte is received by the slave input.
2. The serial communication apparatus of claim 1, wherein said sub-byte syllable comprises one bit.
3. The serial communication apparatus of claim 2, wherein the one bit is held at a first logic value to indicate the beginning of a communication frame.
4. The serial communication apparatus of claim 1, wherein a final slave device adjusts a delay to ensure that the input to the master device is byte-aligned.
5. The serial communication apparatus of claim 4, wherein the adjustment of the delay is set by a special command embedded in the communication frame, preferably in the address byte.
6. The serial communication apparatus of claim 4, wherein the adjustment of the delay is set by a register in the slave device, which has a value that can be set to inform one slave to be byte-aligned.
7. The serial communication apparatus of claim 1, configured such that each slave device stores its identity to determine its position in the daisy chain of slave devices, and during transmission of a communication frame data, is passed from a slave input to a slave output in the same clock cycle.
8. The serial communication apparatus of claim 7, configured such that: during the transmission of an initial communication frame, each slave device is configured to determine its position in the daisy chain based on a delay between the slave input and slave output for that slave; and thereafter during transmission of subsequent communication frames, data is passed by the slaves from their slave inputs to their slave outputs in the same clock cycle.
9. The serial communication apparatus of claim 1, comprising a serial peripheral interface.
10. A serial communication apparatus, comprising: a master device having a master input and a master output; and a plurality of slave devices, each comprising a slave input and a slave output, said plurality being arranged in a daisy chain configuration wherein a first slave device is arranged to receive data from the master output at its slave input and one or more successive slave devices are arranged to receive data from a slave output of a preceding slave device, wherein the serial communication apparatus is configured such that: during the transmission of an initial communication frame each slave device is configured to determine its position in the daisy chain based on a delay between the slave input and slave output for that slave; and thereafter during transmission of subsequent communication frames, data is passed by the slaves from their slave inputs to their slave outputs in the same clock cycle.
11. The serial communication apparatus of claim 10 wherein the delay between the slave input and slave output is k bytes, where k is the position of the slave in the daisy chain.
12. The serial communication apparatus of claim 10, wherein the delay between the slave input and slave output is k sub-byte syllables, where k is the position of the slave device in the daisy chain.
13. A method of communicating data between devices in a serial communication apparatus, said serial communication apparatus comprising a master device having a master input and a master output, a plurality of slave devices, each comprising a slave input and a slave output, said plurality being arranged in a daisy chain configuration wherein a first slave device is arranged to receive data from the master output at its slave input and one or more successive slave devices are arranged to receive data from a slave output of a preceding slave device, wherein, according to the method, the master device sends a communication frame that comprises a sub-byte syllable the communication frame including a device address byte defining a slave device address, and said sub-byte syllable being provided as an initial portion of said address byte; a slave device receives the communication frame at its slave input; and the sub-byte syllable selectively triggers transmission of data from a slave input to a slave output, wherein the triggered transmission of data from slave input to slave output commences before the remainder of the device address byte is received by the slave input.
14. The method of claim 13, wherein said sub-byte syllable comprises one bit.
15. The method of claim 14, wherein the one bit is held at a first logic value to indicate the beginning of a communication frame.
16. The method of claim 13, wherein a final slave device adjusts a delay to ensure that the input to the master device is byte-aligned.
17. The method of claim 16, wherein the adjustment of the delay is set by a special command embedded in the communication frame, preferably in the address byte.
18. The method of claim 16, wherein the adjustment of the delay is set by a register in the slave device, which has a value that can be set to inform one slave to be byte-aligned.
19. The method of claim 13, wherein each slave device stores its identity to determine its position in the daisy chain of slave devices, and during transmission of a communication frame, data is passed from a slave input to a slave output in the same clock cycle.
20. The method of claim 19, wherein: during the transmission of an initial communication frame each slave device determines its position in the daisy chain based on a delay between the slave input and slave output for that slave; and thereafter during transmission of subsequent communication frames, data is passed by the slaves from their slave inputs to their slave outputs in the same clock cycle.
21. The method of claim 13, being part of a serial peripheral interface protocol.
22. A method of communicating data between devices in a serial communication apparatus, said serial communication apparatus comprising a master device having a master input and a master output, a plurality of slave devices, each comprising a slave input and a slave output, said plurality being arranged in a daisy chain configuration wherein a first slave device is arranged to receive data from the master output at its slave input, and one or more successive slave devices are arranged to receive data from a slave output of a preceding slave device, wherein, according to the method, during the transmission of an initial communication frame each slave device determines its position in the chain based on a delay between the slave input and slave output for that slave; and thereafter during transmission of subsequent communication frames, data is passed by the slaves from their slave inputs to their slave outputs in the same clock cycle.
23. The method of claim 22, wherein the delay between the slave input and slave output is k bytes, where k is the position of the slave in the daisy chain.
24. The method of claim 22, wherein the delay between the slave input and slave output is k sub-byte syllables, where k is the position of the slave device in the daisy chain.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) The present disclosure will now be described, by way of example only, with reference to the accompanying drawings.
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
(11)
(12)
DETAILED DESCRIPTION
(13) The present disclosure provides an improved SPI daisy chain protocol as compared with existing protocols.
(14) An existing protocol's operation is illustrated with respect to
(15) The slave select signal CSB 110 is shared between all slaves 302. When it is driven low the slaves are enabled and ready to read and write data. There is a delay of one byte between the slave input signal (MOSI, 306) and the slave output signal (MISO, 308), which appears as a byte's worth of dummy clock cycles at the initial data output by the slave output signal (MISO, 308). Each slave's device address is enumerated by counting the number of empty bytes which are received at the slave input signal (MOSI, 306) after the slave select signal is enabled (or as an equivalent by the number of empty bytes which are output by the slave output signal (MISO, 308)). The slave acts on the data if its enumerated address matches that specified by an address field forming part of a communication frame, as described below.
(16) Once a slave select signal is enabled to commence communication of data between the master and the slaves, the time taken for a command to propagate from the master to any specific slave device of the daisy chained devices is delayed by a number of clock cycles being m*k, where m is the number of bytes in a bit and k is the kth position of the slave device on the chain. The final slave in the chain requires a delay of m*N clock cycles before it receives a command, and for a large chain this delay can cause significant inefficiency.
(17) According to a specification of a serial communications protocol of the disclosure, data is exchanged between master and slave devices in communication frames. Each communication frame has a command portion and a data portion, and each respective portion may comprise packages of one or more bytes.
(18) A byte is a unit of information that comprises a plurality of bits (which can have a value of one or zero). The most common byte size is eight bits, but it will be appreciated that any number of bits can be provided as a byte and that the present disclosure is not limited to any particular byte size.
(19) The command portion of a communication frame includes information about the size of the communication frame, including the number of data bytes, which are included.
(20) The command portion includes a device address, an optional quantity field, and a register address. The data portion comprises one or more data bytes.
(21) The device address comprises one byte and includes as its most significant bit a value, B, meaning broadcast, which is set to B=1 to tell the system that the message is to be broadcast to all devices, or set to B=0 to tell the system to send a normal message to one single device.
(22) The next most significant bit of the device address is a value, S, indicating whether the communication frame is for a data transmission of only one byte (5=1) or for a block of data (S=0). The remaining six bits of the device address byte, DevAddr[5:0], specify the slave address.
(23) As mentioned above, the device address of each slave 302 is automatically set by the position of the slave in the chain. The first device has a device address DevAddr=0x01, the second device in the daisy chain has a device address DevAddr=0x02, and so on.
(24) A first reserved device address, here 0x00, is reserved to indicate that the same data should be written to the same register of all devices (the broadcast bit, B, is set to 1) A second reserved device address, here 0x3F, is used to indicate that different data should be written to the same register of all devices (the broadcast bit, B, is set to 1).
(25) The remaining values, here 0x01 through 0x3E, are used as device addresses for slave devices 1 through 62.
(26) The command portion includes an optional quantity field, which is used only if a block of data is being transmitted (detected by the setting of S=0 in the device address byte as described above). In that case, the quantity field specifies the number of data bytes in the communication frame. It has values from 0x00 to 0xFF.
(27) The command portion includes a register address, defining the register address of the slave device upon which a read or a write operation is to be performed. The most significant bit is labeled RW, meaning read/write, and is set to RW=0 to indicate a write operation to the register address or set to RW=1 to indicate a read operation from the register address.
(28) Following that, the remaining bits of the register address byte, RegAddr[6:0], define the address, and have values of 0x00 through 0x7F.
(29) The communication frame then comprises one or more data bytes, which provide the data payload and have values of 0x00 through 0xFF.
(30)
(31) At time 402, the slave select line 110 falls to start the device address enumeration and is held low until time 404 when the master 300 pulls the signal high to end the transfer of data.
(32) The slave input 306 receives a communication frame from the master comprising a device address byte DA7:DA0, a register address byte RA7:RA0 and a data payload D7:D0.
(33) The communication frame is passed to the slave output 308 after a delay of one byte.
(34) Each successive slave in the daisy chain therefore must wait for a further delay of one byte before it receives the data, which is intended for it. Therefore, if there are N slave devices in one daisy chain, this method requires there to be a delay of m*N dummy clock cycles before the entire chain can be populated, where m is the number of bits in a byte. An additional N−1 bytes of 0x00 must be cycled through.
(35)
(36) This protocol is byte aligned and easy to implement with one microprocessor as a master and many other devices as slave devices. However, with increasing numbers of slave devices an increasing amount of information of each device, this byte aligned protocol meets some difficulties when it comes to large data transmissions and the delay involved in propagating data to all the slaves can decrease efficiency to an unacceptable level.
(37) The present disclosure provides a new serial communication protocol, which provides improvements with respect to the protocol mentioned above as well as to the general field. It will be described herein with specific reference to SPI but it will be appreciated that the concepts described herein may have a wider application.
(38) The serial communication according to the disclosure improves transmission efficiency by discarding the requirement to have a delay of one byte between the slave input and a slave output. The delay between slave input and slave output can be chosen to be a sub-byte syllable (such as a bit or a nibble for example); or the delay can be eliminated altogether (meaning that during the transmission of a communication frame data is passed from a slave input to a slave output in the same clock cycle) if the slave devices are stored. The slave devices may be stored in suitable memories in the slaves during an initial enumeration step, which may involve either a byte-delay or a sub-byte syllable delay between slave input and output. The reduction of the delay between slave input and slave output according to either of these aspects alone or in combination can dramatically decrease the amount of time taken for a command to propagate from a master through a daisy chain of slave devices, which improves system efficiency.
(39) An optional feature is to ensure byte alignment from the last slave that loops back to the master microprocessor. This could be provided in cases where the microprocessor cannot handle non-byte-aligned instructions, although if it can, then this feature could be omitted.
(40) According to one aspect of the disclosure, the delay between slave input and output is set to a sub-byte syllable. A “sub-byte syllable” refers generally to one or more bits, which together provide a component of a communication frame. The number of bits is less than the number of bits, which form a byte (so, in the example of an eight-bit byte, a sub-packet syllable may comprise any of one to seven bits). In a preferred embodiment, the sub-byte syllable comprises one bit but it may also comprise two bits or other numbers of bits.
(41) The operation of a serial communication protocol according to specific embodiments of this aspect is shown with respect to
(42) Instead of needing m*N dummy clocks (for m bits per byte over N slave devices), according to the new protocol of this aspect, only N dummy clocks are needed.
(43) The protocol might be implemented with a system having a similar set up to that illustrated in
(44) Generally speaking, a microcontroller 600 according to the present disclosure comprises a microprocessor 602 and memory 604. The microcontroller 600 interfaces with other components via an input 606 and an output 608. The output 608 may in a preferred embodiment include the clock 104 and slave select signal 110 and the MOSI output 306, while the input 606 may include the MISO input 308. It will be appreciated that a microcontroller according to the present disclosure may be provided with multiple additional outputs and/or inputs as will be apparent to one skilled in the art.
(45) According to the disclosure, a new serial communication protocol can be enabled by the recording of instructions in memory 604 to be executed by the microprocessor 602, thus forming a new microcontroller 600 that provides the capabilities of the disclosure which improve upon the existing microcontroller 300 as known in the prior art.
(46) As before (that is, as described with reference to
(47) A first reserved device address, here 0x00, is reserved to indicate that the same data should be written to the same register of all devices.
(48) A second reserved device address, here 0x3F, is used to indicate that different data should be written to the same register of all devices.
(49) A third reserved device address, here 0x3E, is used to indicate the total number of slave devices in the daisy chain.
(50) The remaining values, here 0x01 through 0x3D, are used as device addresses for slave devices 1 through 61.
(51) When the slave select signal is held low (at zero), all slaves will be activated.
(52) The transmission of addressing and data via the MISO and MOSI lines is organized in packages of bytes, each message can be built with one or more of the following types of data, a device address, a number of data, a register address and the payload data.
(53) In a preferred embodiment, the data types may be defined as follows:
(54) Device Address: Addresses a specific slave device and defines protocol information.
(55) TABLE-US-00001 Bit Meaning Value B Frame begin flag Always be high, used as a “frame begin” indicator S Single byte S = 0 . . . Block data read or write S = 1 . . . Single data transmission (only one byte) DevAddr[5:0] Device Address 0x00 Write same data to same register of all devices 0x3F Write different data to same register of all devices 0x3E indicate the total device numbers in this daisy chain 0x01 to 0x3D. Device addresses for device 1 to 61
(56) Quantity Field: Defines the number of data bytes in the data frame if S=0, or the slave device numbers with command 3E.
(57) TABLE-US-00002 Bit Meaning Value NrOfdata[7:0] Number of data bytes 0x00 to 0xFF in frame Or number of device in this daisy chain connection with Device Address = 0x3E
(58) Register Address: Defines slave device register address to be read or written.
(59) TABLE-US-00003 Bit Meaning Value RW Read/Write RW = 0 write to reg address RW = 1 read from reg address RegAddr[6:0] Select register 0x00 to 0x7F address
(60) Data: contains the data payload.
(61) TABLE-US-00004 Bit Meaning Value data [7:0] Data 0x00 to 0xFF
(62) In the above example, a reserved address (eg 0x3E), is used to indicate the total number of slave devices in the daisy chain. It is possible to use various different special commands or defined slave registers to inform one slave that it needs to be byte-aligned, that is, to provide properly synchronized signals from its slave output to the master input. The slave can introduce an appropriate delay to ensure that this happens.
(63) A non-limiting example of a slave register implementation is to define one control register “daisy_end_enable” in slave device (register address is 0x00): a value of 0x00 means it is not a final device, while 0x01 means it is the final device. It can be set to 0x00 as default. If the final device is the third device on the chain, the device address=0x03, register address=0x00, data=0x01, and the third device will know it is the final device on the chain, and there is no need for a special command, such as “Device ID=0x3E”.
(64) An example of a write operation using this protocol is shown in
(65) Similarly,
(66) Therefore, it can be seen that the transmission delay is reduced to only one clock cycle from m clock cycles (where there are m clock cycles in one byte, in this case m=8).
(67) As an option, if the slave device is identified as the last device in the daisy chain (which device address is equal to the device number indicated by 0x3E command), the delay clocks can automatically adjust from one clock to a different number of clocks, up to the bit-length of a byte, so that the zeros before the frame begin flag (DA7) of the slave output of the last slave will be always be equal to m*k, to help align the data for the microprocessor, in case it can only deal with byte information. This is illustrated in
(68) According to another aspect of the disclosure, a delay between slave input and slave output in a daisy chain can be eliminated altogether, meaning that during transmission of a communication frame, data is passed from a slave input to a slave output in the same clock cycle. This is possible by storing the slave device addresses at the slave devices. The devices can be hard-coded in the devices, being stored at a suitable non-volatile memory; or they may be enumerated in an initial step, which uses either a byte-delay protocol as illustrated in
(69) One non-limiting example of this concept will be discussed here:
(70) 1. Every slave device may be provided with one special register (register address 0xFF) named Device_ID[7:0].
(71) TABLE-US-00005 Bit Meaning Value Dev_addr_en Device ID enabled 0: Device ID has not been informed, add delay from MOSI to MISO 1: Device ID has been informed, bypass MOSI to MISO Bit[6] reserved reserved DevAddr[5:0] Device Address Device address calculated from number zeros or zero-bytes from special command or normal operations
2. At the beginning, Dev_addr_en is default as zero, so the MOSI to MISO is delayed for every slave address.
3. After the first data frame is transferred or with a special command, every device has an individual device ID, by calculating the zero numbers or zero-byte numbers, and setting Dev_addr_en to be high, which means the device ID of each device has been informed. (For a special command, 0x3D can be defined for device ID calculation and Dev_addr_en set to high, and 0x3C for Device ID, and Dev_addr_en both cleared to zero). Note the special command is not necessary.
4. After Dev_addr_en has been set to high, all the slave devices will directly bypass MOSI to MISO, and no extra dummy clocks are needed.
5. One example for read is after Dev_addr_en has been high, and each device has an individual device ID.
(72) The operation of this non-limiting example is shown in
(73)
(74) Various improvements and modifications can be made to the above without departing from the scope of the disclosure. For example, while the specific embodiments relate to SPI, it will be appreciated that the disclosure may be applied to other protocols.