Abstract:
An inquiring apparatus and method thereof is provided for assisting the CPU to inquire the state of the peripheral device. First, stop outputting the clock to the CPU. Afterwards, output a read cycle to the peripheral device. Then, receive a current state of the peripheral device in response to the read cycle. Compare the current state with the expected state. Output the clock to the CPU again if the current state and the expected state are the same.

Description:
[0001]     This application claims the benefit of Taiwan application Serial No. 092124399, filed Sep. 3, 2003, the subject matter of which is incorporated herein by reference.  
       BACKGROUND OF THE INVENTION  
       [0002]     1. Field of the Invention  
         [0003]     The invention relates in general to an inquiring apparatus and method thereof, and more particularly to an inquiring apparatus, which can assist the central processor unit (CPU) to reduce its processing time and power consumption, and method thereof.  
         [0004]     2. Description of the Related Art  
         [0005]     A CPU is a high power-consuming element in electronic products. Even when the CPU is in a standby state, such as waiting for peripheral devices to be ready, it consumes power as operating according to the clock signals.  
         [0006]     As the CPU is in the standby state, there are two methods that the CPU can detect the current state of the peripheral device. One is called an interrupting method, in which the peripheral device automatically output an interrupting signal to the CPU. Before the peripheral device awakens the CPU, no clock is output to the CPU, so some power consumption is reduced. As the peripheral device detects an input event, such as the user operates the keyboard, the peripheral device will output an interrupting signal to wake up the CPU to perform the corresponding programs.  
         [0007]     Each interrupting signal is input to a different pin of the CPU. Since the number of the CPU pins is limited, the CPU cannot provide enough pins for a variety of peripheral devices.  
         [0008]     The other one is a repeatedly polling method, in which the CPU itself inquires the peripheral device repeatedly to determine if the peripheral device comes to an expected state.  
         [0009]     Referring to  FIG. 1 , a flow chart of the conventional repeatedly polling method is shown. First, the CPU reads the current state of the peripheral device in the step  110 . Afterwards, the CPU determines if the current state of the peripheral device agrees with the expected state in the step  120 . If it doesn&#39;t, wait for a period of time in the step  130 , such as execute the command NOP (No Operation), and then go back to the step  110 . If it does, the method is ended.  
         [0010]     However, as described in the repeatedly polling method, even in the standby state, the CPU has to work and the clock has to be continuously output to the CPU. The CPU has to inquire the peripheral device repeatedly until the peripheral device comes to the expected state. Therefore, such inquiring method will not only waste the CPU&#39;s processing time but also be power consuming.  
       SUMMARY OF THE INVENTION  
       [0011]     It is therefore an object of the invention to provide a power-saving repeatedly inquiring apparatus, which can repeatedly inquire the peripheral device instead of the CPU and awaken the CPU as it detects that the peripheral device is ready, and method thereof.  
         [0012]     The invention achieves the above-identified objects by providing an inquiring apparatus installed in an electronic apparatus. The electronic apparatus includes a CPU, a clock controller, a main bus, and a peripheral device. The peripheral device is coupled to the main bus. The inquiring apparatus includes a multiplexer and an awakening unit. The multiplexer selectively couples a first bus or a second bus with the main bus, and the first bus is coupled to the CPU. The awakening unit is coupled to the second bus. When the CPU has to perform the repeatedly inquiring process, the multiplexer couples the second bus with the main bus to enable the awakening unit, and the clock controller stops outputting the clock to the CPU. When the awakening unit is enabled, it will inquire about the current state of the peripheral device repeatedly. And when the current state agrees with the expected one, the awakening unit outputs an awakening signal to the clock controller so as to output the clock to the CPU again.  
         [0013]     The invention achieves the above-identified objects by providing an inquiring method for assisting the CPU to repeatedly inquire a peripheral device. The inquiring method includes the steps of: stopping outputting the clock to the CPU; outputting a read cycle to the peripheral device; receiving a current state of the peripheral device in response to the read cycle; and comparing the current state with the expected state.  
         [0014]     Other objects, features, and advantages of the invention will become apparent from the following detailed description of the preferred but non-limiting embodiments. The following description is made with reference to the accompanying drawings. 
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0015]      FIG. 1  is a flow chart of the conventional repeatedly polling method;  
         [0016]      FIG. 2  is a block diagram of the electronic apparatus having an inquiring apparatus according to a preferred embodiment of the invention;  
         [0017]      FIG. 3  is a block diagram of the awakening unit in  FIG. 2 ; and  
         [0018]      FIG. 4  is a flow chart of the repeatedly inquiring process performed in the electronic apparatus having the inquiring apparatus.  
     
    
     DETAILED DESCRIPTION OF THE INVENTION  
       [0019]     When the CPU should wait for the peripheral device to come to the expected state so as to perform the follow-up operation, conventionally, either the interrupting method or the repeatedly polling one is used to detect the state of the peripheral device. If the repeatedly polling method is used, the CPU doesn&#39;t perform other programs and just wastes time in repeatedly inquiring the current state of the peripheral device until the peripheral device comes to the expected state. Therefore, this method not only wastes the CPU&#39;s processing time but also is power consuming. In the invention, the low power-consuming inquiring apparatus is used instead of the CPU to perform the repeatedly inquiring process. As inquiring, no clock signal has to be output to the CPU. The CPU is awakened as the detected state of the peripheral device agrees with the expected state.  
         [0020]     Referring to  FIG. 2 , a block diagram of the electronic apparatus having an inquiring apparatus according to a preferred embodiment of the invention is shown. The electronic apparatus  200  includes a CPU  202 , a clock controller  204 , an inquiring apparatus  210 , and a peripheral device  220 . The clock controller  204  outputs the clock CLK to the CPU  202  for CPU operation. The CPU  202  communicates with the peripheral device  220  via the bus B 1 , the inquiring apparatus  210 , and the main bus B 0 .  
         [0021]     When the CPU  202  has to inquire the current state of the peripheral device, the inquiring apparatus  210  is actuated to perform the repeatedly inquiring process instead of the CPU  202 . At this time, the clock controller  204  stops outputting the clock signal CLK to the CPU  202  so as to save power. The inquiring apparatus  210  inquires the current state of the peripheral device  220  via the main bus B 0 , and outputs an awakening signal W to the clock controller  204  as the peripheral device  220  comes to the expected state. As the clock controller  204  receives the awakening signal W, it will output the clock signal CLK to the CPU  202  again. When the CPU  202  has not to perform the repeatedly inquiring process, the inquiring apparatus  210  is disabled and just transmits signals between the bus B 1  and the main bus B 0 .  
         [0022]     The inquiring apparatus  210  includes an awakening unit  212  and a multiplexer  214 , which is coupled to the awakening unit  212  via the bus B 2 . When the CPU  202  has not to perform the repeatedly inquiring process, the multiplexer  214  couples the bus B 1  with the bus B 2 . When the CPU  202  has to inquire the current state of the peripheral device, the multiplexer  214  couples the bus B 2  with the main bus B 0 , and then the awakening unit  212  inquires the current state of the peripheral device  220 . When the peripheral device  220  comes to the expected state, the awakening unit  212  outputs an awakening signal W to the clock controller  204 .  
         [0023]     Referring to  FIG. 3 , a block diagram of the awakening unit in  FIG. 2  is shown. The awakening unit  212  includes a bus interface  310 , an address register  320 , a comparator  330 , and a state register  340 . The bus interface  310  transmits and receives signals on the bus B 2 . The address register  320  stores the address of the peripheral device  220  by which the inquiring apparatus  210  can repeatedly inquire the current state of the peripheral device  220 . The state register  340  stores the expected state of the peripheral device  220 . The comparator  330  compares the current state of the peripheral device  220  output by the bus interface  310  with the expected state in the state register  340 , and determines if two states are the same. If two states are the same, the awakening unit  212  outputs an awakening signal. The awakening unit  212  is not limited to the logic circuit construction as mentioned above, and can be a simple and power-saving processor.  
         [0024]     Referring to  FIG. 4 , a flow chart of the repeatedly inquiring process performed in the electronic apparatus having the inquiring apparatus is shown. When the CPU  202  has to wait for the peripheral device  220  to come to the expected state for follow-up operation, the CPU  202  stores the address of the peripheral device  220  into the state register  310  and stores the expected state of the peripheral device  220  into the state register  340 . In the step  410 , the clock controller  204  stops outputting the clock CLK to the CPU  202 , and thus power for outputting the clock CLK at that time can be saved. Afterwards, in the step  420 , the multiplexer  214  couples the bus B 2  with the main bus B 0 , and the awakening unit  212  outputs a read cycle according to the address register  320 . In the step  430 , after receiving the read cycle, the peripheral device provides its current state for the awakening unit  212 . In the step  440 , the comparator  330  in the awakening unit  212  determines if the current state of the peripheral device agrees with the expected state in the state register  340 . If it does, the awakening unit  212  outputs an awakening signal W in the step  440 , and the method is ended. If it doesn&#39;t, the approach goes back to the step  420  and continues the inquiring process.  
         [0025]     The inquiring apparatus disclosed by the above-mentioned embodiment in the invention can perform the repeatedly inquiring process instead of the CPU. Since the CPU doesn&#39;t work in the inquiring process, power consumption can be reduced.  
         [0026]     While the invention has been described by way of example and in terms of a preferred embodiment, it is to be understood that the invention is not limited thereto. On the contrary, it is intended to cover various modifications and similar arrangements and procedures, and the scope of the appended claims therefore should be accorded the broadest interpretation so as to encompass all such modifications and similar arrangements and procedures.