Abstract:
A microprocessor used in solid state products has multiple interrupts and a single read only memory (ROM) masked for two or more product programs. The logic state of an input pin is set to select the appropriate program. If there is an error in one program or it becomes obsolete, the microprocessor does not have to be scrapped, but can be used to execute the other (another) product program. Separate interrupt selection routines for each interrupt, addressed from a common interrupt vector table, direct program execution to an interrupt branch table for the product indicated by the input pin. The product branch table contains addresses for the interrupt service routines for the selected product. The product programs are first separately linked with the interrupt branch table for the corresponding product. The common interrupt vector table and the interrupt selection routines are then linked with one product program and its interrupt branch table, before final linkage of all software components to avoid conflicts should a program be changed.

Description:
BACKGROUND OF THE INVENTION 
     1. Field of the Invention 
     This invention is directed to a microprocessor having a single read only memory (ROM) which is masked to handle interrupts for two or more separate application programs so that the microprocessor may be used interchangably in different solid-state products. 
     2. Background Information 
     The development of microprocessors implemented by an integrated circuit, the &#34;computer on a chip&#34;, has contributed greatly to the expansion of functions that can be performed by many products. Not only has the variety of functions of such products been expanded by these microprocessors, but the specific functions, or combinations of functions, can be tailored to the application. This versatility is realized through programming of the microprocessor. The program is stored in a nonvolatile memory. For large volume products, a read only memory (ROM) in which the program is permanently etched into the integrated circuit is used to store the program. A microprocessor which is programmed in this manner is referred to as a &#34;masked microprocessor&#34; in reference to the processing techniques by which the appropriate circuit configuration is established. While programmable memories can be used for storing programs which are likely to be modified, either from application to application or for enhancements, the ROMs of the masked microprocessor are much less costly when implemented in large numbers. On the other hand, the use of masked microprocessors in solid state products has always presented the risk that if programming bugs exist, or a change in the program is required, all instock processors have to be scrapped. 
     The microprocessor conventionally has available several interrupts which allow the program to leave a routine to perform a task with a higher priority and then to resume the original routine. These interrupts can be in response to internal signals such as from a timer, a counter, a reset module or an input/output device, or from external signals such as a signal from the operation of contacts or from a sensor. Typically, these interrupts are implemented by an interrupt vector table in memory which stores an address for branching to an appropriate interrupt service routine. The service routines are the sets of instructions to be carried out by the processor in response to the interrupts. 
     There remains a need for a mass produced multiple interrupt microprocessor with an inexpensive masked memory which does not have to be scrapped if there is an error in the program etched into the masked memory or if the program is later changed. 
     SUMMARY OF THE INVENTION 
     This need and others are satisfied by the invention which is directed to a microprocessor with multiple interrupts and having a single masked read only memory. In accordance with the invention, the read only memory (ROM) is masked to store two or more separate programs which may be selectively implemented by the microprocessor. These separate programs could be redundant copies of the same program, but preferably are different programs which give the microprocessor the capability of performing different functions. Thus, where the microprocessor is used to provide electronic control for various products, it can be programmed to be interchangeably used in two or more different products, or to provide different kinds of control for a given product. If it turns out that one of the programs is defective or has become obsolete, the microprocessor need not be discarded, but can be used with another product for which the memory has been masked. Obviously, if all programs for which the ROM is masked are defective and/or become obsolete, then the microprocessor chip must be discarded; however, even where the ROM is masked for only two alternate programs, the likelihood of such events affecting both programs occurring simultaneously is significantly less than the likelihood of just one such event occurring. 
     In carrying out the invention with a microprocessor having multiple interrupts, the ROM is masked to provide a separate interrupt selection routine for each interrupt. A common interrupt vector table in ROM directs the processor to the selection routine for the current interrupt. The product program to be executed is set by a logic level applied to a microprocessor input. The selection routines poll this input and transfer program execution to an interrupt branch table for the selected product program. The branch table contains the addresses of all of the separate interrupt service routines for the selected product program. Program execution branches to the interrupt service routine for the current interrupt found in the branch table. Each product program is separately linked with its own interrupt branch table. The common interrupt branch table and all of the interrupt selection routines are also linked with one product program before all of the software is linked for masking the ROM to permit the use of common labels in the different product programs without conflict. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     A full understanding of the invention can be gained from the following description of the preferred embodiments when read in conjunction with the accompanying drawings in which: 
     FIG. 1 is a schematic diagram of a microprocessor system in accordance with the invention. 
     FIG. 2 is an illustration of the manner in which the microprocessor system of FIG. 1 handles multiple interrupts for two product programs. 
     FIG. 3 is an illustration of a map of the read only memory of the system of FIG. 1. 
     FIG. 4 is an illustration of a map of the random access memory of the system of FIG. 1. 
     FIG. 5 is a flow chart showing operation of the system of FIG. 1 in accordance with the invention. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     Referring to FIG. 1, a typical microprocessor 1 incorporating the invention is shown schematically. The microprocessor 1 includes a central processing unit (CPU) 3, a read only memory (ROM) 5, a random access memory (RAM) 7, an analog to digital converter (ADC) 9, several timers 11, 13, and 15 and several input to output devices such as a serial peripheral interface (SPI) 17 and a serial communications interface (SCI) 19. In addition, the microprocessor 1 includes several input/output ports 21, such as ports A-D. These components of the microprocessor 1 are interconnected by a bus system 23. The microprocessor 1 further includes external interrupts 25, an oscillator clock 27 and a system control 29. 
     An example of a suitable microprocessor 1 is a TMS370 microcomputer manufactured by Texas Instruments, Inc. The CPU 3 of the exemplary microprocessor 1 is an 8-bit processor with an internal status register, program counter register, and a stack pointer. The CPU 3 uses the RAM 7 as working registers accessed on the bus 23. The ROM 5 stores the multiple application programs for the products with which the microprocessor 1 is to be alternatively used. As will be seen, the ROM 5 also stores the files used to handle interrupts for the multiple independent application programs. The ADC 9 multiplexes analog signals on multiple input channel 31 and converts them to digital signals for internal use by the CPU 3. The SPI 17 is a high-speed synchronous serial input/output port which provides for communications between the microprocessor 1 and external peripherals or another microprocessor. The serial communications interface (SCI) 19 provides for digital communications between the microprocessor 1 and other asynchronous peripherals. The timers 11 and 13 provide the capability of timing for real time control and counting. The watch dog timer 15 can be used to perform a dead man function or can be used as an additional timer/counter. The ports A-D, 21, can be used for either digital input or output. In accordance with the invention, these ports can be used for selection of the application program to be run by the microprocessor 1. While as explained above, the invention contemplates programming the micro-controller 1 to perform any one of a number of alternative application programs, the invention will be described as providing the capability to select one of two independent application programs. As indicated in FIG. 1, this capability is provided by a switch 33 which inputs either a logical 1 or 0 for selection of the appropriate application program. 
     The clock module 27 is connected to an external crystal oscillator (not shown) to provide the timing function for the microprocessor 1. The system control module 29 includes a reset line 35 by which the microcontrol is initialized. The interrupt module 25 allows the microprocessor 1 to respond to external interrupts. Internal interrupts are generated by the system control 29, the A to D converter 9, the serial peripheral interface 17, the serial communications interface 19 and the timers 11, 13, and 15. The number of interrupts vary with the particular microprocessor used; however, in the exemplary microprocessor, there are ten interrupts available. 
     In accordance with the invention, the microprocessor 1 is adapted to alternatively execute multiple (in the exemplary embodiment 2) independent application programs which share masked ROM 5, the entire RAM 7 and common interrupt vectors. Since the microprocessor 1 is being described for use in controlling various products, the application programs will hereafter be referred to as product programs, meaning application programs written for a specific product. In he exemplary system, the microprocessor 1 is used alternatively for controlling an electric meter and a resistance temperature detector. Obviously, the programs adapted for these two products will utilize the various interrupts for different functions. Since common interrupt vectors are used; however, a procedure must be provided for directing the microprocessor to the appropriate service routine for the current product program being executed. The process by which this is achieved in accordance with the invention is illustrated in FIG. 2. Block 37 in FIG. 2 identifies the ten interrupts, labeled 0 to 9, which are available in the exemplary microprocessor. A separate interrupt selection routine is provided for each interrupt. The common interrupt vectors comprise a table 39 which stores the address of the selection routine 41 for each of the interrupts 0 to 9. Upon the occurrence of an interrupt, the CPU accesses the interrupt vector table 39 to find the address of the selection routine 41 for the current interrupt. The appropriate selection routine 41 is then run. These interrupt selection routines are short programs which check the product selection pin at port D to determine the position of the product selection switch 33. If the switch 33 is set to the logic 1 value (+5 V), the processor branches to the entry for the current interrupt in a product A branch table 43. If the selection switch 33 is set to logic 0 (tied to ground), the selection routine 41 branches to the appropriate location in the product B interrupt branch table 45. The branch tables 43 and 45 contain the addresses for the separate product A interrupt service routines 47 and product B interrupt service routines 49, respectively, which are then executed by the processor. If a particular interrupt is not required in one product program, a return from interrupt instruction is used in the interrupt service routine of the interrupt for that product. Upon completion of the appropriate interrupt service routine, the processor returns to the program being executed at the time of the interrupt. 
     While the ROM 5 is masked to store the product programs and the above scheme for handling interrupts, it is still likely that changes may be desired in the software in future additions of the product. In order to prevent software changes from generating conflicting labels or addresses for the multiple programs, one of the product programs is first linked separately along with its branch table. The other product program is then linked separately with its branch table, the decision-making interrupt service routines and the interrupt vectors pointing to these routines. By linking the programs independently, labels are resolved within the separate modules so that if the same label is used in both products, the correct address is assigned before each reference. The partially linked files are then linked and located into a single executable file. 
     FIG. 3 illustrates a total map 38 of the ROM 5 in which the product programs and interrupt files have been linked in this manner. As can be seen from FIG. 3, the product A program code 40 begins at address 6000H. The product selection routines 41 are stored with the product A program code with which they were linked starting at address 7060H. This is followed by the product B program code 42 beginning at address 7087H. If additional product programs are to be made available to the microprocessor, they would be stored next. Following the last product program code, the product B interrupt branch table 45 is stored beginning at address 7F84H. This is followed by the product A interrupt branch table 43 beginning at address 7FA2H and finally the microprocessor interrupt vector address table 39 beginning at address 7FC0H. Of course, interrupt branch tables must also be provided for any additional product programs. The addresses of these new branch tables must be hard coded into the product selection routines. The number of products that can be served by the microprocessor is limited by the size of the ROM 5 and the length of the independent programs. Of course, the product programs can include independent programs for different models of the same product as well as programs for very different products. The ROM map 38 in FIG. 3 is exemplary only and may be differently organized within the scope of the invention. 
     As mentioned above, the interrupt branch tables 43 and 45 make it convenient for making program changes in future additions of the microprocessor 1. The branch tables can be eliminated; however, this requires hard coding the addresses of the interrupt service routines into the selection routines. This would then require added care in making program changes to avoid conflicts in use of the ROM. 
     In order to allow each of the product programs to have use of the full space in RAM 7 when executing, the linker must be able to accommodate memory page definitions. FIG. 4 illustrates a map for the RAM 5 in which memory for the two programs exist on overlying pages, each of which start with the first address 0000H. 
     FIG. 5 illustrates a flow chart for the microprocessor 1 incorporating the invention. When the processor receives the interrupt at 51, it obtains the address of the corresponding interrupt selection routine from the interrupt vector address table as indicated at 53. The selection routine for the indicated interrupt is then executed at 55. This includes setting up the input port to receive the product selection bit(s) as indicated at 57. The product selection bit(s) is then polled at 59, and if the selection bit(s) is a logic 1 as determined at 61, program execution branches to the entry in the product A interrupt branch table corresponding to the current interrupt as indicated at 63. The branch instruction at the designated entry in the interrupt branch table for product A and the corresponding interrupt is then executed at 65 to jump to the interrupt service routine for the current interrupt as indicated at 65. The product A interrupt service routine for the current interrupt is then executed at 67. 
     If the product selection pin is a logic 0 at 61, then program execution branches to the entry in the product B interrupt branch table corresponding to the current interrupt as indicated at 69. The branch instruction in the product B interrupt branch table for the current interrupt is then executed at 71. This leads to execution of the product B interrupt service routine for the current interrupt at 73. At the conclusion of the appropriate interrupt service routine, the program returns, as indicated at 75, to the program which was being executed at the time of the interrupt. Upon initialization, a reset interrupt is generated. The reset interrupt service routine for the product program selected by the product selection switch 33, which is polled by the reset interrupt service routine, ends with a call for the selected product program. All other interrupt service routines for that product return program execution to that product program. 
     As seen from the above, the present invention permits a masked microprocessor to be stocked for two or more products. This reduces the per unit cost by increasing the volume of the masked microprocessor. It also provides insurance against an error in a product&#39;s software program, and allows for obsolescence of a product program. 
     While specific embodiments of the invention have been described in detail, it will be appreciated by those skilled in the art that various modifications and alternatives to those details could be developed in light of the overall teachings of the disclosure. Accordingly, the particular arrangements disclosed are meant to be illustrative only and not limiting as to the scope of the invention which is to be given the full breadth of the appended claims and any and all equivalents thereof.