Microcomputer including serial data communication unit

Abstract: A microcomputer comprises a CPU executing a string of instructions for a program in synchronism with a clock signal and a serial data communication unit including a serial data terminal and a serial clock terminal which are to be coupled to a peripheral device, the CPU supplying a transfer start command to the serial data communication unit when it executes a serial data communication instruction, the serial data communication unit including a serial a serial clock control circuit responding to the transfer start command and starting to supply the serial clock terminal with a serial clock signal having the same frequency as the clock signal in synchronism with the beginning of a certain machine cycle of CPU, a shift register, and a data transfer control circuit responding to the transfer start command and operating in a first mode to cause the shift register to output data stored therein to the serial data terminal one bit by one bit in synchronism with the serial clock signal and in a second mode to cause the shift register to capture data appearing at the serial data terminal one bit by one bit in synchronism with the serial clock signal.

Description: BACKGROUND OF THE INVENTION The present invention relates to a microcomputer and, more particularly, to a single chip microcomputer including a serial data communication unit. As well known in the art, serial data transfer is widely employed as one of data communication ways between a microcomputer and a peripheral device such as a memory. A microcomputer including a serial data communication unit is, for example, described in "Single Chip 8-Bit Microcontroller - User Manual", 1986, Philips, Eindhoven, NL, or in "Component Data Catolog", January 1982, Intel Corporation, Santa Clara, Ca, USA. The microcomputer thus includes a serial data communication unit as an I/O (Input/Output) unit. While CPU (Central Processing Unit) in the microcomputer manages or controls the serial data communication unit, the actual data transfer is carried out between the serial data communication unit and the peripheral device. Therefore, CPU treats the serial data communication unit as an asynchronous I/O unit. In other words, CPU responds to a request from the serial data communication unit and then sets therein data to be transferred to the peripheral device or reads out therefrom data transferred from the peripheral device. Since CPU continues to execute instructions for a program, in order to respond to the request it must suspend the program execution and then perform the above operation as an interrupt routine. The program execution efficiency and/or speed is thereby deteriorated. SUMMARY OF THE INVENTION Therefore, an object of the present invention is to provide a microcomputer including an improved serial data communication unit. Another object of the present invention is to provide a microcomputer including a serial data communication unit which performs serial data transfer for a peripheral device in synchronism with machine cycles of CPU. Still another object of the present invention is to provide a microcomputer including a serial data communication unit which performs serial data transfer between the microcomputer and a peripheral device without requesting an interrupt routine of the microcomputer. The present invention provides a microcomputer according to claim 1. The microcomputer comprises a CPU executing a string of instructions for a program in synchronism with a clock signal and a serial data communication unit including a serial data terminal and a serial clock terminal which are to be coupled to a peripheral device, the CPU supplying a transfer start command to the serial data communication unit when it executes a serial data communication instruction, the serial data communication unit including a serial clock control circuit responding to the transfer start command and starting to supply the serial clock terminal with a serial clock signal having the same frequency as the clock signal in synchronism with the beginning of a certain machine cycle of CPU, a shift register, and a data transfer control circuit responding to the transfer start command and operating in a first mode to cause the shift register to output data stored therein to the serial data terminal one bit by one bit in synchronism with the serial clock signal and in a second mode to cause the shift register to capture data appearing at the serial data terminal one bit by one bit in synchronism with the serial clock signal. BRIEF DESCRIPTION OF THE DRAWINGS The above and other objects, advantages and features of the present invention will be more apparent from the following description taken in conjunction with the accompanying drawings, in which: Fig. 1 is a block diagram representative of a microcomputer system employing a microcomputer according to an embodiment of the present invention; Fig. 2 is a internal circuit diagram representative of a serial data communication unit in the microcomputer shown in Fig. 1; Fig. 3 is a circuit diagram representative of E 2 PROM (electrically erasable programmable read only memory) shown in Fig. 1; Fig. 4 is a timing chart representative of an operation of the microcomputer shown in Fig. 1; Fig. 5 is a timing chart representative of another operation of the microcomputer shown in Fig. 1; and Fig. 6 is a timing chart representative of still another operation of the microcomputer shown in Fig. 1. DETAILED DESCRIPTION OF THE INVENTION Referring to Fig. 1, a microcomputer 1 according to an embodiment of the present invention is formed as a single semiconductor chip and includes CPU 11, a program memory 12, a data memory 13 and a master serial data communication unit 15 which are interconnected with one another through an internal bus 16 including address, data and control buses. Further included in the microcomputer 1 is a clock generator 14 generating and supplying a clock signal CK to CPU 11 and the unit 15. CPU 11 executes a string of instructions for a program stored in the program memory 12 to perform required operations on data stored in the data memory 13. CPU 11 further supplies the unit 15 with data to be transferred to E 2 PROM 2 as'a peripheral device from the data memory 13 or an internal register therein (not shown) or reads out data from E 2 PROM 2 from the unit 15 to the data memory 13 or the internal register. The master serial data communication unit 15 includes a serial data terminal 17 and a serial clock which are respectively coupled through a serial data (SD) line 3 and a serial clock (SC) line 4 to E 2 PROM 2. E 2 PROM 2 includes an E 2 PROM unit 21 and a slave serial data communication unit 23. This unit 23 includes a serial data terminal 24 and a serial clock terminal 25 coupled to the SD line 3 and SC line 4, respectively. Turning to Fig. 2, the master serial data communication unit 15 includes a data buffer 151, a shift register 152 of a master-slave type, a command decoder 157, a clock control circuit 153, a transfer sequence control circuit 154, a data input/output control circuit 155 and a start bit generator 156. The shift register 152 of 10-bit construction. The data buffer 151 is inserted between a data bus 16-1 in the internal bus 16 and the shift register 152. Since the data bus 16-1 is of 8-bit width, the buffer 151 couples the bus 16-1 to 0th bit (LSB) D 0 to 7th bit D 7 of the register 152. The clock control circuit 153 includes AND gates 1531 and 1534, an S-R type flip-flop (called hereinafter "S-R FF") 1532, an OR gate 1536, a D-type flip-flop (called hereinafter "D-FF") 1533 and a tristate output buffer 1535 which are connected as shown. The transfer sequence control circuit 154 includes D-FFs 1541 and 1547, S-R FE 1543, a falling edge detector 1542, an AND gate 1544, a counter 1545 and a decoder 1546. This decoder 1546 decodes the count value of the counter 1545 and produces signals CD1, CD2, CD3 and CD4 when the count value is "2", "4", "12" and "16", respectively. The data input/output control circuit 155 includes AND gates 1551 and 1554, D-FFs 1555 and 1557, S-R FF 1556, a tristate output buffer 1552 and a tristate input buffer 1553. The start bit generator 156 includes an AND gate 1561, tristate output buffers 1562 and 1566, an OR gate 1564, an 1/2 frequency divider 1563 and an inverter 1565. The above circuit elements are connected mutually as shown in the drawing (Fig. 2). Referring to Fig. 3, E 2 PROM unit 21 of E 2 PROM 2 as a peripheral device includes a read/erase/write controller 211, an address latch circuit 212, an address decoder 213, an E 2 PROM cell array 214, a read/erase/write circuit 215, a data latch circuit 216 and two AND circuits 217 and 218. The slave serial data communication unit 23 of E 2 PROM 2 includes a shift register 231 of a master-slave type, a command decoder 232, a data input/ output control circuit 233, a clock control circuit 234, a transfer sequence controller 235 and a start bit detector 236. The shift register 231 is of 10-bit construction, the 0th bit (LSB) D 0 to 7th bit D 7 of which are coupled in common to the latch circuits 212 and 216. The data input/output control circuit 233 includes a tristate input buffer 2331, a tristate output buffer 2332, an inverter 2333, two D-FFs 2334 and 2336 and an S-R FF 2335. The clock control circuit 234 includes an AND gate 2341 and an S-R FF 2342. The transfer sequence control circuit 235 includes an AND gate 2359, a counter 2352, a decoder 2353, an S-R FF 2355 and two D-FF 2354 and 2356. The decoder 2353 decodes the count value of the counter 2352 and produces signals SCD1, SCD2 and SCD3 when the count value is "2", "10" and "14", respectively. The start bit detector 236 includes two AND gates 2361 and 2362. The above circuit elements are connected naturally as shown in the drawing. In Figs. 2 and 3, since each of the shift registers 152 and 231 is of a master-slave type, and it shifts and outputs data therein one bit by one bit in synchronism with the falling edge of a shift clock signal supplied thereto and captures and shifts data supplied thereto one bit by one bit in synchronism with the raising edge of the shift clock signal. Each of the counters 1545 and 2352 is of a raising count type and thus advances a count value thereof in synchronism with the raising edge of a clock signal supplied thereto. Next, an operation will be described with reference to Figs. 1 to 3 and further to Figs. 4 to 6 illustrating timing charts. As shown in Fig. 4, CPU 11 executes each instruction in four machine cycles M0 to M3 including an instruction fetch operation, a decoding operation, an execution operation and an operand write operation. Each of the machine cycles M0 to M3 corresponds to a time period of four clock pulses of the clock signal CK. Since E 2 PROM 2 is employed as a peripheral device in the present embodiment, the master serial data communication unit 15 requires to perform three operations. The first operation is to supply an address to E 2 PPOM 2. The second operation is to supply data to be written into an accessed address of E 2 PROM 2. The third operation is to receive data from an accessed address of E 2 PROM 2. Each of these three operations will be described below. In the first operation, CPU 11 executes at first a data load instruction to load data as an access address from the data memory 13 or the internal register therein to the data buffer 151. More specifically, as shown in Fig. 4, as a result of fetching and decoding this instruction in the first and second machine cycles M0 and M1, CPU reads the address data from the memory 13 or the internal register and outputs it onto the data bus 16-1 in the third machine cycle M2. CPU 11 then generates a data write enable (DWE) signal in the fourth machine cycle M3. The address data on the data bus 16-1 is thus loaded into the buffer 151. Thereafter, CPU 11 executes an address transfer instruction to transfer the address to E 2 PROM 2. As shown in Fig. 5, in the third machine cycle M2 of this instruction execution cycle, CPU 11 produces a DS signal with supplying an address transfer command consisting of C0 and C1. In response to the DS signal, the address data stored in the buffer 151 is loaded to the shift register 152 at the bit positions D0 to D7 and the command data C0 and C1 are loaded into the bit positions D8 and D9 of the register 152. The command data C0 and C1 are also loaded into the command decoder 157. Since the command data at this time represents an address transfer, a decoded signal DR is at a low level. The DS signal is further supplied to D-FF 1541. By the operation of FFs 1541 and 1543 and the circuit 1542, a TS signal is changed to an active high level at the beginning of the fourth machine cycle M3. The AND gate 1544 is thereby made open to supply the clock signal CK to the counter 1545. On the other hand, in the start bit generator 156, since the TS signal changes to the high level and an STE signal from SR FF 1532 is at the high level, the tristate buffers 1562 and 1566 are activated to drive the terminals 17 and 18. By the operation of the frequency divider 1563, inverter 1565 and OR gate 1564, the serial data terminal 17, i.e. SD line 3, in driven to the high level during one clock period, and the serial clock terminal 18, i.e. SC line 4, is driven to the high level during one and half clock period, as shown in Fig. 5. The combination of those logic levels indicates a start bit. When the rising edge of the clock signal CK arrives at the counter 1545, i.e. when the count value of the counter 1545 advances to "2", the decoder 1546 produces the CD1 signal to set S-R FF 1532. The STE signal is thereby changed to the low level to bring the tristate buffers 1562 and 1566 into a high impedance state. The set state of FF 1532 opens the AND gate 1531 to supply the clock signal CK to the shift register as a shift clock signal. The set state of FF 1532 further activates the tristate buffer 1552 through the AND gate 1551 since the Q output of FF 1556 is at the high level at this time. Thus, the address data stored in the shift register 152 starts to be transferred one bit by one bit in synchronism with each falling edge of the clock signal. The set state of the FF 1532 further opens the AND gate 1534 and activates the tristate buffer 1535 after delay of a half clock period by FF 1533. The serial clock having the same rate as the clock signal is thus transferred to the terminal 18. On the other hand, in E 2 PROM 2, the start bit detector 236 detects the start bit to set FF 2355 and reset the counter 2352. The AND gate 2362 is thereby made close. The set state of FF 2355 is captured into FF 2356 in synchronism with the falling edge of the level on the SC line 4, so that the AND gates 2341 and 2351 are made open. At this time, the tristate buffer 1535 (Fig. 2) is in a high impedance state, and hence the level of the SC line 4 is at the low level. Since the tristate input buffer 2331 is in an activated state, the address data shift-outputted from the shift register 152 is transferred via the SD line to the shift register. The serial clock transferred via the SC line 4 is supplied to the shift register 231 and further to the counter. Therefore, the shift register 231 fetches the data appearing at the terminal 24 in synchronism with the rising edge of the shift clock. When the count value of the counter 2352 reaches "2", the decoder 2353 produces the SCD1 signal. In response thereto, the contents of the first and second bits D0 and D1 of the shift register 231, i.e. the command codes C0 and C1 representative of the address transfer, are fetched in the command decoder 23 which in turn produces an active ADD signals and inactive WRQ and RRQ signals. Since the RRQ signal is at the inactive low level, the state of the input/output control circuit 233 is not changed. On the other hand, after the completion of the address transfer instruction, CPU 11 starts to execute another execution. During this instruction execution, the data transfer between the units 15 and 23 continues to be performed, as shown in Fig. 6. Thus, all the data stored in the shift register 152 in the unit 15 are transferred serially to the shift register 231 in the unit 23. Note that the data transfer is completed in synchronism with the end of the second machine cycle M1, i.e. with the beginning of the third machine cycle M2. That is, the start and completion of the serial data transfer synchronize with the machine cycles. Therefore, the serial communication unit 15 is not required to issue an interrupt request to CPU 11 to inform the completion of the data transfer. Turning back to Fig. 2, when the shift register 152 shifts out the final data D0, i.e. when the counter 1545 reaches the count value of "12", the decoder 1546 produces the CD3 signal. D-FF 1557 thereby produces the high level Q output in synchronism with the beginning of the machine cycle M2 to reset S-R FE 1532. The AND gate 1531 is thereby closed to prevent supply of the shift clock to the shift register 152. Since S-R FF 1558 is also set, the start bit generator 156 is held at the deactivated state. On the other hand, the Q output CLE of S-R FE 1558 is supplied via OR gate 1536 to FF 1533, and therefore, the serial clock continues to appear at the terminal 18 (SC line 4). Referring again to Fig. 3, when the counter 2352 reaches the count value "10", the decoder 2353 produces the SCD2 signal. In response thereto, S-R FF 2342 is set to close AND gate 2341. The shift clock is thereby prevented from being supplied to the shift register 231. Since the command decoder 232 supplies the active ADD signal to AND gate 217, the contents of bits D0 to D7 of the register 231 (i.e., address data) are latched into the latch circuit 212 in response to the SCD2 signal. The active ADD signal is further supplied to the read/erase/write controller 211. The serial clock derived from AND gate 2351 is further supplied to the controller 211 as a timing signal. The controller thereby produces a set of sequence control signals 2111 to initiate a data read operation for reading data from an address of cell array 214 accessed by the content of the address latch circuit 212. The data thus read out is loaded into the shift register 231 by SDLE signal from the controller 211. That is, the data stored in the accessed address is transferred to the register 231 before receiving a data read request from CPU 11. When the counter 2352 reaches the count value "14", D-FF 2354 produces reset (ERR) signal to bring the unit 23 into an initial state. Also in the unit 15, when the counter 1545 reaches the count value "16", FF 1547 produces a reset (SRR) signal to bring the unit 15 into an initial state. In the second operation, i.e. in the data transfer operation on data to be written, of the unit 15, the same operation as the first operation is performed to transfer a write command and data to be written to E 2 PROM 2. Since the command decoder 232 in E 2 PROM 2 decodes the write command, it produces the active WRQ signal. The data to be written is thereby latched into the data latch circuit. The controller 211 generates a set of sequence control signals 2111 to initiate a data erase and write operation. The data which has been stored in the accessed data is first erased and then the data in the latch circuit 216 is written into the accessed address. In the third operation, when CPU 11 executes a data read instruction, it generates DS signal with supplying read command data C0, C1. The command decoder 157 generates the high level DR signal. The command data C0, C1 are thereafter supplied via the SD line 3 to E 2 PROM 2. When the counter 1545 reaches the count value "4" to indicate that the transfer of read command is completed, the decoder 1546 produces the CD2 signal. In response thereto, SR-FF 1556 is set through AND gate 1554 and D-FF 1555. The AND gate 1551 is thereby closed to bring the tristate output buffer 1552 into a high impedance state. The set state of FF 1556 further activates the input buffer 1553. That is, the output of the shift register 152 is disconnected from the terminal 17 and the input thereof is in turn connected to the terminal 17. In E 2 PROM 2 (Fig. 3), on the other hand, the data to be transferred to the microcomputer 1 has already stored in the shift register 231, as mentioned hereinbefore. The shift register 231 shift rightward the read-out data by two bits by receiving two-bit read command. The read command is fetched and decoded by the command decoder 232 in response to SCDl signal from the decoder 2353. The active RRQ signal is thereby generated to set SR-FF 2335 through D-FF 2334. Accordingly, the output buffer 2332 is activated, whereas the input buffer 2331 is deactivated. That is, the shift register 231 drives the SD line 3 in response to data read out of the E 2 PROM cell array 214. Thus, the data is transferred serially from E 2 PROM 2 to the microcomputer 1. CPU 11 execute a buffer read instruction to read data from the register 152 via the buffer 151 with a data read-enable (DRE) signal. As described above, all of the address transfer, write data transfer and read data transfer operations are performed in accordance with the timing chart shown in Fig. 6 and in synchronism with the machine cycles of CPU 11. Accordingly, CPU 11 is free from controlling the serial data communication unit 15 in an interrupt routine.

Claims: A microcomputer comprising a CPU (11) for executing a string of instructions for a program, said CPU (11) executing each of said instructions in a plurality of machine cycles, each of said machine cycles consisting of a plurality of clocks of a clock signal (CK) , and a serial data communication unit (15) including a serial data terminal (17) and a serial clock terminal (18) to be coupled to a peripheral device, said CPU (11) supplying a transfer command to said serial data communication unit (15) by executing a certain instruction, said serial data communication unit (15) further including means responsive to said transfer command (154) for supplying said serial clock terminal (18) with a serial clock signal, a shift register (152), and means responsive to said transfer command (155) for operating in a first mode to cause said shift register (152) to output data stored therein to said serial data terminal (17) one bit by one bit in synchronism with said serial clock signal and in a second mode to cause said shift register (152) to capture data appearing at said serial data terminal (17) one bit by one bit in synchronism with said serial clock signal, at a rate of one bit per period of said serial clock signal, said microcomputer being characterized in that said serial clock signal has the same frequency as said clock signal (CK) and the number of bits of the data outputted or captured by said shift register (152) per one serial data transfer is smaller than the number of said machine cycles per one instruction multiplied by the number of clocks per one machine cycle. The microcomputer as claimed in claim 1, wherein the number of said plurality of machine cycles is four and said shift register (152) completes outputting or capturing the data within a period of time that is shorter than a period of time corresponding to three machine cycles. The microcomputer as claimed in claim 2, wherein the number of clocks is four.

Inventors: NISHIZAWA KAZUYUKI, NISHIZAWA, KAZUYUKI, Nishizawa, Kazuyuki, c/o NEC Corporation
Applicants: NIPPON ELECTRIC CO, NEC CORPORATION
Application year: 1991
Main classification: G06F13
IPC codes: G06F13, H04L7, G06F15