Serial bus interface capable of transferring data in different formats

Abstract: A serial bus interface comprises a shift register (12) for receiving and transmitting a serial data, a first selector (16) coupled to a serial input of the shift register for selectively coupling the input of the shift register to one of at least two serial data lines, and a second selector (26) coupled to a serial output of the shift register for selectively coupling the output of the shift register to one of the serial data lines. Further, a clock generator (14) capable of generating a clock pulse in at least two different formats is coupled to a clock line (32). This clock generator operates to output to the clock line a clock pulse in accordance with a format adopted in one of the serial data lines selected by the selector.

Description: The present invention relates to a serial bus interface capable of transferring data in synchronism with clocks by use of a clock line and a serial data line. More specifically, the present invention relates to such a serial bus interface which can be coupled to a plurality of peripheral devices having different transfer formats and which can execute data transfer to and from any selected one of the peripheral devices in accordance with the selected peripheral device. Description of related art So-called serial bus interfaces can made it possible to transfer data by means of only one clock line and one data line. Therefore, if the serial bus interface is used, data transfer can be effected between microcomputers and various associated peripheral devices through a small number of lines. On the other hand, since the serial bus interface has only one clock line and one data line, microcomputers and/or peripheral devices coupled to the clock lines and the data line have to have the same transfer format. If one of peripheral devices coupled to the clock line and the data line has a data transfer format different from the microcomputer and other peripheral devices coupled to the same clock line and data line, even if the microcomputer could transfer the data in the different format to the above one peripheral device, the other peripheral devices coupled to the same clock line and data line may erroneously receive the data transferred in the different format. The article "On-chip serial interface aids µC system expansion and eases traffic crunch" by Michael Gallup, published in Electronic Design, Hasbrouk Heights, New Jersey, US, vol.32, no.9, may 1984, shows a serial peripheral interface for performing data transfer with a plurality of peripheral units in a predetermined mode, whereby control and status registers initially set by the system operator determine the bit rate and the sequence in which the peripherals are accessed. WO 82/02102 shows an integrated controller circuit for connecting a central processing unit to a plurality of remote devices using two communication channels to transfer either 8-bit words or 9-bit words together with one of two clock rates. Each of the communication channels is provided with a serial send register and a serial receive register as well as a send and receive clock generator, respective clock controllers and counter decoders. Summary of the Invention Accordingly, it is an object of the present invention is to provide a serial bus interface which has overcome the above mentioned drawback. Another object of the present invention is to provide a serial bus interface capable of carrying out data transfer to and from various peripheral devices having different transfer formats. A further object of the present invention is to provide a serial bus interface provided in a microcomputer and capable of carrying out data transfer in various transfer formats. The above and other objects of the present invention are achieved in accordance with the present invention by a serial bus interface according to claim 1. Preferred embodiments are claimed in the dependent Claims. The above and other objects, features and advantages of the present invention will be apparent from the following description of the preferred embodiment of the invention with reference to the accompanying drawings. Brief Description of the Drawings Figure 1 is a conceptional block diagram of one embodiment of the serial bus interface in accordance with the present invention; Figure 2 is a block diagram in a more specific form of the serial bus interface shown in Figure 1; and Figures 3 and 4 respectively illustrate transfer formats realized in the serial bus interface shown in Figure 2. Description of the Preferred Embodiment Referring to Figure 1, there is shown in a conceptional block diagram one embodiment of the serial bus interface in accordance with the present invention, which is incorporated in a microcomputer 10 functioning as a master device in a serial data transfer. The serial bus interface includes a shift register 12 controlled by a clock generator 14 to convert a parallel data into a serial data in synchronism with clocks supplied from the clock generator 14 as well as to receive a serial data in synchronism with the clocks for generating a parallel data. The shift register 12 has a serial data input connected to an output of a first selector 16, which in turn has a pair of inputs connected to first and second serial data lines 18 and 20, respectively. These data lines 18 and 20 are pulled up through resistors 22 and 24 to a voltage Vcc, respectively. The shift register 12 also has a serial data output connected to an input of a second selector 26, which in turn has a pair of outputs connected to respective gates of two source-grounded N-channel field effect transistors 28 and 30. Drains of the transistors 28 and 30 are connected to the first and second data lines 18 and 20, respectively. Namely, the transistors 28 and 30 constitute an open-drain type data output buffer, respectively, so that a wired logic is formed on each of the data lines. Incidentally, the slave ICs 34 and 36 have similar open-drain type data output buffer. The clock generator 14 has a clock output connected to a clock line 32, which is in turn connected to clock inputs of two slave IC devices 34 and 36. One of these slave IC devices 34 is connected at its data input/output to the first data line 18, and the other slave IC device 36 is connected at its data input/output to the second data line 20. Turning to Figure 2, the serial bus interface is shown in a more specific form. The shift register 12 is coupled at its parallel data input/output to a data buffer 38, which is coupled to an internal bus 40 provided in the microcomputer 10. To the internal bus 40 are coupled a central processing unit (CPU) 42, a data line selection flag 44, a transmission/reception (T/R) flag 46, a clock control flag 48, a master/slave (M/S) flag 50, and a clock selector 52 provided in the clock generator 14. The first selector 16 has a pair of three-input AND gates 54 and 56, whose respective first inputs are connected to the T/R flag 46. A second input of the AND gate 54 is connected directly to the selection flag 44, and a second input of the AND gate 56 is connected through an inverter 58 to the selection flag 44. Third inputs of the AND gates 54 and 56 are connected to first and second serial data terminals 18A and 20A connected to the first and second data lines 18 and 20, respectively. Outputs of the AND gates 54 are connected to an OR gate 60, whose output is connected to the serial data input of the shift register 12. The second selector 26 has a pair of three-input AND gates 62 and 64, whose respective first inputs are connected to the serial data output of the shift register 12. A second input of the AND gate 62 is connected directly to the selection flag 44, and a second input of the AND gate 64 is connected through an inverter 66 to the selection flag 44. The AND gates 62 and 64 are connected at their respective third inputs through an inverter 68 to the T/R flag 46, and are coupled at their outputs to the gates of the source-grounded transistors 28 and 30, respectively, whose drains are respectively connected to the first and second serial data terminals 18A and 20A. The clock generator 14 has a clock oscillator 70 outputting various clock pulses to the clock selector 52. The clock selector 52 is set through the internal bus 40 to output a clock pulse of a selected rate to one input or a NAND gate 72. An output of the NAND gate 72 is connected to one input of an AND gate 74, whose other input is connected to the clock control flag 48. An output of the AND gate 74 is connected to an output buffer 76 controlled by the M/S flag 50. The output buffer 76 is constituted of for example a push-pull transistor circuit, and is connected at its output to a serial clock terminal 32A connected to the clock line 32. The output of the buffer 76 is also connected to the shift register 12 and an input of a counter 78 of for example 3 bits. A carry of this counter 78 is supplied as an interrupt request signal to the CPU 42 and to a reset input of a R/S flipflop 80. The Q output of the flipflop 80 is connected to a second input of the NAND gate 72. The counter 78 is cleared by a signal supplied from the internal bus 40, and the flipflop 80 is set by the same signal. Now, operation will be explained on a first case that a 8-bit data is transferred from the microcomputer 10 to the slave IC 34 and on a second case that the microcomputer 10 receives a 9-bit data from the slave IC 36. In the first case, since the microcomputer 10 functions as a master station controlling a serial clock on the clock line 32, the M/S flag 50 is set to "1" by the CPU 42 through the internal bus 40, so that the output buffer 76 can control the level on the clock lines. (If the microcomputer 10 acts as a slave station, the M/S flag 50 is set to "0" so that the output buffer 76 has a high output impedance.) Thereafter, the CPU makes the following settings through the internal bus 40 before transferring date to the slave IC 34. Namely, the T/R flag 46 is set to "0" as shown in Figure 3, so that the AND gates 54 and 56 are put in a closed condition. Therefore, the selector 16 cannot operate. On the other hand, the selection flag 44 is set to "1" as shown in Figure 3, with the result that the AND gate 64 is put in a closed condition. Thus, only the AND gate 62 is put in a condition capable of passing its input to the gate of the transistor 28. In this condition, 8-bit parallel data to be transferred is written into the shift register 12 through the data buffer 38 from the internal bus 40. A transfer rate data is written into the clock selector 52 so that the selector 52 produces a clock signal of a designated pulse rate from the output of the clock oscillator 70. The clock control flag 48 is set to "1" as shown in Figure 3. Further, a signal is supplied to a clear input CL of the counter 78 so as to clear the counter 78, and to the set input S of the flipflop 80 so that the Q output of the flipflop 80 is set to "1". Thus, the clock signal of the designated pulse rate is supplied from the clock oscillator 70 through the clock selector 52, the NAND gate 72 and the AND gate 74 to the output buffer 76, and then further outputted from the output buffer 76 through the serial clock line 32 to the slave ICs 34 and 36, as shown in Figure 3. The clock signal outputted from the output buffer 76 is also supplied to the shift register 12 as the shift clock, so that the shift register 12 performs its shift operation in synchronism with the falling edge of each received shift clock. As mentioned above, since only the AND gate 62 is in an open condition, i.e., in a signal passable condition, the data serially outputted from the shaft register 12 is applied to the gate of the transistor 28, so that the transistor 28 is turned on or off in accordance with the signal inputted to the gate. As mentioned hereinbefore, the data lines 18 and 20 are pulled up to the voltage Vcc through the resistors 22 and 24, respectively, and therefore, a wired logic circuit are formed on each of the data lines. Accordingly, if the transistor 28 is turned off, the data line 18 is pulled up to a high level, and if the transistor 28 is turned on, the data line 18 is pulled down to a low level. In this manner, the serial data is outputted to the data line 18. On the other hand, the slave IC 34 fetches the level on the data line 18 in synchronism with the rising edge of each clock signal supplied through the clock line 32. As mentioned above, the data is serially outputted from the computer 10 (the master station) in synchronism with the falling edge of each clock pulse, and the slave IC 34 fetches the data in synchronism with the rising edge of each clock pulse. As mentioned above, since the counter 78 is of the three bits, when the counter 78 counts eight clock pulses, the counter 78 generates a carry signal as the interrupt signal, as shown in Figure 3. This interrupt signal is supplied to the reset input of the flipflop 80 so that the Q output of the flipflop 80 is brought into "0". As a result, the NAND gate 72 is closed, and so, the output of the clock pulse is stopped. The interrupt signal is also supplied to the CPU 42. In response to this signal, the CPU 42 reads the content of the selection flag 44, and discriminates the destination of the data communication. In this case, since the selection flag 44 is set with "1" indicating the data line 18 through which a serial data is transferred in a 8-bit format, the CPU 42 can start preparation for another data transfer or reception, or can restart a suspended data processing if data communication is not necessary. In the case of receiving the 9-bit data from the slave IC 36, the CPU 42 send through the internal bus 40 various instructions for preparation of data reception. First, the T/R flag 46 is set to "1" as shown in Figure 4 so that the microcomputer is put in a data reception mode. As a result, the AND gates 62 and 64 are closed, so that the transistors 28 and 30 are maintained off. Further, the selection flag 44 is set to "0" as shown in Figure 4, so that the AND gate 54 is put in a closed condition, and only the AND gate 56 is maintained in an open condition, i.e., in a signal passable condition. The clock control flag 48 is set to "1" as shown in Figure 4, and a data reception rate is set in the clock selector 52. The counter 78 is cleared and the flipflop 80 is set, similarly to the data transmission. Thus, a clock pulse of a designated pulse rate is supplied from the clock terminal 32A through the clock line 32 to the slave IC 36. In synchronism with the falling edge of each clock pulse from the microcomputer 10, the slave IC 36 outputs a serial data on the data line 20 one bit by one bit. The serial data outputted on the data line 20 is supplied through the AND gate 56 and the OR gate 60 to the serial data input of the shift register 12. This shift register fetches the input data in the rising edge of each shift clock supplied from the output buffer 76. When eight clock pulses are generated, the counter 78 generates the carry signal, i.e., the interrupt request signal as shown in Figure 4, which is applied to the reset input of the flipflop 80. Namely, the flipflop 80 is rest, and so, the generation of the clock pulse is stopped. Further, the interrupt request signal is also inputted to the CPU 42. In response to this signal, the CPU 42 reads the content of the selection flag 44, and discriminates the destination of the data communication. In this case, since the selection flag 44 is set with "0", the CPU 42 judges that the destination of the data transmission/reception is the slave IC 36 having a 9-bit format. (If the flag 44 is "1", it is judged that the destination of the data transmission/reception is the slave IC 34.) If it is discriminated that the destination is the slave IC 36, the CPU 42 writes "0" into the clock control flag 29 as shown in Figure 4. As a result, the output of the AND gate 74 is brought into a low level, and therefore, the clock line 32 is inverted to the low level. In response to the falling of the level on the clock line 32, the slave IC 36 outputs a ninth data bit to the data line 20. Thereafter, the CPU 42 writes "1" to the clock control flag 48 again as shown in Figure 4, so that the output of the AND gate 74 is returned to the high level. Thus, in response to the rising of the level on the clock line 32, the shift register 12 fetches the ninth data bit from the slave IC 36. Thereafter, the CPU 42 reads a 9-bit data in the shift register 12 through the data buffer 38, and then, execute necessary data processing. In the case of receiving a 8-bit data from the slave IC 34, since the selection flag 44 is set to "1", when the interrupt request signal is generated by the counter 78, the CPU judges from the content of the selection flag 44 that the destination of the data communication is the slave IC 34. In this case, the CPU 42 will not write "0" and "1" to the clock control flag 48. In the case of transferring a 9-bit data to the slave IC 36, since the selection flag 44 is set to "0", when the interrupt request signal is generated by the counter 78, the CPU judges from the content of the selection flag 44 that the destination of the data communication is the slave IC 36. In this case, the CPU 42 will sequentially write "0" and "1" to the clock control flag 48, so that a ninth clock pulse is generated from the output buffer 76. Accordingly, a ninth data bit is outputted from the shift register 12 to the data line 20. The invention has thus been shown and described with reference to the specific embodiment. However, it should be noted that the invention is in no way limited to the details of the illustrated structures but changes and modifications may be made within the scope of the appended claims. For example, if "0" and "1" are written to the clock control flag 48 two times, respectively, it can control a slave IC having a 10-bit serial data transfer format. In addition, two or more slave ICs can be coupled to the clock line 32 and each of the data lines 18 and 20.

Claims: A serial bus interface comprising: a first serial data terminal (18A) coupled to a first peripheral unit (34) through a first serial data line (18); a second serial data terminal (20A) coupled to a second peripheral unit (36) through a second serial data line (20); a shift register (12); a serial clock terminal (32A) coupled in common to said first and second peripheral units through a serial clock line (32), a clock generator (14) generating and supplying a clock pulse to said serial clock terminal and said shift register, characterised in that it further comprises : a central processing unit (42) for setting said shift register with data to be transmitted and/or for receiving, data received from a peripheral unit, from said shift register; a selector (16, 26) for selecting one of said first and second data terminals to couple said shift register to a selected one of said first and second data terminals; said shift register receiving or transmitting data from and to said first peripheral unit by a first number of bits in synchronism with said clock pulse when said selector selects said first serial data terminal and from and to said second peripheral unit by a second number of bits in synchronism with said clock pulse when said selector selects said second serial data terminal, said second number being larger than said first number, in that said clock generator includes a clock generating means (70, 52) for generating a clock pulse, a first gate means ((72) receiving said clock generated by said clock generating means (70, 52), for selectively passing the received clock pulse, a buffer means (76) receiving the clock pulse from said first gate means, for supplying the received clock pulse to said shift register and said serial clock terminal (32A), and means (78,80) for controlling said first gate means so as to close said first gate means when said first number of the clocks have been supplied from said buffer means so that passage of the clocks through said first gate means (72) is inhibited, and so as to supplying a control signal to said central processing unit; in that said serial bus interface further includes a clock control flag (48) and means (74) coupled to said clock control flag (48) and said buffer means (76) and responding to a change of the content of said clock control flag (48) so as to cause an input level of said buffer means so that an additional clock pulse appears on an output of said buffer means; and in that said central processing unit responds to said control signal and to the fact that said selector selects said second serial data terminal, to cause said clock control flag (48) to change its content by an additional number of times required for said shift register to receive or transmit said second number of bits from or to said second peripheral unit. A serial bus interface as claimed in Claim 1, wherein said central processing unit is coupled to an internal bus (40), and further including a format selection flag (44) coupled to said internal bus and set by said central processing unit, and a transmission/reception flag (46) coupled to said internal bus and set by said central processing unit, said selector being set in accordance with the contents of said format selection flag (44) and said transmission/reception flag (46). A serial bus interface as claimed in Claim 2 wherein said clock generating means includes a clock oscillator (70) for generating a clock signal, and a clock selector (52) receiving said clock signal and controlled by said central processing unit so as to generate said clock pulse at a pulse rate designated by said central processing unit, wherein said first gate means includes a NAND gate (72) having a first input receiving said clock from said clock selector, wherein said means (74) includes an AND gate having its one input connected to an output of said NAND gate and its other input connected to said clock control flag (48), an output of said AND gate being connected to said buffer means (76), so that said clock pulse continues to be supplied to said serial clock terminal when said clock control flag (48) is set to "1", and wherein said control means includes a counter (78) connected to receive said clock pulse appearing on said serial clock terminal, for generating an interrupt request signal when said first number of the clocks have been supplied from said buffer means to said serial clock terminal, and a flipflop (80) having a set input receiving a set signal from said central processing unit and a reset input connected to receive said interrupt request signal from said counter, an output of said flipflop being connected to a second input of said NAND gate, whereby said first number of clocks are supplied to said serial clock terminal by setting said flipflop and setting "1" to said clock control flag. A serial bus interface as claimed in Claim 3 wherein said central processing unit discriminates the content of said format selection flag when said interrupt request signal is generated, and then, when said format selection flag indicates data transfer of said first number of bits, said central processing unit maintains the content of said clock control flag as it is, and when said format selection flag indicates data transfer of said second number of bits, said central processing unit sequentially writes "0" and "1" to said clock control flag so that an additional clock signal is generated from said AND gate.

Inventors: IWAMOTO SHINICHI C O NEC CORPO, IWAMOTO, SHINICHI C/O NEC CORPORATION
Applicants: NIPPON ELECTRIC CO, NEC CORPORATION
Application year: 1987
Main classification: G06F13
IPC codes: G06F13