Data processor including a/d converter for converting a plurality of analog input channels into digital data

Abstract: A data processor comprises a CPU (100) for executing a program, an A/D converter (400) for converting a selected one of a plurality of analog inputs into digital data, means (303) for storing designation data for said inputs, means (501) responsive to a completion signal from the A/D converter for supplying a macro service request to the CPU, and execution means (107) in said CPU responsive to said request for suspending execution of the program and for detecting the stored designation data and setting corresponding selection data for the A/D converter to select an analog input and convert it into digital data which are transferred to a predetermined destination area (304-311) whereupon the CPU resumes execution of the suspended program.

Description: BACKGROUND OF THE INVENTION The present invention relates to a data processor and, more particularly, to a microcomputer including an analog-to-digital converter (called hereinafter an "A/D converter") for converting a plurality of analog input channels into the corresponding digital data. A microcomputer including an A/D converter can perform a data processing operation on an analog signal supplied thereto and is thus widely employed in various systems. When the data processing on the analog signal is requested, a CPU (Central Processing Unit) in the microcomputer supplies a converting command to the A/D converter and then receives the converted digital data to perform the requested processing operation thereon. There is a serious problem in the operation of the CPU after supplying the converting command to the A/D converter. A time required by the A/D converter to convert the analog signal into the digital data is considerably longer than a time required by the CPU to execute one instruction. For this reason, a first control method in which the subsequent processing operations by the CPU is stopped until the converted digital data is derived from the A/D converter, remarkably lowers the executing efficiency of the CPU. In order to solve this problem, a second control method is employed in which the CPU continues to perform the subsequent operations after supplying the converting command to the A/D converter and, on the other hand, the A/D converter generates an interruption request to the CPU when completing the converting operation. When the interruption request is generated, the CPU suspends the operations in a main program routine and saves the contents of a program counter and a status register into a stack area of a data memory, followed by starting an operation in an interruption program routine. The program counter is used for reading each instruction out of a program memory and the status register stores status data representative of an executing condition of the CPU. In accordance with the operation in the interruption program routine, the CPU reads the converted data from the A/D converter and transfers it to a predetermined destination area of the data memory. When the operation in the interruption program routine is completed, the CPU returns the saved contents to the program counter and the status register, respectively, and then resumes the operation in the main program routine. Thus, the second control method can enhance the execution efficiency of the CPU. However, in order that the CPU starts to execute the interruption program routine and resumes the suspended main program routine, there are required overheads for saving the contents of the program counter and the status register and for returning the saved contents thereto, respectively. For this reason, this control method restricts the execution efficiency and processing capability of the CPU. In order to overcome the drawbacks of the first and second control methods, therefore, a new control method has been disclosed in EP-A-0 153 764 published on September 4, 1985. This control method is to perform the operation responsive to the completion of the A/D conversion, i.e. the transfer of the converted data to the destination area, without intervention of any user's program operation. More specifically, the microcomputer disclosed in the above publication is constructed to perform two types of interruption operation, the first one of which is executed by use of user's interruption program and thus required to save the contents of the program counter and the status register and the second one of which is executed by no use of user's interruption program with holding the contents of the program counter and status register. When the A/D converter generates the interruption request with designating the second type of interruption operation, the CPU suspends the program operation which is currently being executed, inhibits the contents of the program counter and status register from being varied, and then transfers the converted data to the destination area without saving the contents of the program counter and status register and with holding them as they are. After the converted data is transferred to the destination area, the CPU allows the program counter and status register to change to resume the suspended program operation. The second type of interruption operation is also called "macro service operation". According to the macro service operation, the above-mentioned overheads are not required, so that the execution efficiency and processing capability of the CPU are enhanced remarkably. However, the above publication merely discloses the macro service operation for a single analog input channel. Some systems are required to process a plurality of analog input channels, and two or more channels thereof are simultaneously subjected to the conversion request to perform a desired operation. SUMMARY OF THE INVENTION Therefore, an object of the present invention is to provide a microcomputer performing a macro service operation for a plurality of analog input channels. Another object of the present invention is to provide a data processor which can transfer the converted data of plural analog input channels to respective destination areas in a data memory without intervention of any user's program operation. Still another object of the present invention is to provide an improved data processor including an A/D converter for a plurality of analog inputs. A data processor according to the present invention is characterized in claim 1. Thus, the A/D conversion for a plurality of analog inputs can be designated and reserved simultaneously, and the execution of the A/D conversion of the respectived designated analog inputs and the transfer of the respective converted data can be performed in a sequential manner by the macro service operation without intervention of any user's program and without any overhead. 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 an embodiment of the present invention; Fig. 2 is a block diagram representative of an A/D converter shown in Fig. 1; Fig. 3 is a flow chart representative of a macro service operation performed by a microcomputer shown in Fig. 1; Fig. 4 is a block diagram representative of another embodiment of the present invention; Fig. 5 is a flow chart representative of a macro service operation performed by a microcomputer shown in Fig. 4; and Fig. 6 is a circuit diagram representative of a converted-data operation controller shown in Figs. 1 and 4. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Referring to Fig. 1, a microcomputer 1000 according to an embodiment of the present invention includes a CPU (Central Processing Unit) 100. A program to be executed by the CPU 100 is stored in a program memory 200. This program includes a main operation routine and one or more interruption operation routines and is made up by a user of the microcomputer 100. The CPU 100 includes a program counter (PC) 101 indicating an address of an instruction to be executed in the program of the program memory 200, an instruction register (IR) 105 stored with an instruction read from the program memory 200, an instruction decoder (ID) 106 decoding the instruction from the IR 105 and producing various control signals, an execution control unit 107 responding to the control signals from the ID 106 to control the whole operation of the microcomputer 1000, an arithmetic and logic unit (ALU) 103 performing an arithmetic and/or logic operation, a status register (PSW) 104 storing information representative of an execution condition of the CPU 100, and a general purpose register set 102, which are interconnected via an address/data bus 600. The execution control unit 107 includes a micro-ROM (Read Only Memory) 1071 and a pointer 1072 pointing out an address of the micro-ROM 1071. The micro-ROM 1071 stores a microprogram consisting of a string of microinstructions for a macro service operation which will be described later in detail. Through the address/data bus 600, a data memory 300, an A/D converter 400 and a converted-data operation controller 500 are also interconnected. The A/D converter 400 includes a start flag 401, a converted result register (CRR) 402 and a selection data register (ASR) 403 and starts to execute the A/D conversion when the start flag 401 is set. The A/D converter 400 is supplied with eight channels of analog inputs 400-1 to 400-8, one of which is selected in response to the selection data stored in the ASR 403. The converted digital data of the selected analog input is stored into the CRR 402. When the A/D conversion is completed, the A/D converter 400 generates a completion signal 400-9 which is in turn to the converted-data operation controller 500. In this embodiment, one of the analog inputs 400-1 to 400-8 is selected in response to the selection data of the ASR 403 as shown in the following TABLE: Although A/D converters of various types are proposed and put into a practical use, an A/D converter of the sequential comparison type is shown in Fig. 2 as one example. The A/D converter 400 of this type further includes a selector 404, a sample/hold circuit 405, a comparator 406, a comparison voltage generater 407, a sequential comparison register 408 and a controller 410, as well know in the art. The controller 410 starts the A/D converting operation when the start flag 401 is set, and generates the completion signal 400-9 when the converted digital data is stored into the CRR 402. The further detailed description on the A/D converter of that type will be omitted since the circuit operation thereof is well-known in the art. Turning back to Fig. 1, the completion signal 400-9 supplied to an operation request until 501 of the controller 500. This unit 501 includes a mode flag 502 for designating either one of a macro service operation and an interruption operation on the converted digital data and a channel pointer address register (ACPTR) 503 storing an address of a channel pointer (CPTR) 302 which will be described later. In response to the completion signal 400-9, the operation request unit 501 supplies an operation request signal 500-1 and an operation mode designation signal 500-2 to a request receiving unit 504. In case of designating the macro service operation, the made flag 502 is set to store the data of "1" and the mode designation signal 500-2 takes a high level (logic-1). In case of designating the interruption operation, on the other hand, the mode flag 502 is reset to store the data of "0" and the signal 500-2 takes a low level (logic-0). Since the mode flag 502 can be made access, the user can designate the operation mode to the macro service operation or the interruption operation. The request receiving unit 504 responds to the request signal 500-1 and detects the level of the mode designation signal 500-2. When the signal 500-2 is of the high level, the unit 504 transfers a macro service code stored in a register 505 to the instruction register (IR) 105 via an operation request bus 507. On the other hand, when the signal 500-2 is of the low level, an interruption code stored in a register 506 is transferred to the IR 105 via the bus 507. The interruption code includes a vector address for an interruption program routine stored in the program memory 200. The registers 503, 505 and 506 are inhibited from being accessed by the user. The data memory 300 includes a stack area 301 into which the contents of PC 101, PSW 104 and register set 102 are saved in response to the interruption operation request, eight destination areas (DST1 to DST8) 304 to 311 to which the converted digital data of the analog inputs 400-1 to 400-8 are respectively transferred, a converted channel register (ACR) 303 storing channel designation data for designating one or more analog inputs to be converted, and a channel pointer (CPTR) 302 storing an address of the ACR 303. The ACR 303 has an 8-bits construction, and the respective bits thereof correspond to the respective ones of the analog inputs 400-1 to 400-8. Therefore, when the A/D conversion of the first, fifth and seventh analog inputs 400-1, 400-5 and 400-7 is requested, for example, the data of "10001010" is set into the ACR 303. In this embodiment, the address of the ACR 303 can be selected by the user, but the ACR 303 and the destination areas 304 to 311 are allotted to consecutive addresses, respectively. The address of the CPTR 302 is fixed. Next, description on an operation of the microcomputer 1000 will be made in the following. Instructions for the program stored in the memory 200 are read out and executed sequentially by the CPU 100 using the PC 101. By executing an instruction for storing data into the ACR 303 and an instruction for storing data into the CPTR 302, the ACR 302 is stored with the channel designation data in which bit or bits corresponding to the analog input or inputs to be converted are set to "1" and the CPTR 302 is stored with the address of the ACR 302. In order to designate the macro service operation, the mode flag 502 is set to "1" by an instruction from the memory 200. When an instruction for setting the start flag 401, i.e. conversion start instruction, is read from the memory 200 and executed by the CPU 100, the selection data responsive to the channel designation data of the ACR 303 is stored into the ASR 403 and the start flag 401 is set. In this embodiment, the conversion priority order of the first to eight analog inputs 400-1 to 400-8 is designed to be in that order. Assuming that the ACR 303 stores the channel designation data of "10001010", therefore, the selection data of "000" for selecting the first analog input 400-1 is set into the ASR 403. Thus, the A/D converter 400 selects the first analog input 400-1 and starts the A/D converting operation. The access to the program memory 200 is allowed during the converting operation by the A/D converter 400. Accordingly, the CPU 100 continues to perform the subsequent operations is parallel to the operation of the A/D converter 400. When the conversion of the first analog input 400-1 is completed, the A/D converter 400 generates and applies the completion signal 400-9 to the operation request unit 501. The converted digital data is stored in the CRR 402. The unit 501 thereby produces the request signal 500-1 with the mode designation signal 500-2 being the high level, since the mode flag 502 is in the set condition. In response thereto, the request receiving unit 504 transfers and sets the macro service code of the register 505 to the IR 105 via the bus 507. The macro service code is decoded by the ID 106 and supplied to the execution control unit 107. As a result, the execution control unit 107 produces and applies a hold signal 107-1 to the PC 101, PSW 104 and the register set 107 to inhibit the contents thereof from being varied and to hold the current contents thereof as they are. Further, the pointer 1072 is set with a leading address of the microprogram for the macro service operation stored in the micro-ROM 1071, so that the macro service operation starts to be executed. Thus, the CPU 100 suspends the program operation and then performs the macro service operation without saving the contents of the PC 101, PSW 104 and register set 102 and with holding the current contents thereof as they are. The macro service operation is performed in accordance with the flow chart shown in Fig. 3. Since the ACPTR 503 of the operation request unit 501 stores the address of the CPTR 302, the execution control unit 107 makes access to the CPTR 302 to read the content thereof by use of the address stored in the ACPTR 503 (Step 30). The content of the CPTR 302 indicates the address of the ACR 303, and the destination areas 304 to 311 are allotted respectively to the consecutive addresses from the address next the address of the ACR 303. That is, the address of the destination area to be transferred with the converted digital data is equal to the address obtained by adding the content of the ASR 403 plus 1 to the address of the ACR 303. Therefore, the execution unit 107 adds the content of the ASR 403 plus 1 to the content of the CPTR 302 by using the ALU 103 (Step 31). Since the content of the ASR 403 is "000", the added result is equal to the address of the first destination area (DST1) 403. The execution control unit 107 makes access to the area 403 by use of the added result to transfer the converted digital data of the first analog input 400-1 to the first destination area 304 from the CRR 402 (Step 32). Thereafter, the execution control unit 107 makes access again to the CPTR 302 by use of the content of the ACPTR 503 (Step 33) and then makes access to the ACR 303 by use of the content of the CPTR 302 (Step 34). Since the converted digital data has been already transferred to the associated destination register, the execution control unit 107 resets the bit of the channel designation data of the ACR 303, which bit position corresponds to the content of the ASR 403 (Step 35). The channel designation data is thereby changed "00001010". The execution control unit 107 thereafter scans the content of the ACR 303 from the least significant bit (LSB) thereof by using the ALU 103 (Step 36) and detects whether or not another bit set to "1" is present in the channel designation data (Step 37). Since the fifth bit is set to "1", the position data thereof, "100", is set into the ASR 403 as new selection data by the unit 107 (Step 38). The A/D converter is thereby initialized and then selects the fifth analog input 400-5 to start the A/D conversion. On the other hand, an access-enable command to the program memory 200 is produced (Step 40), so that the hold signal 107-1 is withdrawn. The PC 101, PSW 104 and register set 102 are thereby allowed to change the contents thereof so the CPU 100 restarts to read and execute the instructions from the program memory 200. Thus, the macro service operation responsive to the completion signal 400-9 is completed and the CPU resumes the suspended program operation. When the A/D conversion of the fifth analog input 400-5 is completed, the signal 400-9 is generated again. In response thereto, the CPU 100 suspends the program operation with holding the contents of the PC 101, PSW 104 and register set 102 as they are and then performs the macro service operation. The converted digital data of the fifth analog input 400-5 is thereby transferred to the fifth destination area (DST 5) 308. The A/D conversion of the seventh analog input 400-7 is then started, and the CPU 100 restarts to execute the suspended program operation. In the macro service operation for the converted digital data of the seventh analog input 400-7, the channel designation data of the ACR 303 is changed to all "0" by the execution of Step 35, so that it is detected that the content of the ACR 303 is all "0" in Step 37. Accordingly, the execution control unit 107 resets the start flag 401 of the A/D converter 400 to bring the converter 400 into a standby condition. Thus, only by setting the start flag 401 in the set state of the mode flag 502, the transfer of the converted digital data to the corresponding destination area and the A/D conversion operation of the remaining analog input or inputs are performed automatically by the macro service operation. Accordingly, the user is free from making up the interruption operation program for those operations, and moreover there is no overhead base on the starting and completion of the interruption operation program. By checking the content the of the ACR, it can be detected which one of the designated analog inputs has been already converted and whether or not all the designated analog inputs have been already converted. Moreover, since the CPU 100 executs the program operation in parallel to the converting operation by the A/D converter 400, the correction, change, addition or reservation of the analog input to be converted can be carried out arbitrarily. All of those operations can be performed in the main program routine, so that no interruption program routine is required. On the other hand, when the completion signal 400-9 is generated in the reset state of the mode flag 502, the operation request unit 501 produces the request signal 500-1 with the low level mode designation signal 500-2. Accordingly, the request receiving unit 504 sets the interruption code 506 to the IR 105. In response thereto, the execution control unit 107 saves the contents of the PC 101, PSW 104 and register set 102 into the stack area 301 of the data memory 300 and thereafter sets into the PC 101 the vector address for the interruption program routine. The CPU 100 thereby executes the interruption operation in accordance with the interruption program routine. When the interruption operation is completed, the saved contents are returned respectively to the PC 101, PSW 104 and register set 102 from the stack area 301, and the suspended main program routine is restarted. Referring to Fig. 4, there is shown a microcomputer 1000′ according to another embodiment of the present invention, wherein the same constituents as those shown in Fig. 1 are denoted by the same reference numerals to omit further description thereof. In this embodiment, a memory pointer (MPTR) 320 is provided at an address next the address of the ACR 300, and the address of the first destination area (DST1) 304 is stored in the MPTR 320. Therefore, the address of the destination areas 304 to 311 can be designed independently of the address of the ACR 303. The macro service operation in this microcomputer 1000′ is basically the same as that shown in Fig. 3, but due to the presence of the MPTR 320, Steps 31-1, 31-2 and 31-3 are executed in place of Step 31 of Fig. 3, as shown in Fig. 5. More specifically, by Step 31-1, the content of the CPTR 302 is incremented by one by using the ALU 103. Since the incremented result is equal to the address of the MPTR 320, the MPTR 320 is made access by use of the incremented result (Step 31-2), and the content of the MPTR 320 is added with the content of the ASR 403 by using the ALU 103 (Step 31-3). The added result is equal to the address of the destination area to be transferred with the converted digital data. The Steps 32 to 40 are thereafter executed in the same manner as shown in Fig. 3. The MPTR 320 can take two or more bytes, so that the destination areas 304 to 311 can be allotted to arbitrary addresses of the data memory 300. Referring to Fig. 6, there is shown a circuit construction representative of one example of the converted-data operation controller 500 shown in Figs. 1 and 4, wherein the ACPTR 503 is omitted in order to avoid the complication of the drawing. When the conversion completion signal 400-9 is generated, a flip-flop (called hereinafter an "F/F") 510 is set and the Q-output thereof is supplied to the execution control unit 107 as an operation request control signal 500-10. The execution control unit 107 produces an acknowledge signal 107-2 after a current instruction is completed to be executed, so that an F/F 513 is set through an AND gate 511. The Q-output of the F/F 513 is used as the operation request signal 500-1. The leading edge of this signal is detected by a detector 510 to reset the F/F 510. The F/F 510 thereby waits for the next conversion completion signal 400-9. On the other hand, the signal 500-1 activates a tri-state buffer 514, so that the content of the mode flag 502 is read out therefrom. The signal 500-1 is further supplied to AND gates 515 and 518. The AND gate 515 further receives the content of the mode flag 502, whereas the AND gate 518 receives the inverted content of the mode flag 502 by an inverter 517. Therefore, the AND gate 515 is opened by the set state of the mode flag 502, whereas the AND gate 518 is opened by the reset state of the mode flag 502. In response to an operation code request signal 107-3 from the execution control unit 107, one of transfer gates 516 and 519 is thereby brought into an open state, so that the macro service operation code 505 or the interruption operation code 506 is outputted to the but 507. When the macro service operation or the interruption operation is completed, the execution control unit 107 produces an operation and signal 107-2 to reset the F/F 513. The buffer 514 and transfer gates 516 and 519 are thereby brought into a closed state. As described above, the data processor or microcomputer according to the present invention can be perform any one of the software interruption operation and the macro service operation is response to the A/D conversion completion signal, and moreover the macro service operation for a plurality of analog inputs is performed. The present invention is not limited the above embodiments, but may be changed and modified without departing from the scope and spirit of the invention. For example, the A/D converter 400 can be constructed to generate the conversion completion signal 400-9 with resetting the start flag 401 and in that case, a step for setting the start flag is inserted after Step 38 shown in Fig. 3 and Step 39 can be omitted. Moreover, the program memory 200 and the data memory 300 can be constructed by a single memory. The request receiving unit 504 may transfer the macro service code or the interruption code to the IR 105 via the address/data bus 600 in place of the bus 507.

Claims: A data processor comprising a program memory (200) storing a program, a central processing unit (100) including a program counter (101) indicating an address of said program memory storing an instruction to be executed and a status register (104) temporarily storing information representative of an execution state of said central processing unit and executing said program by use of said program counter and said status register, an analog-to-digital converter (400) supplied with a plurality of analog inputs (400-1 to 400-8) and including first storage means (403) for temporarily storing data for selecting one of said analog inputs, said analog-to-digital converter selecting one of said analog inputs in response to the data stored in said first storage means, converting the selected analog input into digital data and generating a completion signal (400-9) representative of completion of the analog-to-digital conversion operation, and means (500) responsive to said completion signal for supplying a macro service operation request (507) to said central processing unit, said central processing unit further including execution means responsive to said macro service operation request for suspending the execution of said program and for executing a macro service operation, said macro service operation being executed without saving contents of said program counter and said status register and with holding the contents thereof as they are, said execution means for executing said macro service operation including means (30-32) for transferring said digital data to a predetermined destination area (304-311) and means (40) for restarting change in contents of said program counter and said status register to allow said central processing unit to resume the suspended operation of said program after said digital data is transferred to said predetermined destination area, characterized in that said data processor further comprises a second storage means (303) for temporarily storing designation data for designating one or more analog inputs to be converted and that said execution means for executing said macro service operation further includes means (33-37) for detecting said designation data stored in said second storage means to accordingly produce new selection data for selecting an analog input to be next converted and means (38) for setting said new selection data to said first storage means so that said analog-to-digital converter starts the conversion operation on the analog input selected by said new selection data. The processor as claimed in claim 1, characterized in that said destination data stored in said second storage means (403) consists of a plurality of bits, the respective ones of which correspond to the respective ones of said analog inputs, and that said detecting means includes means (35) for resetting the bit of said destination data corresponding to the converted analog input and means (36, 37) for judging whether or not another bit taking a set state is present in said destination data. The processor as claimed in claim 2, characterized in that said execution means (39) for executing said macro service operation further includes means for bringing said analog-to-digital converter into a standby condition when all the bits of said designation data take a reset state. The processor as claimed in claim 1, 2 or 3, characterized in that said predetermined destination area includes a plurality of storage areas (304-311) each provided for storing digital data of an associated one of said analog inputs.

Inventors: ISHIMOTO SATOMI C O NEC CORPOR, MATSUSHIMA OSAMU C O NEC CORPO, SAKUMA HAJIME C O NEC CORPORAT, ISHIMOTO, SATOMI C/O NEC CORPORATION, MATSUSHIMA, OSAMU C/O NEC CORPORATION, SAKUMA, HAJIME C/O NEC CORPORATION
Applicants: NIPPON ELECTRIC CO, NEC CORPORATION
Application year: 1988
Main classification: G06F3
IPC codes: G06F3