Flash memory incorporating microcomputer having on-board writing function

Abstract: In a microcomputer comprising internal buses (AB, DB) , a serial communication interface (2), a flash memory (4) , a RAM (5), a ROM (6) for storing a writing program, an input/output port (1b), a CPU (7), and a mode control unit (3) for setting various operation modes and test modes in the microcomputer, a switching circuit (8) is connected between the ROM and the internal buses and between the input/output port and the internal buses. The mode control unit operates the switching circuit in an emulation test mode so that the ROM is deactivated and the input/output port is activated. Then, the CPU reads a program from the serial communication interface and writes the program into the flash memory in accordance with a writing program from the input/output port.

Description: BACKGROUND OF THE INVENTION Field of the Invention The present invention relates to a flash memory incorporating microcomputer, and more particularly, to the testing of the microcomputer. Description of the Related Art Microcomputers have been broadly incorporated into cameras, audio-visual apparatus, automobiles and the like. Generally, a control program for operating a microcomputer is stored in a read-only memory (ROM). However, since the control program needs to be changed as occasion demands, the mask ROM has been replaced by an erasable and programmable ROM (EPROM), an electrically-erasable programmable ROM (EEPROM), or a flash EEPROM which is called a flash memory. A prior art flash memory incorporating microcomputer includes input/output ports, a serial communication interface, a mode control unit for setting various operation modes, a flash EEROM for storing a control program, a random access memory (RAM) for storing temporary data, a read-only memory (ROM) for storing a writing program for writing the control program into the flash EEPROM, a central processing unit (CPU) and internal buses for connecting these elements to each other (see JP-A-5-266219). This will be explained later in detail. In the prior art microcomputer, although the CPU is tested in a CPU testing mode and the flash EEPROM is tested in a flash EEPROM testing mode, the flash EEPROM is not tested by the CPU. Therefore, even if the CPU testing mode and the flash EEPROM test mode both succeed, it is impossible to guarantee the operation of the flash EEPROM by the CPU. Also, the ROM is active only for an on-board writing operation mode; in other words, the ROM is inactive for the other operation modes. Therefore, when the ROM is incorporated into one chip of the microcomputer, the chip area thereof is increased, thus reducing the manufacturing yield. Further, since the serial communication interface is fixed to one of the types of communication systems, an upper system is limited. Further, in order to write the control program into the flash EEPROM, since the control program is temporarily stored in the RAM or a buffer of the CPU, the time required for a writing operation of the control program is long. Still further, when the frequency of a clock signal is changed by an upper system or the type of the serial communication interface, the time period of a writing operation and the time period of a flash erasing operation are also changed. SUMMARY OF THE INVENTION It is an object of the present invention to guarantee the operation of a flash memory by a CPU in a microcomputer. Another object is to reduce the chip area of a flash memory incorporating microcomputer. A further object is to match a flash memory incorporating microcomputer with various kinds of upper systems. A still further object is to increase the operation speed of an on-board writing operation mode of a flash memory incorporating microcomputer. A further object is to make the writing time period and the flash erasing time period of a flash memory almost constant even when the frequency of a clock signal is changed by upper systems or the like. According to the present invention as defined in independent claims 1 and 9, in a microcomputer including internal buses, a serial communication interface, a flash memory, a RAM, a ROM for storing a writing program, an input/output port, a CPU, and a mode control unit a switching circuit is connected between the ROM and the internal buses and between the input/output port and the internal buses. The mode control unit operates the switching circuit in an emulation test mode so that the ROM is deactivated and the input/output port is activated. Then, the CPU reads the program from the serial communication interface and writes the program into the flash memory in accordance with a writing program from the input/output port. Thus, the operation of the flash memory by the CPU can be guaranteed. Also, in the present invention as defined in independent claim 11, a writing program for writing a program into the flash memory is incorporated into the RAM. As a result, the ROM for storing the writing program is unnecessary, so that the chip area of the microcomputer can be reduced. Further, in the present invention as defined in independent claim 17, the serial communication interface includes a plurality of kinds of serial communication interface units and a selector for selecting one of the serial communication interface units. Thus, the microcomputer can respond to various kinds of upper systems. Still further, in the present invention as defined in independent claim 22, in an on-board writing operation, the read speed of a program is detected by a data reception time detector. As a result, when the read speed is high, the CPU temporarily stores the program in the RAM or a buffer of the CPU before writing the program into the flash memory. On the other hand, when the read speed is low, the CPU directly writes the program into the flash memory. Further, in the flash memory according to the present invention, a value of a register for defining a writing operation time period or a flash erasing operation time period is variable. BRIEF DESCRIPTION OF THE DRAWINGS The present invention will be more clearly understood from the description as set forth below, as compared with the prior art, with reference to the accompanying drawings, wherein: Fig. 1 is a block circuit diagram illustrating a prior art flash memory incorporating microcomputer; Figs. 2A, 2B, 2C and 2D are block circuit diagrams for showing the operations of the microcomputer of Fig. 1; Fig. 3 is a detailed circuit diagram of the flash EEPROM of Fig. 1; Fig. 4 is a detailed circuit diagram of the control circuit of Fig. 3; Fig. 5 is a block circuit diagram illustrating a first embodiment of the flash memory incorporating microcomputer according to the present invention; Fig. 6 is a block circuit diagram for showing the operation of the microcomputer of Fig. 5; Fig. 7 is a block circuit diagram illustrating a second embodiment of the flash memory incorporating microcomputer according to the present invention; Fig. 8 is a block circuit diagram for showing the operation of the microcomputer of Fig. 7; Fig. 9 is a block circuit diagram illustrating a third embodiment of the flash memory incorporating microcomputer according to the present invention; Fig. 10 is a block circuit diagram illustrating a fourth embodiment of the flash memory incorporating microcomputer according to the present invention; Fig. 11A is a circuit diagram illustrating a fifth embodiment as defined in dependent claims 5, 13, 18 and 23 of the flash memory incorporating microcomputer according to the present invention; and Figs. 11B, 11C and 11D are circuit diagrams of modifications of the circuit of Fig. 11A. DESCRIPTION OF THE PREFERRED EMBODIMENT Before the description of the preferred embodiments, a prior art flash memory incorporating microcomputer will be explained with reference to Figs. 1 2A through 2D, 3 and 4 (see: JP-A-5-266219). In Fig. 1, provided between internal buses such as an address bus AB, a data bus DB and a control bus (not shown) and external circuits (not shown) are input/output ports 1a and 1b and a serial communication interface 2 for receiving an address signal, a data signal and a control signal and transmitting them. A mode control unit 3 receives various mode signals from the data bus DB to set various operation modes in each section of the microcomputer of Fig. 1. A flash EEPROM 4 is connected to the address bus AB, the data bus DB and the control bus. That is, in a write mode, a control program is written from the data bus DB into the flash EEPROM 4 whose address is designated by the address signal at the address bus AB. Also, in a read mode, the control program is read to the data bus DB from the flash EEPROM 4 whose address is designated by the address signal at the address bus AB. A RAM 5 is connected to the address bus AB, the data bus DB and the control bus. That is, in a write mode, data is written from the data bus DB into the RAM 5 whose address is designated by the address signal at the address bus AB. Also, in a read mode, data is read to the data bus DB from the RAM 5 whose address is designated by the address signal at the address bus AB. A ROM 6 stores a writing program for writing the control program into the flash EEPROM 4. A CPU 7 controls the input/output ports 1a and 1b, the serial communication interface 2, the flash EEPROM 4, the RAM 5 and the ROM 6 in accordance with operation modes set by the mode control unit 3. The operation of the microcomputer of Fig. 1 is explained next with reference to Figs. 2A, 2B, 2C and 2D, in which only the operated blocks are extracted from Fig. 1. A usual operation is illustrated in Fig. 2A. In this case, the mode control unit 3 recognizes a usual operation mode by the data signal at the data bus DB supplied from the input/output port 1a (not shown in Fig. 2A, but shown in Fig. 1) or the like. As a result, the mode control unit 3 connects the serial communication interface 2, the flash EEPROM 4, the RAM 5 and the CPU 7 to the address bus AB, the data bus DB and the control bus. Note that the input/output port 1a or 1b can be connected to the address bus AB, the data bus DB and the control bus simultaneously with the serial communication interface 2 or instead of the serial communication interface 2. In the usual operation mode, the CPU 7 reads the control program from the flash EEPROM 4 to control the serial communication interface 2, the flash EEPROM 4 and the RAM 5. For example, the CPU 7 performs a predetermined operation upon signals supplied via the serial communication interface 2 from the external circuit (not shown) and returns resulting signals to the external circuit. Also, the CPU 7 reads data from the RAM 5 to perform a predetermined operation upon the data, and writes resulting data into the RAM 5. An on-board writing operation mode is illustrated in Fig. 2B. In this case, a control program source 11 is connected via an adapter (not shown) to the serial communication interface; however, such a control program source 11 can be connected to the input/output port 1a or 1b. When, the mode control unit 3 recognizes an on-board writing operation mode by the data signal at the data bus DB supplied from the input/output port 1a (not shown in Fig. 2A, but shown in Fig. 1) or the like, the mode control unit 3 connects the serial communication interface 2, the flash EEPROM 4, the RAM 5 and the CPU 7 to the address bus AB, the data bus DB and the control bus. In the on-board writing operation mode, the CPU 7 reads the control program via the serial communication interface 2 from the control program source 11 in accordance with the writing program stored in the ROM 6, and temporarily stores the control program into the RAM 5. Then, the control program is written into the flash EEPROM 4 at a predetermined timing. Note that the control program can be temporarily stored in a buffer 7a of the CPU 7 instead of the RAM 5. A CPU testing mode is illustrated in Fig. 2C. In this case, a test program memory 12 is connected to the input/output port 1a; however, such a test program memory 12 can be connected to the serial communication interface 12. When the mode control unit 3 recognizes a CPU testing mode by the data signal at the data bus DB supplied from the input/output port 1a, the mode control unit 3 connects the input/output port 1a, the RAM 5 and the CPU 7 to the address bus AB, the data bus DB and the control bus. That is, the flash EEPROM 4 is separated from the internal buses. In the CPU testing mode, the CPU 7 reads a test program from the test program memory 12, so as to carry out various operations in accordance with the test program. For example, temporary data is stored in the RAM 5, and result data is outputted via the input/output port 1a -to the test program memory 12 or via the intput/output port 1b (not shown in Fig. 2C, but shown in Fig. 1). In Fig. 2C, an LSI tester instead of the test program memory 12 can be connected to the input/output port la. Thus, test patterns are generated from the LSI tester, to perform a test upon the microcomputer. A flash EEPROM testing mode is illustrated in Fig. 2D. In this case, a flash EEPROM 4 is connected to the address bus AB, the data bus DB and the control bus. That is, the CPU 7 is separated from the internal buses. As a result, the flash EEPROM tester 13 performs a writing operation, a writing verification operation, a flash erasing operation and an erasing verification operation upon the flash EEPROM 4. Thus, a testing time for the flash EEPROM 4 by the flash EEPROM tester 13 can be reduced as compared with that by the CPU 7. There are various types of the serial communication interface 2. One is a clock synchronous three-wire communication interface using three signal lines for a clock signal, a transmitting data signal and a receiving data signal. Another is an asynchronous two-wire communicaiton interface (UART) using two signal lines for a transmitting data signal and a receiving data signal each having a start pulse and a stop pulse. Still another is a synchronous IIC bus communication interface using two signal lines for a clock signal and a transmitting/receiving data signal. One of the types of serial communication interfaces is adopted in accordance with the scale of the serial communication interface 2, the characteristics such as operating speed, a characteristic of resistance to environment such as noise, the number of signals, the kind of upper system including the microcomputer, the ratio of chip area of the serial communication interface 2 to that of the microcomputer, the matching of the upper system and the like. In Fig. 3, which is a detailed circuit diagram of the flash EEPROM of Fig. 1, a plurality of word lines WL0, WL1, ... and a plurality of bit lines BL0, BL1, ... are provided. Reference numeral 41 designates a memory cell array formed by memory cells M00, M01, ... each having a source, a drain connected to one of the bit lines BL0, BL1,..., a floating gate, and a control gate connected to one of the word lines WL0, WL1, .... A row decoder 42 selects one of the word lines WL0, WL1, .... On the other hand, a column selection circuit 43 and a column decoder 44 selects one of the bit lines BL0, BL1, .... That is, the column selection circuit 43 is formed by column selection transistors Q c0 , Q c1 , ··· each connected between one of the bit lines BL0, BL1, ... and a digit line DL. One of the column selection transistors Q c0 , Q c1 , ... is selected and turned ON by the column decoder 44. The row decoder 42 and the column decoder 44 receive address signals from the address bus AB. A write amplifier 45 receives data from the data bus DB and transmits it to the digit line DL. On the other hand, a sense amplifier 46 senses data at the digit line DL and transmits it to the data bus DB. Voltages applied to the row decoder 42, the column decoder 44, the write amplifier 45 and the sources of the memory cells M00, M01, ... are controlled by a control circuit 47 as well as voltage generating circuit 48, 49 and 50. In this case, the control circuit 47 receives a write enable signal WE and an erase signal ER from a control bus CB which is not shown in Fig. 1. In more detail, when the control circuit 47 receives the write enable signal WE, the control circuit 47 generates a control signal WE1 in synchronization with the write enable signal WE and transmits it to the voltage generating circuit 48. As a result, a voltage V PP higher than a power supply voltage V cc is applied to the row decoder 42 and the column decoder 44. Simultaneously, the control circuit 47 generates a control signal WE2 in synchronization with the write enable signal WE and transmits it to the voltage generating circuit 49. As a result, the V PP is applied to the write amplifier 45, so that the write amplifier 45 applies a high voltage to the digit line DL in accordance with the data signal at the data bus DB. In this case, all the sources of the memory cells M00, M01, are grounded by the voltage generating circuit 50. Therefore, in a selected memory cell, high voltages are applied to the drain and the control gate while the source is grounded, thus carrying out a write operation. For example, the threshold voltage of the selected memory cell is made higher. On the other hand, when the control circuit 47 receives the erase signal ER, the control circuit 47 generates a control signal ER1 in synchronization with the erase signal ER and transmits it to the row decoder 42 and the column decoder 44. As a result, the row decoder 42 deactivates all the word lines WL0, WL1, ... , so that all the word lines WL0, WL1, ... are grounded. Also, the column decoder 44 deactivates all the column switching transistors Q c0 , Q c1 , ..., so that all the column switching transistors Q c0 , Q c1 ,··· are turned OFF. As a result, all the drains of the memory cells M00, M01, ... are in a floating state. Simultaneously, the control circuit 47 generates a control signal ER2 in synchronization with the erase signal ER and transmits, it to the voltage generating cirucit 50. As a result, the voltage generating circuit 50 applies the high voltage V PP to all of the sources of the memory cells M00, M01,... . Thus, a flash erase operation is carried out, so that the threshold voltages of all the memory cells are made lower. In Fig. 4, which is a detailed circuit diagram of the control circuit 47 of Fig. 3, only a section for generating the control signal WE1 is illustrated; the other sections for generating the control signals WE2, ER1 and ER2 are similar to this section. That is, the control circuit 47 includes a timing generating circuit 471 for receiving the write enable signal WE1 to generate a start pulse ST in synchronization with a clock signal CK. A counter 472 is initiated by receiving the start pulse ST to count the clock signal CK. A comparator 474 compares the content of the counter 472 with a preset value in a register 473. As a result, when the content of the counter 472 coincides with the preset value of the register 473, the comparator 474 generates a stop pulse SP. A pulse generating circuit 475 responds to the start pulse ST and the stop pulse SP. That is, the control signal WE1 rises in response to the start pulse ST and falls in response to the stop pulse SP. Note that the preset value of the register 473 is a definite value depending on the frequency of the clock signal CK. For example, the preset value corresponds to about 50 µs for the control signals WE1 and WE2, and corresponds to about 2s for the control signals ER1 and ER2. In the microcomputer of Fig. 1, although the CPU 7 is tested in the CPU testing mode and the flash EEPROM 4 is tested in a flash EEPROM testing mode, the flash EEPROM is not tested by the CPU 7. Therefore, even if the CPU testing mode and the flash EEPROM test mode both succeed, it is impossible to guarantee the operation of the flash EEPROM by the CPU 7, since the write enable signal WE, the erase signal ER and the other timing signals from the CPU 7 to the flash EEPROM 4 are not tested. Note that the test of the writing operation, the writing verification operation, the flash erasing operation and the erasing verification operation of the flash EEPROM 4 under the CPU 7 may be possible by operation of the ROM 6. In this case, however, since the ROM 6 includes a redundant program, it is impossible to effectively carry out such a test. Also, the ROM 5 is active only for an on-board writing operation mode; in other words, the ROM 6 is inactive for the other operation modes. Therefore, when the ROM 6 is incorporated into one chip of the microcomputer, the chip area thereof is increased, thus reducing the manufacturing yield. Further, since the serial communication interface 2 is fixed to one of the types of communication systems, an upper system is limited. If the microcomputer is forced to respond to all types of communication systems, a plurality of such types of serial communication interfaces have to be introduced into the chip of the microcomputer, thus making the control complex. Also, this increases the chip area, which reduces the manufacturing yield. Further, in order to write the control program into the flash EEPROM, since the control program is temporarily stored in the RAM 5 or a buffer 7a of the CPU 7, the time of a writing operation of the control program is long. Still further, in the control circuit 47 of the flash EEPROM 4, the time period of a writing operation and the time period of a flash erasing operation are determined by the preset value of the register 472 and the like. In this case, however, when the frequency of the clock signal CK is changed by the upper system or the type of the serial communication interface 2, the time period of a writing operation and the time period of a flash erasing operation are also changed. In Fig. 5, which illustrates a first embodiment of the microcomputer according to the present invention, a switching circuit 8 is interposed between the input/output port 1b and the internal buses and between the ROM 6 and the internal buses. In the case, the ROM 6 has the same address space as an external circuit connected to the input/output port 1b. Also, the switching circuit 8 is controlled by the mode control circuit 3. That is, in an emulation test mode, the switching circuit 8 is operated so that the ROM 6 is deactivated and the input/output port 1b is activated. The operations of the microcomputer of Fig. 5 are the same as those of the microcomputer of Fig. 1 except for an emulation test operation. The emulation test mode is illustrated in Fig. 6 where the deactivated blocks are removed from Fig. 5. That is, in advance of the emulation test operation, an emulation memory 21 is connected to the input/output port 1b, and an emulation test data source 22 is connected to the serial communication interface 2. First, the mode control unit 3 recognizes an emulation test mode by the data signal at the data bus DB supplied from the input/output port 1a (not shown in Fig. 6, but shown in Fig. 5) or the like. As a result, the mode control unit 3 connects the serial communication interface 2, the flash EEPROM 4, the RAM 5 and the CPU 7 to the address bus AB, the data bus DB and the control bus. Also, the mode control unit 3 operates the switching circuit 8 so that the ROM 6 is deactivated and the input/output port 1b, i.e., the emulation memory 21 is activated. Therefore, the emulation memory 21 can be accessed by the same addresses for the ROM 6. Thus, the CPU 7 reads an emulation test data via the serial communication interface 2 from the emulation test data source 22 in accordance with the emulation program stored in the emulation memory 21, and temporarily stores the emulation test data into the RAM 5. Then, the emulation test data is written into the flash EEPROM 4 at a predetermined timing. Note that the emulation test data program can be temporarily stored in the buffer of the CPU 7 instead of the RAM 5. Thus, the functions of the serial communication interface 2, the RAM 5 and the CPU 7 are tested. Also, when the emulation test data is written into the flash EEPROM 4, a writing verification operation is carried out by the CPU 7 in accordance with the emulation program stored in the emulation memory 21. Thus, a determination of whether or not an on-board writing operation is normally carried out can be done. As a result, if the on-board writing operation is determined to be abnormal, the emulation program stored in the emulation memory 21 and the emulation memory 21 and the emulation test data stored in the emulation test data source 22 are corrected, thus carrying out an on-board writing operation again. Further, a writing program, a writing verification program, a flash erasing program and an erasing verification program are stored in the emulation memory 21. Therefore, the CPU 7 performs a writing operation, a writing verification operation, a flash erasing operation and an erasing verification operation upon the flash EEPROM 4 in accordance with the emulation program stored in the emulation memory 21. Thus, the write enable signal, the erase signal and the other timing signals from the CPU 7 to the flash EEPROM 4 can be effectively tested. In Fig. 7, which illustrates a second embodiment of the microcomputer according to the present invention, a writing program area 5a is provided in the RAM 5, and intead of this, the ROM 6 of Fig. 1 is removed. That is, at an initial state such as a power on state, the writing program area 5a is initialized to store a writing program in the writing program area 5a of the RAM 5. For example, the RAM 5 is formed by a static random access memory (SRAM) having flip-flop type cells, and the states of the flip-flop type cells of the writing program area 5a are fixed in advance. That is, since each cell is formed by two resistances and two cross-coupled driving transistors, if one of the resistances is made larger than the other, the state of this cell is fixed. Thus, as illustrated in Fig. 8, in an on-board writing operation mode, the CPU 7 reads a control program via the serial communication interface 2 from the control program source 11 in accordance with the writing program stored in the writing program area 5a of the RAM 5, and temprorarily stores the control program into the RAM 5. Then, the control program is written into the flash EEPROM 4 at a predetermined timing. Note that the control program can be temporarily stored in the buffer 7a of the CPU 7 instead of the RAM 5. Thus, in Fig. 8, since the ROM 6 of Fig. 1 is unnecessary, the chip area of the microcomputer can be reduced, thus increasing the manufacturing yield. In Fig. 9, which illustrates a third embodiment of the microcomputer according to the present invention, the serial communication interface 2 of Fig. 1 is modified into a serial communication interface 2'. The serial communication interface 2' includes three types of interfaces, i.e., a synchronous three-wire communication interface 201, an asynchronous two-wire communication interface 202, and a synchronous IIC bus communication interface 203. Also, one of the interfaces 201, 202 and 203 is selected by a selector 204 which is controlled by a register 205. The content of the register 205 is set at a predetermined timing using the flash EEPROM 4 or the RAM 5 which is also set by a power on routine or the like. Note that the register 205 can be set directly by supplying voltages to terminals of the register 205. Thus, in Fig. 9, since one of the interfaces 201, 202 and 203 can be selected in accordance with the upper system, thus matching with the upper system. In Fig. 10, which illustrates a fourth embodiment of the microcomputer according to the present invention, a data reception time detector 9 is connected to the internal buses AB and DB, and the data reception time detector 9 is also connected to the CPU 7. That is, in an on-board writing operation mode, the data reception time detector 9 detects an interval time T between one piece of the control program and another piece of the control program, and transmits the interval time T to the CPU 7. Therefore, in an on-board writing operation mode, the CPU 7 reads a control program via the serial communication interface 2 from the control program source 11 (see Fig. 2B) in accordance with the writing program stored in the ROM 6. In this case, at each timing of reading one piece of the control program, the CPU 7 determines whether or not the interval time T is smaller than a definite time T0. As a result, if T < TO, which means that the data read speed is large, the CPU 7 temporarily stores the piece of the control program into the RAM 5. Then, the control program is written into the flash EEPROM 4 at a predetermined timing. Note that the control program can be temporarily stored in the buffer 7a (see Fig. 2B) of the CPU 7 instead of the RAM 5. Contrary to this, if T 5≧ T0, which means that the data read speed is small, the CPU 7 directly writes the piece of the control program into the flash EEPROM 4. Thus, the operation speed of the on-board writing operation can be increased. In Fig. 11A, which illustrates a fifth embodiment of the microcomputer according to the present invention, the content of the register 473 of Fig. 4 can be changed, while the content of the register 473 in the prior art is fixed. That is, the content of the register 473 can be changed in accordance with the frequency of the clock signal CK. In Fig. 11B, which is a modification of the control circuit 47 of Fig. 11A, a frequency-to-voltage conversion circuit 476 is connected to the register 473. In this case, the frequency-to-voltage conversion circuit 476 generates a digital signal whose value is proportional to the frequency of the clock signal CK. Therefore, in the control circuit 47 of Fig. 11B, the content of the register 473 can be automatically set. In Fig. 11B, when the frequency of the clock signal CLK is too large, the value of the frequency to voltage conversion circuit 476 may be larger than the maximum value of the register 473. This is compensated for by circuits as illustrated in Figs. 11C and 11D. In Fig. 11C, a counter 477, a determination circuit 478, and gate circuits 479, 480 and 481 are added to the elements of Fig. 11B. That is, the counter 477 receives the output of the comparator 474 to count the clock signal CK. Then, when the content of the counter 477 reaches a predetermined value, the counter 477 generates a delayed stop pulse. The determination circuit 478 determines whether or not the value of the frequency-to-voltage conversion circuit 476 is larger than a predetermined value corresponding to the maximum value of the register 473. As a result, if the value of the frequency-to-voltage conversion circuit 476 is larger than the predetermined value, the delay stop signal of the counter 477 is transmitted via the gate circuits 480 and 481 selected by the determination circuit 478 to the pulse generating circuit 475. In this case, the maximum value is set in the register 473. Otherwise, the output signal of the comparator 474 is transmitted via the gate circuits 479 and 481 selected by the determination circuit 478 as the stop pulse to the pulse generating circuit 475. In Fig. 11D, a determination 482, which is the same as the determination circuit 478 of Fig. 11C, and a pulse eliminating circuit 483 are added to the elements of Fig. 11B. The pulse eliminating circuit 483 eliminates a part of pulses of the clock signal CK. As a result, if the value of the frequency-to-voltage conversion circuit 476 is larger than the predetermined value, the pulse eliminating circuit 483 is activated by the determination circuit 482, thus substantially delaying the generation of the stop pulse SP. In this case, the maximum value is also set in the register 473. Otherwise, the pulse eliminating circuit 483 is deactivated by the determination circuit 482, so that all pulses of the clock signal CK pass though the pulse eliminating circuit 483 and reach the counter 472. As explained hereinabove, according to the present invention, since the write enable signal, the erase signal and the other timing signals from the CPU to the flash EEPROM are tested, it is possible to guarantee the operation of the flash EEPROM by the CPU. Also, since the function of the ROM is incorporated into the RAM, the chip area of the microcomputer is decreased, thus increasing the manufacturing yield. Further, since the serial communication interface responds to a plurality of types of serial communication interfaces, matching with any possible upper systems can be obtained. Further, since the operation speed of an on-board writing operation mode is adjusted in accordance with the read speed of a program from the serial communication interface, the operation speed of the on-board writing operation mode can be improved. Still further, even when the frequency of the clock signal is changed by the upper system or the type of the serial communication interface, the time period of a writing operation and the time period of a flash erasing operation can be almost definite.

Claims: A microcomputer comprising: internal buses (AB, DB); a serial communication interface (2) connected to said internal buses; a flash memory (4) connected to said internal buses; a RAM (5), connected to said internal buses, for storing temporary data; a ROM (6) for storing a writing program; an input/output port (1b); a CPU (7); a switching circuit (8) connected between said ROM and said internal buses and between said input/output port and said internal buses; and a mode control unit (3), connected to said internal buses, said serial communication interface, said flash memory, said RAM, said ROM, said CPU and said switching circuit, for operating said switching circuit in an emulation test mode so that said ROM is deactivated and said input/output port is activated, said CPU reading a program from said serial communication interface and writing said program into said flash memory in accordance with a writing program from said input/output port. The microcomputer as set forth in claim 1, wherein said CPU performs a writing verification operation, a flash erasing operation and an erasing verification operation upon said flash memory in accordance with a writing verification program, a flash erasing program and an erasing verification program via said input/output port. The microcomputer as set forth in claim 1, wherein said CPU temporarily stores said program in said RAM before writing into said flash memory. The microcomputer as set forth in claim 1, wherein said CPU temporarily stores said program in a buffer (7a) of said CPU before writing into said flash memory. A microcomputer as set forth in claim 1, wherein said flash memory comprises a control circuit (47) for generating control signals (WE1, WE2, ER1, ER2) for a writing operation and a flash erasing operation in response to a write enable signal (WE) and an erase signal (ER), one unit of said control circuit for generating one of said control signals comprising: a timing generating circuit (471) for receiving one of said write enable signal and said erase signal to generate a start pulse (ST) in response to a clock signal (CK); a counter (472), connected to said timing generating circuit, for receiving said start pulse to count pulses of said clock signal; a register (473) for storing a value corresponding to one of a writing operation time and a flash erasing operation time, said value being variable; a comparator (474), connected to said counter and said register, for comparing a value of said counter with the value of said register to generate a stop pulse (ST) when the value of said counter reaches the value of said register; and a pulse generating circuit (475), connected to said timing generating circuit and said comparator, for generating a corresponding one of said control signals defined by said start pulse and said stop pulse. The microcomputer as set forth in claim 5, wherein the one unit of said control circuit further comprises a frequency detecting circuit (476), connected to said register, for detecting a frequency of said clock signal, a value corresponding to the frequency of said clock signal being set in said register. The microcomputer as set forth in claim 6, wherein the one unit of said control circuit further comprises: a determination circuit (478), connected to said frequency detecting circuit, for determining whether or not the value corresponding to the frequency of said clock signal is larger than a maximum value of said register; means (477, 479, 480, 481), connected to said determination circuit and said comparator, for delaying said stop pulse for a certain time period, when the value corresponding to the frequency of said clock signal is larger than the maximum value of said register. The microcomputer as set forth in claim 6, wherein the one unit of said control circuit further comprises: a determination circuit (482), connected to said frequency detecting circuit, for determining whether or not the value corresponding to the frequency of said clock signal is larger than a maximum value of said register; and a pulse eliminating circuit (483), connected to said determination circuit and said counter, for eliminating a part of pulses of said clock signal, when the value corresponding to the frequency of said clock signal is larger than the maximum value of said register. A method for testing a microcomputer including: internal buses (AB, DB); a serial communication interface (2) connected to said internal buses; a flash memory (4) connected to said internal buses; a RAM (5), connected to said internal buses, for storing temporary data; a ROM (6) for storing a writing program; an input/output port (1b); a CPU (7); a switching circuit (8) connected between said ROM and said internal buses and between said input/output port and said internal buses; a mode control unit (3), connected to said internal buses, said serial communication interface, said flash memory, said RAM, said ROM, said CPU and said switching circuit, for operating said switching circuit in an emulation test mode so that said ROM is deactivated and said input/output port is activated, said method comprising the steps of: connecting an emulation memory (21) for storing said writing program to said input/output port, said emulation memory having the same address space as said ROM; connecting an emulation test data source (22) for storing a program to said serial communication interface; and reading said program from said emulation test data source and writing said program into said flash memory in accordance with said writing program stored in said emulation memory by said CPU. The method as set forth in claim 9, further comprising performing a writing verification operation, a flash erasing operation and an erasing verification operation upon said flash memory in accordance with a writing verification program, a flash erasing program and an erasing verification program stored in said emulation memory by said CPU. A microcomputer comprising: internal buses (AB, DB); a serial communication interface (2) connected to said internal buses; a flash memory (4) connected to said internal buses; a RAM (5), connected to said internal buses, for storing a writing program; an input/output port (1b); a CPU (7); and a mode control unit (3), connected to said internal buses, said serial communication interface, said flash memory, said RAM, said input/output port and said CPU, for setting an on-board writing mode in said microcomputer, said CPU reading a program from said serial communication interface and writing said program into said flash memory in accordance with a writing program stored in said RAM. The microcomputer as set forth in claim 11, wherein an area (5a) of said RAM for storing said writing program comprises flip-flop type cells each having two resistances and two cross-coupled transistors, one of said resistances being different from the other. A microcomputer as set forth in claim 11, wherein said flash memory comprises a control circuit (47) for generating control signals (WE1, WE2, ER1, ER2) for a writing operation and a flash erasing operation in response to a write enable signal (WE) and an erase signal (ER), one unit of said control circuit for generating one of said control signals comprising: a timing generating circuit (471) for receiving one of said write enable signal and said erase signal to generate a start pulse (ST) in response to a clock signal (CK); a counter (472), connected to said timing generating circuit, for receiving said start pulse to count pulses of said clock signal; a register (473) for storing a value corresponding to one of a writing operation time and a flash erasing operation time, said value being variable; a comparator (474), connected to said counter and said register, for comparing a value of said counter with the value of said register to generate a stop pulse (ST) when the value of said counter reaches the value of said register; and a pulse generating circuit (475), connected to said timing generating circuit and said comparator, for generating a corresponding one of said control signals defined by said start pulse and said stop pulse. The microcomputer as set forth in claim 13, wherein the one unit of said control circuit further comprises a frequency detecting circuit (476), connected to said register, for detecting a frequency of said clock signal, a value corresponding to the frequency of said clock signal being set in said register. The microcomputer as set forth in claim 14, wherein the one unit of said control circuit further comprises: a determination circuit (478), connected to said frequency detecting circuit, for determining whether or not the value corresponding to the frequency of said clock signal is larger than a maximum value of said register; means (477, 479, 480, 481), connected to said determination circuit and said comparator, for delaying said stop pulse for a certain time period, when the value corresponding to the frequency of said clock signal is larger than the maximum value of said register. The microcomputer as set forth in claim 14, wherein the one unit of said control circuit further comprises: a determination circuit (482), connected to said frequency detecting circuit, for determining whether or not the value corresponding to the frequency of said clock signal is larger than a maximum value of said register; and a pulse eliminating circuit (483), connected to said determination circuit and said counter, for eliminating a part of pulses of said clock signal, when the value corresponding to the frequency of said clock signal is larger than the maximum value of said register. A microcomputer comprising: internal buses (AB, DB); a serial communication interface (2) connected to said internal buses; a flash memory (4) connected to said internal buses; a RAM (5), connected to said internal buses, for storing temporary data; a ROM (6) for storing a writing program; an input/output port (1a, 1b); a CPU (7); and a mode control unit (3), connected to said internal buses, said serial communication interface, said flash memory, said RAM, said ROM, said CPU and said switching circuit, for setting operation modes and testing modes in said microcomputer, said serial communication interface including a plurality of kinds of serial communication interface units (201, 202, 203), and a selector means (204, 205) for selecting one of said serial communication interface units according to a predetermined timing using the flash memory (4) on the RAM (5). A microcomputer as set forth in claim 17, wherein said flash memory comprises a control circuit (47) for generating control signals (WE1, WE2, ER1, ER2) for a writing operation and a flash erasing operation in response to a write enable signal (WE) and an erase signal (ER), one unit of said control circuit for generating one of said control signals comprising: a timing generating circuit (471) for receiving one of said write enable signal and said erase signal to generate a start pulse (ST) in response to a clock signal (CK); a counter (472), connected to said timing generating circuit, for receiving said start pulse to count pulses of said clock signal; a register (473) for storing a value corresponding to one of a writing operation time and a flash erasing operation time, said value being variable; a comparator (474), connected to said counter and said register, for comparing a value of said counter with the value of said register to generate a stop pulse (ST) when the value of said counter reaches the value of said register; and a pulse generating circuit (475), connected to said timing generating circuit and said comparator, for generating a corresponding one of said control signals defined by said start pulse and said stop pulse. The microcomputer as set forth in claim 18, wherein the one unit of said control circuit further comprises a frequency detecting circuit (476), connected to said register, for detecting a frequency of said clock signal, a value corresponding to the frequency of said clock signal being set in said register. The microcomputer as set forth in claim 19, wherein the one unit of said control circuit further comprises: a determination circuit (478), connected to said frequency detecting circuit, for determining whether or not the value corresponding to the frequency of said clock signal is larger than a maximum value of said register; means (477, 479, 480, 481), connected to said determination circuit and said comparator, for delaying said stop pulse for a certain time period, when the value corresponding to the frequency of said clock signal is larger than the maximum value of said register. The microcomputer as set forth in claim 19, wherein the one unit of said control circuit further comprises: a determination circuit (482), connected to said frequency detecting circuit, for determining whether or not the value corresponding to the frequency of said clock signal is larger than a maximum value of said register; and a pulse eliminating circuit (483), connected to said determination circuit and said counter, for eliminating a part of pulses of said clock signal, when the value corresponding to the frequency of said clock signal is larger than the maximum value of said register. A microcomputer comprising: internal buses (AB, DB); a serial communication interface (2) connected to said internal buses; a flash memory (4) connected to said internal buses; a RAM (5), connected to said internal buses, for storing temporary data; a ROM (6) for storing a writing program; an input/output port (1a, 1b); a CPU (7); a mode control unit (3), connected to said internal buses, said serial communication interface, said flash memory, said RAM, said ROM, said CPU and said switching circuit, for setting an on-board writing operation in said microcomputer, and a data reception time detector (9), connected to said internal buses and said CPU, for counting an interval time (T) between pieces of a control program propagating said internal buses and read by said CPU (7) via said serial communication interface (2) in accordance with said stored writing program, said CPU temporarily storing said control program in one of said RAM and a buffer (7a) of said CPU before writing said flash memory, when said interval time is smaller than a certain value, said CPU directly writing said control program into said flash memory, when said interval time is not smaller than said certain value. A microcomputer as set forth in claim 22, wherein said flash memory comprises a control circuit (47) for generating control signals (WE1, WE2, ER1, ER2) for a writing operation and a flash erasing operation in response to a write enable signal (WE) and an erase signal (ER), one unit of said control circuit for generating one of said control signals comprising: a timing generating circuit (471) for receiving one of said write enable signal and said erase signal to generate a start pulse (ST) in response to a clock signal (CK); a counter (472), connected to said timing generating circuit, for receiving said start pulse to count pulses of said clock signal; a register (473) for storing a value corresponding to one of a writing operation time and a flash erasing operation time, said value being variable; a comparator (474), connected to said counter and said register, for comparing a value of said counter with the value of said register to generate a stop pulse (ST) when the value of said counter reaches the value of said register; and a pulse generating circuit (475), connected to said timing generating circuit and said comparator, for generating a corresponding one of said control signals defined by said start pulse and said stop pulse. The microcomputer as set forth in claim 23, wherein the one unit of said control circuit further comprises a frequency detecting circuit (476), connected to said register, for detecting a frequency of said clock signal, a value corresponding to the frequency of said clock signal being set in said register. The microcomputer as set forth in claim 24, wherein the one unit of said control circuit further comprises: a determination circuit (478), connected to said frequency detecting circuit, for determining whether or not the value corresponding to the frequency of said clock signal is larger than a maximum value of said register; means (477, 479, 480, 481), connected to said determination circuit and said comparator, for delaying said stop pulse for a certain time period, when the value corresponding to the frequency of said clock signal is larger than the maximum value of said register. The microcomputer as set forth in claim 24, wherein the one unit of said control circuit further comprises: a determination circuit (482), connected to said frequency detecting circuit, for determining whether or not the value corresponding to the frequency of said clock signal is larger than a maximum value of said register; and a pulse eliminating circuit (483), connected to said determination circuit and said counter, for eliminating a part of pulses of said clock signal, when the value corresponding to the frequency of said clock signal is larger than the maximum value of said register.

Inventors: AKIYAMA SHIN-ICHIRO, IIZUKA YUICHI, NISHIMOTO HIROAKI, OSADA YUUICHI, YASUDA SADAHIRO, AKIYAMA, SHIN-ICHIRO, IIZUKA, YUICHI, NISHIMOTO, HIROAKI, OSADA, YUUICHI, YASUDA, SADAHIRO, Nishimoto, Hiroaki, NEC IC Microcomp. Systems, Ltd, Osada, Yuuichi, NEC IC Microcomp. Systems, Ltd.
Applicants: NIPPON ELECTRIC CO, NEC CORPORATION
Application year: 1996
Main classification: G06F11
IPC codes: G11C29, G11C17, G06F15, G06F11, G06F12