Abstract:
A serial bus interface includes a shift register for receiving and transmitting serial data, a first selector coupled to a serial input of the shift register selectively coupling the serial input of the shift register to either of two serial data lines, and a second selector coupled to a serial output of the shift register selectively coupling the serial output of the shift register to one of the two serial data lines. A clock generator, capable of generating a clock pulse in two different formats, is coupled to a clock line. The clock generator operates to output to the clock line a clock pulse in accordance with a format utilized by one of the serial data lines.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     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. 
     2. Description of Related Art 
     Serial bus interfaces can make it possible to transfer data by means of only one clock line and one data line. Therefore, if a 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 line and the data line have to have the same transfer format. If one of the 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. 
     SUMMARY OF THE INVENTION 
     Accordingly, it is an object of the present invention 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 comprising a shift register receiving and transmitting serial data, a first selector coupled to a serial input of the shift register selectively coupling the input of the shift register to one of at least two serial data lines, a second selector coupled to a serial output of the shift register selectively coupling the output of the shift register to one of the serial data lines, and a clock generator coupled to a clock line and capable of generating a clock pulse in at least two different formats, the clock generator operating to output to the clock line a clock pulse in accordance with a format adopted in one of the serial data lines selected by a selector. 
     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 
     FIG. 1 is a block diagram of one embodiment of a serial bus interface in accordance with the present invention; 
     FIG. 2 is a block diagram of a more specific form of the serial bus interface shown in FIG. 1; and 
     FIGS. 3 and 4 respectively illustrate transfer formats realized in the serial bus interface shown in FIG. 2. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     Referring to FIG. 1, there is shown in a block diagram one embodiment of a 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 parallel data into serial data in synchronism with clock signals supplied from the clock generator 14 as well as to receive serial data in synchronism with clock signals for generating 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 resisters 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 wired logic is formed on each of the data lines. Slave ICs 34 and 36 have a 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 FIG. 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 of 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 using a first example in which 8-bit data is transferred from the microcomputer 10 to the slave IC 34 and using a second example in which the microcomputer 10 receives 9-bit data from the slave IC 36. 
     In the first example, 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 &#34;1&#34; 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 &#34;0&#34; 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 data to the slave IC 34. 
     Namely, the T/R flag 46 is set to &#34;0&#34; as shown in FIG. 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 &#34;1&#34; as shown in FIG. 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 a transistor. 
     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 &#34;1&#34; as shown in FIG. 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 &#34;1&#34;. 
     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, is then further outputted from the output buffer 76 through the serial clock line 32 to the slave ICs 34 and 36, as shown in FIG. 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 shift 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 is 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 has three bits, when the counter 78 counts eight clock pulses, the counter 78 generates a carry signal as the interrupt signal, as shown in FIG. 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 &#34;0&#34;. As a result, the NAND gate 72 is closed, and, 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 &#34;1&#34; indicating the data line 18 through which serial data is transferred in an 8-bit format, the CPU 42 can start preparation for another data transfer or reception, or can restart 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 sends through the internal bus 40 various instructions for preparation of data reception. First, the T/R flag 46 is set to &#34;1&#34; as shown in FIG. 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 &#34;0&#34; as shown in FIG. 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 &#34;1&#34; as shown in FIG. 4, and a data reception rate is set to the clock selector 52. The counter 78 is cleared and the flipflop 80 is set, similarly to 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 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 on 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 FIG. 4, which is applied to the reset input of the flipflop 80. Namely, the flipflop 80 is reset, and 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 &#34;0&#34;, 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 was &#34;1&#34;, it would be 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 &#34;0&#34; into the clock control flag 29 as shown in FIG. 4. As a result, the output of the AND gate 74 is brought to 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 &#34;1&#34; to the clock control flag 48 again as shown in FIG. 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 the 9-bit data in the shift register 12 through the data buffer 38, and then, executes necessary data processing. 
     When receiving 8-bit data from the slave IC 34, since the selection flag 44 is set to &#34;1&#34;, 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 &#34;0&#34; and &#34;1&#34; to the clock control flag 48. 
     In the case of transferring 9-bit data to the slave IC 36, since the selection flag 44 is set to &#34;0&#34;, 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 &#34;0&#34; and &#34;1&#34; 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 a 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 &#34;0&#34; and &#34;1&#34; are written into the clock control flag 48 two times the system 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.