Abstract:
A near full duplex portable handset speakerphone comprises: a microprocessor; a hands-free receive register connected to the microprocessor; a hands-free transmit register connected to the microprocessor; a ROM having a speakerphone operation algorithm, the ROM-connected to the microprocessor; a first analog-to-digital converter connected to the hands-free receive register; a second analog-to-digital converter connected to the hands-free transmit register; a first programmable digital attenuator connected to the microprocessor and to a speaker; and a second programmable digital attenuator connected to the microprocessor and to a microphone, wherein near full duplex communication is achieved without digital signal processing. In another feature of the invention, the hands-free registers provide a digital representation of the speech volume in each direction to the microprocessor. The microprocessor monitors the speech signal levels, calculates digital volume comparisons in order to make speech gain decisions for optimal sound, and digitally adjusts the gains in the two speech paths to the upper half of their maximum values.

Description:
RELATED PATENT DOCUMENTS  
       [0001]     This is a continuation of patent application Ser. No. 08/699,844, filed on Aug. 20, 1996 (LEGR.121US01), to which Applicant claims priority under 35 U.S.C. § 120 for common subject matter, and which is fully incorporated herein by reference. 
     
    
     BACKGROUND  
       [0002]     The invention relates to wireless speakerphones, and more particularly, to a microprocessor-controlled full-duplex speakerphone using automatic gain control. There are two basic types of speakerphones available on the market today: A lower-cost, half-duplex design aimed at the consumer market; and an expensive full-duplex DSP implementation for business applications. The major technical obstacle to overcome in designing a speakerphone is the prevention of unstable feedback (howling, or squealing) caused by adjusting the speaker and/or microphone gains too high. The first solution to this problem was the half-duplex speakerphone.  
         [0003]     In the receive direction (the far-end person is heard via the speaker), it is obviously desirable to provide a relatively large gain on the speaker, but due to the proximity of the microphone to the speaker in the speakerphone enclosure, the microphone will detect the far-end person&#39;s voice and amplify it back to the far-end. This acoustic coupling is the source of half of the feedback loop in the speakerphone, and results in an annoyingly high level of sidetone in the far-end handset. To mitigate this acoustic coupling, the half-duplex speakerphone reduces the gain of the microphone to its minimum when the far-end person is talking, so that none of the far-end person&#39;s voice is returned back.  
         [0004]     In the transmit direction (the near-end person speaks into the microphone), it is obviously desirable to provide a relatively large gain on the microphone to allow greater distances between the person speaking and the microphone. However, due to the electrical connection of the microphone to the telephone lines (via the 2-wire to 4-wire hybrid interface), a part of the transmitted voice signal is reflected back into the RX speech path, which is then amplified by the speaker driver with the result that the near-end person&#39;s own voice is amplified into the room. This hybrid sidetone is the second half of the feedback loop in the speakerphone, and is the natural way typical telephone handsets provide sidetone from microphone to the earpiece (the microphone gain contributes to the sidetone level). To mitigate this hybrid sidetone, the half-duplex speakerphone reduces the gain of the speaker to its minimum when the near-end person is talking, so that none of the near-end person&#39;s voice is amplified into the same room.  
         [0005]     Whenever the microphone and speaker gains are not balanced in this “see-saw” minimum/maximum way, the familiar acoustic feedback sound (howling, squealing) can easily result from the completed feedback loop provided by the acoustic coupling and hybrid sidetone audio paths. This “see-saw” gain adjustment process requires the speakerphone to determine which person is talking, and it must arbitrate the two signal paths accordingly. These functions are typically provided by an expensive analog voice-switched speakerphone chip, but the arbitration typically suffers from several basic disadvantages:  
         [0006]     The speakerphone gives priority to the loudest person speaking when both people are attempting to speak simultaneously, for example, when one person is trying to interrupt the other. This is a disadvantage for the case of a weak signal from a distant phone, or from a person who is not sitting very close to the speakerphone. In these cases it may be necessary for the far-end person to unnaturally shout into the handset, or for a person at the far end of the table, to temporarily move closer to the speakerphone.  
         [0007]     The slow switching time during this volume comparison usually results in the loss of a few syllables at the beginning of the interruption, which generally results in the person having to repeat the whole sentence.  
         [0008]     The full-duplex DSP-based speakerphone implements robust signal cancellation of the two speech paths to eliminate the coupling of the two channels. As a result, the microphone and speaker gains can be maintained at high levels throughout the conversation, thus eliminating the voice switching altogether. However, this high quality demands a high price because 1) it requires a powerful DSP engine capable of performing these calculations on both speech paths at the 8 kHz sample rate, and 2) the algorithm requires considerable DSP and audio experience.  
         [0009]     The user-controlled volume setting is typically implemented in hardware in an analog speakerphone via a potentiometer, but suffers from degraded audio quality over time due to dust in the potentiometer mechanism and DC offset drift. Typical cordless phone designs house the speakerphone function in the base station. The disadvantage of this configuration is the obvious one: the speakerphone functions are limited by the length of the wires connecting the base station to the telephone jack and to the power.  
         [0010]     In view of the foregoing, what is needed is a speakerphone which allows a full-duplex conversation, i.e., simultaneous speaking and hearing, without an external analog speakerphone chip and a DSP engine, without external analog decoders with resistor ladders for providing gain, and without using a potentiometer for user-controlled volume control. Furthermore, the speakerphone functions should be housed in the portable handset.  
       SUMMARY  
       [0011]     A near full duplex portable handset speakerphone comprises: a microprocessor; a hands-free receive register connected to the microprocessor; a hands-free transmit register connected to the microprocessor; a ROM having a speakerphone operation algorithm, the ROM connected to the microprocessor; a first analog-to-digital converter connected to the hands-free receive register, a second analog-to-digital converter connected to the hands-free transmit register; a first programmable digital attenuator connected to the microprocessor and to a speaker; and a second programmable digital attenuator connected to the microprocessor and to a microphone, wherein near full duplex communication is achieved without digital signal processing.  
         [0012]     In another feature of the invention, the hands-free registers provide a digital representation of the speech volume in each direction to the microprocessor. The microprocessor monitors the speech signal levels, calculates digital volume comparisons in order to make speech gain decisions for optimal sound, and digitally adjusts the gains in the two speech paths to the upper half of their maximum values.  
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0013]      FIG. 1  is a block diagram of a wireless speakerphone system  10  built according to the present invention.  
         [0014]      FIG. 2  is a diagram of the state machine  60  of the speakerphone algorithm  41 , showing timer-controlled state transitions.  
         [0015]      FIG. 3  is a flow chart of the algorithm for the peak detector  70  of the speakerphone algorithm.  
         [0016]      FIG. 4  is a flow chart of the algorithm for the idle state  68  of the speakerphone algorithm.  
         [0017]      FIG. 5  is a flow chart of the algorithm for the RX state  62  of the speakerphone algorithm.  
         [0018]      FIG. 6  is a flow chart of the algorithm for the TX state  64  of the speakerphone algorithm.  
         [0019]      FIG. 7  is a flow chart of the algorithm for the full-duplex state  66  of the speakerphone algorithm.  
         [0020]      FIG. 8  is a flow chart of the RX quantification routine  190  of the speakerphone algorithm.  
         [0021]      FIG. 9   a  is a flow chart of the RX gain adjustment routine  230  of the speakerphone algorithm.  
         [0022]      FIG. 9   b  is a flow chart of the RX AGC  231  of the speakerphone algorithm.  
         [0023]      FIG. 10  is a state diagram and table showing the substates within the full-duplex state  66 .  
         [0024]      FIG. 11  is a flow chart of the full-duplex substate initialization routine of the speakerphone algorithm.  
         [0025]      FIG. 12  is a diagram showing the mapping of the RX and TX volume levels.  
         [0026]      FIGS. 13   a  and  13   b  are flow charts of the routine by which the mapping of  FIG. 12  is determined.  
         [0027]      FIG. 14  is block diagram of a first alternate embodiment, having the speakerphone in the base station.  
         [0028]      FIG. 15  is block diagram of a second alternate embodiment.  
     
    
     DETAILED DESCRIPTION  
       [0029]     In  FIG. 1 a  wireless speakerphone system  10 , built according to the present invention, uses a pair of integrated circuit controller chips  12 ,  14  to provide a digital wireless voice link between a portable handset  16  and a base station  18 . A signal  20  from a far-end telephone  22  is received by a PBX or a telephone central office  24 . The office  24  transmits the signal  20  to the base station  18 . In addition to the controller chip  12  mentioned above, the base station  18  also includes a hybrid  26 , which is a telephone line interface (a 2-wire to 4-wire hybrid interface). The controller chip  12  includes a codec  28 , which is a coder/decoder of signals. The codec  28  serves as the analog interface to the telephone line. The base station  18  further includes an RF  30 , which is a radio frequency interface.  
         [0030]     Referring now to the portable handset  16 , it includes the speakerphone functionality, rather than having such functionality included in the base station  18 . The user makes the usual decision to enable either the handset&#39;s earpiece and microphone (not shown in  FIG. 1 , or the “hands-free” speakerphone interface (consisting of blocks  50 ,  44 ,  48 ,  42  in  FIG. 1 ) for the telephone conversation. A codec  32  in the controller chip  14  handles the analog speakerphone interface. The controller chip  14  further includes an embedded hands-free receive register RX  34  and an embedded hands-free transmit register TX  36  in its speech paths.  
         [0031]     A microprocessor TP  38  controls the functioning of the controller chip  14 . A read-only memory ROM  40  houses a speakerphone algorithm  41 , not shown. A microphone Mic  42  picks up the speech of the user, and a speaker  44  delivers the far-end user&#39;s speech to the user of the portable handset  16 . A pre-amplifier PRE  46  provides programmable gain of either +3 dB or +18 dB. The amplifiers AMP  48 ,  50  external to the controller chip  14  are analog amplifiers. The AMP amplifiers (RX attenuation register  52  and TX attenuation register  54 ) internal to the controller chip  14  are programmable digital attenuators providing 0 dB to −42 dB gain, and mute. The portable handset  16  also includes a radio frequency interface RF  56 .  
         [0032]     Although hands-free registers exist in both of the identical controller chips  12  and  14 , hands-free registers in the controller chip  12  are not used, because the speakerphone algorithm executes solely in the portable handset  16 .  
         [0033]     The speakerphone algorithm  41  includes three sequential tasks performed by the on-chip TP  38 : reading the hands-free registers and determining the peak volume levels of both speech paths; executing a speakerphone state machine  60  (shown in  FIG. 2 ); and digitally adjusting the microphone and speaker gains as directed by the speakerphone state machine. The speakerphone algorithm  41  uses timers and peak detection as its two basic pillars. The timers are the first basic pillar which forms the foundation of the speakerphone algorithm  41 . The timers fall into three categories: a) a 125 Ts frame timer or variable, b) a 20 ms state machine variable, and c) a 160 ms hold variable and a 80 ms duplex variable. The 125 Ts frame variable is the only variable which is implemented in hardware. The 125 Ts frame variable generates a hardware interrupt to the TP  38  on every speech frame so that one of the hands-free registers  34 ,  36  can be read by a software peak detector.  
         [0034]     The 20 ms state machine variable is a RAM Sample_Counter variable which is implemented in the interrupt service routine for the 125 Ts frame variable. The RAM Sample_Counter variable is incremented by one each time the interrupt service routine is called (every 125 Ts), and when it reaches 160 (20 ms), the value is cleared and the Do_HF Boolean flag is set. This flag is polled by the main( ) wireless telephone control program, and when set, causes execution of the hands-free speakerphone algorithm  41 . Thus the speakerphone algorithm is executed once every 20 ms, which means that the peak detection window is 20 ms, and the speakerphone state machine  60  either remains in the same state or advances to a new state every 20 ms.  
         [0035]     The 160 ms hold variable is a software timer which is implemented inside the speakerphone state machine  60  by the use of a RAM Hold_Time variable. The RAM Hold_Time variable holds the state machine  60  in the current state before it enters the idle state, i.e., it adds a delay between the active RX, TX, or full-duplex states and the idle state. This empirically derived delay prevents the state machine  60  from jumping between the active states and the idle state during the short quiet gaps and pauses in normal speech. The Hold_Time variable is initialized to 160 ms upon entry into the RX, TX, and full-duplex states, and is used in conjunction with the duplex variable.  
         [0036]     The 80 ms software duplex timer is implemented inside the speakerphone state machine  60  by the use of a RAM Duplex_Time variable. The primary purpose of this variable is to prevent an abrupt change in duplex when both people are talking at (nearly) the same time. For example, it would be very undesirable for the speakerphone to oscillate between the RX and TX states when both people are talking. Instead the duplex variable holds the state machine  60  in the full-duplex state during the short quiet gaps and pauses in both people&#39;s normal speech. The Duplex_Time variable is initialized to 80 ms upon entry into the RX, TX and full-duplex states, and is used in conjunction with the hold variable as follows.  
         [0037]     Referring now to  FIG. 2 , the state machine  60  is a software routine which has memory of its past state, the current state, and its future states by means of state variables stored in RAM The state machine  60  makes its decisions by executing software instructions. Electronic state machines are either typically implemented in hardware (by flip-flops or latches) or in software (by a routine which operates on state variables stored in RAM). In the preferred embodiment, the state machine  60  is implemented in software. The inputs to the speakerphone state machine  60  are comprised of the peak volume levels of both speech paths together with the current microphone and speaker gain settings. The speakerphone state machine  60  compares the peak volume levels of both speech paths to pre-defined threshold levels, monitors the current microphone and speaker gain settings, and finally determines the optimum gain settings for the present volume levels. The speakerphone state machine  60  consists of 4 operating states: a RX  62 , a TX  64 , a full-duplex  66 , and idle state  68 .  
         [0038]      FIG. 2  shows how the Hold_Time variable and the Duplex_Time variable are used in conjunction to provide the state transition delays. Specifically, the hold and duplex variables are initialized to 160 ms and 80 ms respectively by loading the Hold_Time variable with a value of 8, and by loading the Duplex_Time variable with a value of 4. On each execution pass of the speakerphone state machine  60  (every 20 ms), both of these variables are either reloaded with their initial values, or one of them decremented by 1, depending on the decision made by the state machine  60 . If the state machine  60  detects sufficient volume in the RX and/or TX speech paths to enter or to remain in one of the active states (RX  62 , TX  64 , or full-duplex  66 ), both variables are reloaded with their initial values. If insufficient volume is present in the RX speech path, the duplex variable is decremented by 1 in preparation for the pending state transition to the TX state  64 . When the duplex variable is decremented to 0 (after 4 passes), the state machine  60  enters the TX state  64  and both variables are initialed. If insufficient volume is present in the TX speech path, the duplex variable is decremented by 1 in preparation for the pending state transition to the RX state  62 . When the duplex variable is decremented to 0 (after 4 passes), the state machine  60  enters the RX state  62  and both variables are initialed. If insufficient volume is present in both speech paths, the state machine  60  will enter an idle state  68  after both variables are decremented to 0: the duplex variable is decremented to 0 first (after 4 passes), then the hold variable is decremented by 1. When the hold variable is also decremented to 0, twelve total execution passes of the state machine  60  have elapsed, and the state machine  60  enters the idle state  68 .  
         [0039]     The peak detector algorithm  70  is the second basic pillar which forms the foundation of the speakerphone algorithm  41 . The most basic piece of information needed by the speakerphone algorithm  41  is the relative volume of the two speech paths. The transmit and receive speech paths of the controller  14  are conveyed by the codec  32 , whose sample rate is the standard frame rate of 8 kHz, so the hands-free registers  34 ,  36  are updated with fresh values every 125 Ts. Because these registers return the current digital magnitude of the two speech paths at the instant they are read, a software peak detector algorithm  70  is necessary to determine the maximum signal level during a given time.  
         [0040]     Referring now to  FIG. 3 , as previously described, in step  72  the 125 Ts frame variable generates the interrupts which cause the on-chip TP  38  to read one of the hands-free registers  34 ,  36  during the frame variable interrupt service routine. In step  74  a Boolean flag HF_Toggle is used to keep track of which hands-free register to read during alternating passes. The hands-free register RX  34  is read during one pass, and the hands-free register TX  36  is read during the next, so the sample rate for both registers is 250 Ts. If HF_Toggle=1 during an execution of the interrupt service routine, then in step  76  HF_Toggle is set equal to zero. In step  78  the TP  38  reads the hands-free register RX  34 , and in step  80  compares the value to the saved (peak) value stored in the RAM variable RX_Peak. If the fresh value is greater than the saved value, then in step  82  the fresh value is stored in RX_Peak for future use. In step  84 , the fresh value is discarded if it is less than or equal to the saved peak value. Likewise, if HF_Toggle=0 during an execution of the interrupt service routine, then in step  86  HF_Toggle is set equal to one. In step  88  the TP  38  reads the hands-free register TX  36 , and in step  90  compares the value to the saved (peak) value stored in the RAM variable TX_Peak. If the fresh value is greater than the saved value, then in step  92  the fresh value is stored in TX_Peak for future use. In step  94  the fresh value is discarded if it is less than or equal to the saved peak value. The RX and TX peak values are accumulated in this way over the whole Peak Detection Window, which is 80 samples at 250 ps each, or 20 ms.  
         [0041]     When the state machine  60  variable reaches  160  (20 ms), the Do_HF Boolean flag is set, and the TP  38  soon executes the hands-free state machine  60  which first copies the current values of RX_Peak and TX_Peak to separate RAM locations called RX_Max and TX_Max respectively (because RX_Peak and TX_Peak are continually updated by the frame variable interrupt service routine). These separate RAM locations are used for all subsequent volume level comparisons within the speakerphone algorithm  41 .  
         [0042]     Referring now to  FIG. 4 , after the telephone call is made and the connection is established, the speakerphone in step  100  begins in the idle state  68  because both speech paths are quiet, because neither person has started talking yet. This “quiet level” is defined in software as a background noise level threshold, and an independent threshold is assigned for the speakerphone-side and the far-end environments. As shown in  FIG. 2 , and in the idle state  68  flow chart in  FIG. 4 , the state machine  60  decides during the current cycle whether to remain in the idle state  68 , to enter the RX state  62 , or the TX state  64 , when the current cycle completes.  
         [0043]     In step  102  the TP  38  checks to see if the volume level received from the far-end (RX_Max) rises above the pre-defined background noise level (RX_Noise_Thresh). If so, the speakerphone state machine  60  assumes the far-end person has just begun to speak. If this volume level is greater than the near-end volume level (TX Max), then the speakerphone state machine  60  in step  104  will enter the RX state  62  when the current cycle completes. If both of these conditions are not met, then in step  106  the state machine  60  focuses on the TX speech path. If the near-end volume level (TX_Max) rises above the pre-defined background noise level (TX_Noise_Thresh), the speakerphone state machine  60  assumes the near-end person has just begun to speak. If this volume level is greater than the far-end volume level (RX_Max), then the speakerphone state machine  60  in step  108  will enter the TX state  64  when the current cycle completes. If both of these conditions are not met, then in step  110  the speakerphone state machine  60  remains in the idle state  68  until the next cycle, when the volume levels will be analyzed again.  
         [0044]     Referring now to  FIG. 5 , the RX state  62  is defined from the speakerphone&#39;s point of view as the state when the far-end person is talking but the person near the speakerphone is not talking. As shown in  FIG. 2  and in  FIG. 5 , the state machine  60  decides during the current cycle whether to remain the RX state  62 , or to enter the TX state  64 , the full-duplex state  66 , or the idle state  68  when the current cycle completes.  
         [0045]     Step  112  is the entry point for the RX state  62  algorithm. In step  114 , if the volume level received from the far-end (RX_Max) is still greater than the pre-defined background noise level (RX_Noise_Thresh), the speakerphone state machine  60  assumes the far-end person is still speaking. Then in step  116 , if the near-end volume level (TX_Max) exceeds the volume level received from the far-end (RX_Max) by a dynamic “both” level (Both_Thresh), the speakerphone state machine  60  assumes the near-end person has just begun to speak in addition to the far-end person, and in step  118  it will enter the full-duplex state when the current cycle completes. (Both_Thresh is detailed in a later section.) If the RX volume level exceeds the noise threshold, but insufficient TX volume is detected, then in step  120  the speakerphone state machine  60  remains in the RX state  62  until the next cycle, when the volume levels will be analyzed again.  
         [0046]     If the RX volume level does not exceed the noise threshold, then in step  122  the state machine  60  focuses on the TX Speech Path. In step  122 , if the TX volume level rises above the pre-defined background noise level (TX_Noise_Thresh), the speakerphone state machine  60  assumes the near-end person has just begun to speak and the far-end person has stopped. If the Duplex Variable has been decremented to 0, then in step  124  the speakerphone state machine  60  will enter the TX state  64  when the current cycle completes. If not, then in steps  126 ,  128  and  120  the duplex variable is decremented by 1 and the speakerphone state machine  60  remains in the RX state  62  until the next cycle. Thus the duplex variable imposes an 80 ms transition delay from the RX state  62  to the TX state  64 . The state delays are implemented by executing multiple passes through the state machine.  
         [0047]     The 80 ms delay from RX to TX state goes through the following steps:  
         [heading-0048]     step  112   
         [heading-0049]     step  114 : no  
         [heading-0050]     step  1 . 22 : no, TX_Max is greater, but Duplex Time=4 (initial value)  
         [heading-0051]     step  126 : no  
         [heading-0052]     step  128 : Duplex_Time=3  
         [heading-0053]     step  120   
         [heading-0054]     (wait 20 ms, re-execute state machine)  
         [heading-0055]     step  112   
         [heading-0056]     step  114 : no  
         [heading-0057]     step  122 : no, TX_Max is greater, but Duplex_Time=3  
         [heading-0058]     step  126 : no  
         [heading-0059]     step  128 : Duplex Time=2  
         [heading-0060]     step  120   
         [heading-0061]     (wait 20 ms, re-execute state machine)  
         [heading-0062]     step  112   
         [heading-0063]     step  114 : no  
         [heading-0064]     step  122 : no, TX_Max is greater, but Duplex_Time=2  
         [heading-0065]     step  126 : no  
         [heading-0066]     step  128 : Duplex_Time=1  
         [heading-0067]     step  120   
         [heading-0068]     (wait 20 ms, re-execute state machine)  
         [heading-0069]     step  112   
         [heading-0070]     step  114 : no  
         [heading-0071]     step  122 : no, TX_Max is greater, but Duplex Time=1  
         [heading-0072]     step  126 : no  
         [heading-0073]     step  128 : Duplex_Time=0  
         [heading-0074]     step  120   
         [heading-0075]     (wait 20 ms, re-execute state machine)  
         [heading-0076]     step  112   
         [heading-0077]     step  114 : no  
         [heading-0078]     step  122 : yes, TX_Max is greater, Duplex_Time=0  
         [heading-0079]     step  124 : exit to TX state  
         [0080]     If neither the RX volume nor the TX volume level exceeds their respective noise thresholds, the speakerphone state machine  60  delays a total of 240 ms (12 passes) before entering the idle state  68 . This is accomplished in steps  126  to  134  by decrementing the duplex and hold variables during successive cycles of the speakerphone state machine  60 .  
         [0081]     The 240 ms delay from RX to Idle state goes through the following steps:  
         [heading-0082]     step  112   
         [heading-0083]     step  114 : no  
         [heading-0084]     step  122 : no, TX_Max not greater, and Duplex Time=4 (initial value)  
         [heading-0085]     step  126 : no  
         [heading-0086]     step  128 : Duplex Time=3  
         [heading-0087]     step  120  (wait 20 ms, re-execute state machine)  
         [heading-0088]     step  112   
         [heading-0089]     step  114 : no  
         [heading-0090]     step  122 : no, TX_Max not greater, Duplex_Time=3  
         [heading-0091]     step  126 : no  
         [heading-0092]     step  128 : Duplex_Time=2  
         [heading-0093]     step  120  (wait 20 ms, re-execute state machine)  
         [heading-0094]     step  112   
         [heading-0095]     step  114 : no  
         [heading-0096]     step  122 : no, TX_Max not greater, Duplex_Time=2  
         [heading-0097]     step  126 : no  
         [heading-0098]     step  128 : Duplex_Time=1  
         [heading-0099]     step  120  (wait 20 ms, re-execute state machine)  
         [heading-0100]     step  112   
         [heading-0101]     step  114 : no  
         [heading-0102]     step  122 : no, TX_Max not greater, Duplex_Time=1  
         [heading-0103]     step  126 : no  
         [heading-0104]     step  128 : Duplex Time=0  
         [heading-0105]     step  120   
         [heading-0106]     (wait 20 ms, re-execute state machine)  
         [heading-0107]     step  112   
         [heading-0108]     step  114 : no  
         [heading-0109]     step  122 : no, TX_Max not greater, Duplex_Time=0  
         [heading-0110]     step  126 : yes  
         [heading-0111]     step  130 : no, Hold_Time still=8 (initial value)  
         [heading-0112]     step  132 : Hold_Time=7  
         [heading-0113]     step  120   
         [heading-0114]     (wait 20 ms, re-execute state machine)  
         [heading-0115]     step  112   
         [heading-0116]     step  114 : no  
         [heading-0117]     step  122 : no, TX_Max not greater, Duplex_Time=0  
         [heading-0118]     step  126 : yes  
         [heading-0119]     step  130 : no, Hold_Time=7  
         [heading-0120]     step  132 : Hold_Time=6  
         [heading-0121]     step  120   
         [heading-0122]     (wait 20 ms, re-execute state machine)  
         [heading-0123]     step  112   
         [heading-0124]     step  114 : no  
         [heading-0125]     step  122 : no, TX_Max not greater, Duplex_Time=0  
         [heading-0126]     step  126 : yes  
         [heading-0127]     step  130 : no, Hold_Time=6  
         [heading-0128]     step  132 : Hold_Time=5  
         [heading-0129]     step  120   
         [heading-0130]     (wait 20 ms, re-execute state machine)  
         [heading-0131]     step  112   
         [heading-0132]     step  114 : no  
         [heading-0133]     step  122 : no, TX_Max not greater, Duplex_Time=0  
         [heading-0134]     step  126 : yes  
         [heading-0135]     step  130 : no, Hold_Time=5  
         [heading-0136]     step  132 : Hold_Time=4  
         [heading-0137]     step  120   
         [heading-0138]     (wait 20 ms, re-execute state machine)  
         [heading-0139]     step  112   
         [heading-0140]     step  114 : no  
         [heading-0141]     step  122 : no, TX_Max not greater, Duplex_Time=0  
         [heading-0142]     step  126 : yes  
         [heading-0143]     step  130 : no, Hold_Time=4  
         [heading-0144]     step  132 : Hold_Time=3  
         [heading-0145]     step  120   
         [heading-0146]     (wait 20 ms, re-execute state machine)  
         [heading-0147]     step  112   
         [heading-0148]     step  114 : no  
         [heading-0149]     step  122 : no, TX_Max not greater, Duplex_Time=0  
         [heading-0150]     step  126 : yes  
         [heading-0151]     step  130 : no, Hold_Time=3  
         [heading-0152]     step  132 : Hold_Time=2  
         [heading-0153]     step  120   
         [heading-0154]     (wait 20 ms, re-execute state machine)  
         [heading-0155]     step  112   
         [heading-0156]     step  114 : no  
         [heading-0157]     step  122 : no, TX_Max not greater, Duplex_Time=0  
         [heading-0158]     step  126 : yes  
         [heading-0159]     step  130 : no, Hold_Time=2  
         [heading-0160]     step  132 : Hold_Time=1  
         [heading-0161]     step  120   
         [heading-0162]     (wait 20 ms, re-execute state machine)  
         [heading-0163]     step  112   
         [heading-0164]     step  114 : no  
         [heading-0165]     step  122 : no, TX_Max not greater, Duplex Time=0  
         [heading-0166]     step  126 : yes  
         [heading-0167]     step  130 : no, Hold_Time=1  
         [heading-0168]     step  132 : Hold_Time=0  
         [heading-0169]     step  120   
         [heading-0170]     (wait 20 ms, re-execute state machine)  
         [heading-0171]     step  112   
         [heading-0172]     step  114 : no  
         [heading-0173]     step  122 : no, TX_Max not greater, Duplex_Time=0  
         [heading-0174]     step  126 : yes  
         [heading-0175]     step  130 : yes  
         [heading-0176]     step  134 : exit to Idle State  
         [0177]     Referring now to  FIG. 6 , the TX state  64  is defined from the speakerphone&#39;s point of view as the state when the person near the speakerphone is talking but the far-end person is not talking. As shown in  FIG. 2  and in  FIG. 6 , the state machine  60  decides during the current cycle whether to remain in the TX state  64 , or to enter the RX state  62 , the full-duplex state  66 , or the idle state  68  when the current cycle completes.  
         [0178]     Step  140  is the entry point for the TX state  64  algorithm. In step  142 , if the near-end volume level (TX_Max) is still greater than the pre-defined background noise level (TX_Noise_Thresh), the speakerphone state machine  60  assumes the near-end person is still speaking. Then in step  144  if the volume level received from the far-end (RX-Max) exceeds the near-end volume level, the speakerphone state machine  60  assumes the far-end person has just begun to speak in addition to the near-end person, and in step  146  it will enter the Near Full-Duplex State when the current cycle completes. If the TX volume level exceeds the noise threshold but insufficient RX volume is detected, then in step  148  the speakerphone state machine  60  remains in the TX state  64  until the next cycle, when the volume levels will be analyzed again.  
         [0179]     In step  142 , if the TX volume level does not exceed the noise threshold, the state machine  60  focuses on the RX Speech Path. In step  150 , If the RX volume level rises above the pre-defined background noise level (RX Noise_Thresh), the speakerphone state machine  60  assumes the far-end person has just begun to speak and the near-end person has stopped. If the duplex variable has been decremented to 0, then in step  152  the speakerphone state machine  60  will enter the RX state  62  when the current cycle completes. If not, then in steps  154 ,  156 , and  148  the duplex variable is decremented by 1 and the speakerphone state machine  60  remains in the TX state  64  until the next cycle. Thus the duplex variable imposes an 80 ms transition delay from the TX state  64  to the RX state  62 .  
         [0180]     The state delays are implemented by executing multiple passes through the state machine. The 80 ms delay from TX to RX state goes through the following steps:  
         [heading-0181]     step  140   
         [heading-0182]     step  142 : no  
         [heading-0183]     step  150 : no, RX-Max is greater, but Duplex_Time=4 (initial value)  
         [heading-0184]     step  154 : no  
         [heading-0185]     step  156 : Duplex_Time=3  
         [heading-0186]     step  148   
         [heading-0187]     (wait 20 ms, re-execute state machine)  
         [heading-0188]     step  140   
         [heading-0189]     step  142 : no  
         [heading-0190]     step  150 : no, RX_Max is greater, but Duplex_Time=3  
         [heading-0191]     step  154 : no  
         [heading-0192]     step  156 : Duplex_Time=2  
         [heading-0193]     step  148   
         [heading-0194]     (wait 20 ms, re-execute state machine)  
         [heading-0195]     step  140   
         [heading-0196]     step  142 : no  
         [heading-0197]     step  150 : no, RX_Max is greater, but Duplex_Time=2  
         [heading-0198]     step  154 : no  
         [heading-0199]     step  156 : Duplex_Time=1  
         [heading-0200]     step  148   
         [heading-0201]     (wait 20 ms, re-execute state machine)  
         [heading-0202]     step  140   
         [heading-0203]     step  142 : no  
         [heading-0204]     step  150 : no, RX_Max is greater, but Duplex Time=1  
         [heading-0205]     step  154 : no  
         [heading-0206]     step  156 : Duplex_Time=0  
         [heading-0207]     step  148   
         [heading-0208]     (wait 20 ms, re-execute state machine)  
         [heading-0209]     step  140   
         [heading-0210]     step  142 : no  
         [heading-0211]     step  150 : yes, RX_Max is greater, Duplex_Time=0  
         [heading-0212]     step  152 : exit to RX state  
         [0213]     If neither the TX volume nor the RX volume level exceeds their respective noise thresholds, the speakerphone state machine  60  delays a total of 240 ms (12 passes) before entering the Idle state  68 . This is accomplished in steps  154  to  162  by decrementing the duplex and hold variables during successive cycles of the speakerphone state machine  60 .  
         [0214]     Referring now to  FIG. 7 , the speakerphone state machine  60  enters the full-duplex state whenever both people are simultaneously talking. As shown in  FIG. 2  and  FIG. 7 , the state machine  60  decides during the current cycle whether to remain in the Full-Duplex State, or to enter the TX or Idle state  68  when the current cycle completes. Once the speakerphone enters this state, it remains here until the far-end person stops talking, in which case the speakerphone returns to the Idle state  68 . The reason for this is because it is much simpler in practice to detect that the far-end person has stopped talking than to detect that the near-end person has stopped talking, due to the acoustic coupling of the speakerphone&#39;s speaker to its microphone.  
         [0215]     Step  170  is the entry point for the full-duplex state  66  algorithm. In step  172 , if the volume level received from the far-end (RX_Max) is still greater than the pre-defined background noise level (RX_Noise_Thresh), the speakerphone state machine  60  assumes the far-end person is still speaking, and therefore remains in the full-duplex state  66  until the next cycle, when the volume levels will be analyzed again.  
         [0216]     In step  172 , if the RX volume level does not exceed the noise threshold, the state machine  60  focuses on the TX Speech Path. In step  174 , if the TX volume level is still greater than the pre-defined background noise level RX_Noise_Thresh), the speakerphone state machine  60  assumes the near-end person is still speaking but the far-end person has stopped. If the duplex variable has been decremented to 0, then in step  176  the speakerphone state machine  60  will enter the TX state  64  when the current cycle completes. If not, in step  180  the duplex variable is decremented by 1, and the speakerphone state machine  60  remains in the full-duplex state  66  until the next cycle. Thus the duplex variable imposes an 80 ms transition delay from the full-duplex state to, the TX state  64 .  
         [0217]     The state delays are implemented by executing multiple passes through the state machine. The 80 ms delay from Full-Duplex state to TX state goes through the following steps:  
         [heading-0218]     step  170   
         [heading-0219]     step  172 : no  
         [heading-0220]     step  174 : no, TX_Max is greater, but Duplex_Time=4 (initial value)  
         [heading-0221]     step  178 : no  
         [heading-0222]     step  180 : Duplex_Time=3  
         [heading-0223]     step  188   
         [heading-0224]     (wait 20 ms, re-execute state machine)  
         [heading-0225]     step  170   
         [heading-0226]     step  172 : no.  
         [heading-0227]     step  174 : no, TX_Max is greater, but Duplex_Time=3  
         [heading-0228]     step  178 : no  
         [heading-0229]     step  180 : Duplex_Time=2  
         [heading-0230]     step  188   
         [heading-0231]     (wait 20 ms, re-execute state machine)  
         [heading-0232]     step  170   
         [heading-0233]     step  172 : no  
         [heading-0234]     step  174 : no, TX_Max is greater, but Duplex_Time=2  
         [heading-0235]     step  178 : no  
         [heading-0236]     step  180 : Duplex_Time=1  
         [heading-0237]     step  188   
         [heading-0238]     (wait 20 ms, re-execute state machine)  
         [heading-0239]     step  170   
         [heading-0240]     step  172 : no  
         [heading-0241]     step  174 : no, TX_Max is greater, but Duplex_Time=1  
         [heading-0242]     step  178 : no  
         [heading-0243]     step  180 : Duplex_Time=0  
         [heading-0244]     step  188   
         [heading-0245]     (wait 20 ms, re-execute state machine)  
         [heading-0246]     step  170   
         [heading-0247]     step  172 : no  
         [heading-0248]     step  174 : yes, TX_Max is greater, Duplex_Time=0  
         [heading-0249]     step  176 : exit to TX state  
         [0250]     If neither the RX volume nor the TX volume level exceeds their respective noise thresholds, the speakerphone state machine  60  delays a total of 240 ms (12 passes) before entering the idle state  68 . This is accomplished in steps  178  to  184  by decrementing the duplex and hold variables during successive cycles of the speakerphone state machine  60 .  
         [0251]     The final task of the speakerphone algorithm  41  is the digital adjustment of the microphone and speaker gains as directed by the speakerphone state machine  60 . The inputs to a gain adjustment routine  230  are the volume levels in the RX and TX speech paths (RX_Max and TX_Max) and the current state. The portable handset  16  implements fixed gain settings in the idle state  68  and in the TX state  64 , but Automatic Gain Control (AGC) is implemented in software in the RX state  62  and in the full-duplex state  66 . In all cases, the gain adjustment routine  230  selects the optimum gain settings for the present volume levels, based on a pre-defined correspondence of volume levels and gain settings, i.e., for any given combination of RX and TX volume levels, the optimum gain setting was experimentally determined during the development of the wireless speakerphone system  10 . Thus there is no guesswork or adapting process in the gain adjustment routine  230 ; it simply outputs one gain setting for the current volume inputs it receives during each time it is executed.  
         [0252]     The same inputs (and TX_Max) are given to the speakerphone state machine  60  as to the gain adjustment routine  230 . These inputs are copied from RX_Peak and TX_Peak prior to the execution of the speakerphone state machine  60 , and thus remain constant long after the end of the gain adjustment routine  230 . In addition, a routine RX AGC  231  requires the RX volume level to be quantified into several volume ranges, so this quantification is done by the RX quantification routine  190 , just after RX_Max and TX_Max are updated, and just before the speakerphone state machine  60  begins.  
         [0253]     All gain adjustments are accomplished simply by writing a gain coefficient value to the appropriate gain control register inside the controller chip  14 . There are three such registers used by the speakerphone algorithm  41 : the RX attenuation register  52 ; the TX attenuation register  54 ; and the microphone pre-amplification register  46 .  
         [0254]     Referring now to  FIG. 9   a , the gain adjustment routine  230 , entered at step  223 , does only one of four possible things, depending on the next speakerphone state: 
        (a) If the speakerphone state machine  60  just decided in step  224  that the next state to be entered is the idle state  68 , then in step  225  the gain adjustment routine  230  sets pre-determined speaker and microphone gains by simply writing the appropriate gain coefficient value to the gain control registers.     (b) If the speakerphone state machine  60  just decided in step  226  that the next state to be entered is the TX state  64 , then in step  227  the gain adjustment routine  230  sets pre-determined speaker and microphone gains by simply writing the appropriate gain coefficient value to the gain control registers.     (c) If the speakerphone state machine  60  decides in step  228  that the next state to be entered is the RX state  62 , then in step  232  the gain adjustment routine  230  executes the RX AGC  231  (shown in  FIG. 9   b ). (Note that the RX quantization routine  190  has already been executed by this time). T e RX quantification routine  190  stored the result of its RX volume comparisons in the RAM variable RX_Level, for later use by the RX AGC  231 . The RX AGC  231  uses the output of the RX quantification routine  190  (RX_Level) in order to decide the optimal gain coefficients to be written to the gain control registers.     (d) If in step  228  the speakerphone state machine  60  just decided that the next state to be entered is the full-duplex state  66 , the gain adjustment routine  230  executes the full-duplex AGC routine, entered at step  260 . The full-duplex AGC routine is shown in  FIG. 11 . Step  274  in  FIG. 11  causes immediate execution of the three AGC substates shown in  FIGS. 13   a  and  13   b:  1) if the substate=40/60, execution begins at step  280  in  FIG. 13   a;  or     2) if the substate=60/40, execution begins at step  282  in  FIG. 13   a;  or     3) if the substate=50/50, execution begins at step  302  in  FIG. 13   b.          
 
         [0261]     When the idle state  68  is entered, the gain adjustment routine  230  sets the RX gain to sets the TX gain to −9 dB, and sets the Pre-Amp gain to +18 dB. These gain settings are accomplished when the TP  38  writes the following coefficients to the gain control registers:  
                                                       Gain Control Register   Value Written   Gain Setting                           RX Attenuation 52   20 H     −12 dB           TX Attenuation 54   2D H      −9 dB           Mic. Pre-Amp. 46   90 H     +18 dB                      
 
         [0262]     In the RX state  62 , which is a half-duplex state, the speaker gain is controlled in software by Automatic Gain Control (AGC), and the microphone gain is significantly reduced. Here, the AGC keeps the RX volume level as loud as possible within the practical constraints imposed by the portable handset  16 .  
         [0263]     Referring now to  FIG. 8 , the purpose of an RX quantification routine  190  is to quantify the RX volume level into one of six volume ranges, and to pass this information to the gain adjustment routine  230  for use by the RX AGC  231 . This quantification is accomplished by comparing the RX volume level (RX-Max) to pre-defined volume levels (steps  194  to  202 ), and storing the result in the RAM variable RX_Level, as shown below. RX_Max has a maximum range of 00 H  to 7 F H .  
                                                       RX-Max   Value stored               Volume Range   in RX_Level   Step                           73 H  to 7F H     5   204           63 H  to 72 H     4   206           53 H  to 62 H     3   208           43 H  to 52 H     2   210           33 H  to 42 H     1   212           00 H  to 32 H     0   214                      
 
         [0264]     The RX quantification routine  190  also adjusts the value of Both_Thresh according to the RX volume level, in steps  216 ,  218 , and  220 . Both_Thresh represents the amount of energy that the TX volume must exceed the RX volume in order to exit the RX state  62  and enter the full-duplex state  66 , i.e., how loud the near-end person must speak in order for the speakerphone algorithm  41  to recognize that both people are simultaneously speaking. The reason why Both_Thresh is dynamic rather than a fixed value is directly related to the RX AGC  231 . At low RX volume levels, the RX AGC  231  will boost the RX signal as much as possible to allow the near-end person to hear better. Due to acoustic coupling, this amplification results in a strong signal at the microphone, so some means is needed to prevent the speakerphone algorithm  41  from misinterpreting this strong microphone signal as near-end speech. Conversely, at high RX volume levels, the RX AGC  231  does riot need to add much amplification in order for the signal to be heard well. In this case it would be undesirable to require the near-end person to shout at the speakerphone in order to enter the full-duplex state  66 , so some reasonable means is need to allow this state transition to occur. Therefore Both_Thresh is implemented to create a “cushion” of volume to determine when the near-end person is speaking simultaneously with the far-end person. At low RX volume levels, Both_Thresh is large enough to mask acoustic coupling, and at high RX volume levels, Both_Thresh is small enough to allow a reasonable TX volume to cause the transition to the full-duplex state  66 .  
         [0265]     Referring now to  FIG. 9   b,  when the gain adjustment routine  230  is executed, the RX AGC  231  dramatically reduces the TX Speech Path gain by setting the Pre-Amp gain to +3 dB, sets the TX gain to −9 dB, and controls the RX gain in software by the AGC. The RX quantification routine  190  has already updated RX_Level with the volume range of RX_Max, so the AGC is simply a matter of selecting higher gain for weak RX signals and lower gain for strong RX signals, as shown below.  
                                                       Gain Control Register   Value Written   Gain Setting                           Mic. Pre-Amp. 46   80 H     +3 dB           TX Attenuation 54   2D H     −9 dB                      
 
         [0266]     Referring again to  FIG. 9   b,  the steps of the RX AGC  231  are shown below in the far right column.  
                                                       Value   Gain           RX_Level   Gain Control Register   Written   Setting   Steps                   0, 1, 2, 3   RX Attenuation 52   7F H      0 dB   234, 238, 242       4   RX Attenuation 52   5B H     −3 dB   234, 238, 240       5   RX Attenuation 52   2D H     −9 dB   234, 236                  
 
         [0267]     Due to the particular microphone  42  (Tram Model No. TR-50, manufactured by Tram Electronics, Inc., Cookstown, N.J. 08511) used in the portable handset  16 , the external amplifier  48 , and the physical location in the portable handset  16 , it is not necessary to graduate the TX volume level into ranges by a TX quantification routine. The center of the microphone (⅜″ diameter) is 6⅛″ inches from the center of the speaker (2″ diameter). Both components are oriented facing the same direction (up, when the speakerphone is placed flat on a desktop). Here, the “acceptable” background noise level limits the maximum microphone gain applied, with the result that a single digital gain setting is sufficient for the entire range of TX volume levels.  
         [0268]     When the TX state  64  is entered, the gain adjustment routine  230  reduces the RX gain to 24 dB, boosts the TX gain to 0 dB, and sets the Pre-Amp gain to +18 dB. These gain settings are accomplished when the TP  38  writes the following coefficients to the gain control registers.  
                                                       Gain Control Register   Value Written   Gain Setting                           RX Attenuation 52   08 H     −24 dB           TX Attenuation 54   7F H      0 dB           Mic. Pre-Amp. 46   90 H     +18 dB                      
 
         [0269]     In the Full-Duplex State, software Automatic Gain Control (AGC) regulates the gain proportions of the microphone and speaker amplifiers  54 ,  52  to keep the volume high in both speech paths without producing unstable audio feedback. By constantly monitoring the volume levels in the speech paths (as reflected in RX_Max and TX_Max), and by constantly adjusting the amplifier gains accordingly, the AGC dynamically regulates the balance of the two speech paths to allow both people to speak and hear simultaneously.  
         [0270]     Referring now to  FIG. 10 , the full-duplex AGC is implemented as three substates within the full-duplex state  66 , where each substate corresponds to a different gain combination. These substates are named “40/60”, “50/50” and “60/40” to reflect the percentage ratio of RX-to-TX gain. The 40/60 substate&#39;s gain setting emphasizes the microphone (for weak near-end speech), the 50/50 Substate&#39;s gain setting handles the case when strong volumes are present in both speech paths, and the 60/40 Substate&#39;s gain setting emphasizes the speaker (for weak far-end speech). The same pre-amp gain is programmed for each of the substates within the full-duplex state  66 .  
         [0271]     Referring now to  FIG. 11 , during each execution pass of the speakerphone state machine  60 , if the full-duplex state  66  is entered, in step  260 , only one of the three AGC substates is entered. In step  262 , if the previous state was the RX state  62 , then in step  264  the pre-amp gain is boosted to +18 dB, and then in step  266  the substate is initialized to the 60/40 substate. In step  268 , if the previous state was the idle state  68 , or in step  270 , if the previous state was the TX state  64 , then in step  272  the substate is initialized to the 40/60 substate. If the previous state was the full-duplex state  66 , then in step  274  the substate is unchanged to retain the previous AGC substate.  
         [0272]     During the current cycle, a substate machine decides which one of the three substates will be entered when the current cycle completes. This decision is based on the RX and TX volume levels (RX_Max and TX_Max), and on the current substate. The substate machine compares RX_Max and TX_Max to pre-defined value ranges to determine the optimal gains settings for the present volume levels. These value ranges were experimentally determined during the development of the wireless speakerphone system  10 , and resulted in the creation of a mapping of RX and TX volume levels to optimal gain settings. The mapping for the wireless speakerphone system  10  is shown in  FIG. 12 . The key to the stability of the AGC is to include hysteresis in the range boundaries, to avoid the metastable condition of the AGC oscillating between two substates in successive execution passes of the speakerphone state machine  60 . The mapping shown in  FIG. 12  for the wireless speakerphone system  10  includes this type of hysteresis. Two examples are given next to explain how hysteresis is implemented.  
       EXAMPLE 1  
       [0273]    
       
         
           
              In the 40/60 and 60/40 substates, TX_Max must rise above 7 D H  and RX_Max must rise above 6 C H  in order to cause a substate transition to the 50/50 substate. The AGC remains in the 50/50 substate until TX_Max falls below 71 H  and until RX_Max falls below 69 H , thus allowing 0 C H  of TX hysteresis and 03 H  of RX hysteresis between the 50/50 substate and the 40/60, 60/40 substates.  
           
         
       
     
       EXAMPLE 2  
       [0274]    
       
         
           
              Because the 40/60 and 60/40 substates share the same mapping, it may appear at first that there is no hysteresis between these two substates. However, an understanding of the speakerphone system explains the hysteresis. Increasing the RX gain increases the value of TX_Max due to acoustic coupling of the speaker to the microphone, which results in an apparent increase in TX speech volume from the point of view of the TP  38 . In the 40/60 substate the RX gain is 40% of the combined RX and TX gains. If the transmit speech gets loud enough to cause TX_Max to rise above 6E H , the AGC initiates a substate transition to the 60/40 substate, and thus decreases the TX gain in order to compensate for the apparent increased TX speech volume. The transition also increases the RX gain from 40% to 60%, which from the point of view of the TP  38 , increases the apparent TX volume as indicated by TX_Max. In the portable handset  16 , this increase is generally 03 H  to 04 H , which means TX_Max is now 71 H  to 72 H . The AGC remains in this 60/40 substate until TX_Max falls back below 6E H , thus allowing more than 03 H  of hysteresis between the 40/60 and 60/40 substates.  
           
         
       
     
         [0275]     Thus by determining which range the RX and TX volume levels fall into, the AGC decides which next substate (and consequently which pre-defined gain setting) is best for the associated input volume levels.  
         [0276]      FIGS. 13 and 14  show the decision process which implements the mapping of RX and TX volume levels to optimal gain settings, and defines the next substate. Referring now to  FIG. 13   a , the TP  38  begins at either step  280  or step  282 , depending on the substate decided by the full-duplex AGC in  FIG. 11 . In step  284 , the AGC determines if TX_Max is greater than 7 D H . If it is not, then in step  286  the AGC determines if TX_Max is less than 6E H . If it is, then in step  288  the RK gain is set equal to −12 dB, and the TX gain is set equal to −9 dB. In step  290 , the substate machine will enter the 40/60 substate when the current cycle completes. In step  286 , if TX_Max is not less than 6E H , then in step  292  the RX gain is set equal to −9 dB, and the TX gain is set equal to −12 dB. In step  294 , the substate machine will enter the 60/40 substate when the current cycle completes. Referring back to step  284 , if TX_Max is greater than 7 D H , then in step  296  the AGC determines if RX_Max is greater than 6 C H . If it is not, then in step  292  the RX gain is set equal to −9 dB, and the TX gain is set equal to −12 dB. In step  294 , the substate machine will enter the 60/40 substate when the current cycle completes. Referring back to step  296 , if RX_Max is greater than 6 C H , then in step  298  the RX gain is set equal to −12 dB, and the TX gain is set equal to −12 db. In step  300 , the substate machine will enter the 50/50 substate when the current cycle completes.  
         [0277]     Referring now to  FIG. 13   b,  in step  302  the TP  38  begins at step  302  if the substate decided by the full-duplex AGC in  FIG. 11  is the 50/50 substate. In step  304 , the AGC determines if TX_Max is less than 68 H . If it is, then in step  306  the RX gain is set equal to −12 db, and the TX gain is set equal to −9 dB. In step  308 , the substate machine will enter the 40/60 substate when the current cycle completes. Referring back to step  304 , if TX_Max is not less than 68 H , then, in step  310  the AGC determines if RX_Max is less than 5E H . If it is, then in step  312  the RX gain is set equal to −9 dB, and the TX gain is set equal to −12 db. In step  314 , the substate machine will enter the 60/40 substate when the current cycle completes. Referring back to step  310 , if RX_Max is not less than 5E H , then in step  316  the AGC determines if RX_Max is less than 69 H. In step  318 , the substate machine remains in the 50/50 substate until the next cycle. If RX_Max is less than 69 B, then in step  320  the AGC determines if TX_Max is greater than 71 H. If it is, then in step  318 , the substate machine remains in the 50/50 substate until the next cycle. If it is not, then in step  312 , the RX gain is set equal to −9 dB, and the TX gain is set equal to −12 db. In step  314 , the substate machine will enter the 60/40 substate when the current cycle completes.  
         [0278]     In addition to the preferred embodiment of a speakerphone in the portable handset  16 , the same speakerphone algorithm  41  can be implemented in at least two other embodiments. In typical speakerphone configurations available on the market today, the half-duplex speakerphone function is implemented in the base station  18  rather than in the portable handset  16 . Referring now to  FIG. 14 , in a first alternate embodiment of the invention, a wireless speakerphone system  400  has a second codec  33  in the base station  18 . The same full-duplex speakerphone algorithm  41  can be executed by the base station&#39;s TP  39 . In the alternate embodiment of  FIG. 14 , the two hardware requirements are maintained:  
         [0279]     the RX and TX volume levels are provided to the TP  39  in digital form; and  
         [0280]     the TP  39  can control the gain in the RX and TX speech paths. The portable handset  16  also includes a typical earphone/microphone  17 .  
         [0281]     To further generalize, the same full-duplex speakerphone algorithm  41  can be executed by the TP  38  in any telephone system where the following two hardware requirements are maintained:  
         [0282]     the RX and TX volume levels are provided to the TP  38  in digital form; and  
         [0283]     the TP  38  can control the gain in the RX and TX Speech paths.  
         [0284]      FIG. 15  shows such a second alternate embodiment of the invention. A wireless speakerphone system  500  includes analog-to-digital converters  502  and  504 . The converter  502  sends a digital voice signal to a receive speech register  506 , which has an 8 kHz sample rate. The converter  504  sends a digital voice signal to a transmit speech register  508 , which also has an 8 kHz sample rate. A microprocessor TP  510  controls the functioning of the system  500 , under the direction of the speakerphone algorithm  41  stored in a ROM  512 . Amplifiers  514  and  516  amplify the voice signals from a microphone  518 , and to a speaker  520 . The amplifiers  514 ,  516  can be analog or digital as long as their gain is selectable by means of a TP data bus  522 .  
         [0285]     The present invention has many advantages over the prior art. It provides better sound quality than the typical half-duplex speakerphone. It allows a full-duplex conversation, i.e., simultaneous speaking and hearing.  
         [0286]     The present invention eliminates the need for an external analog speakerphone chip and a DSP engine, and instead performs the comparisons, decisions, and gain adjustments by a small on-chip TP  38 . The on-chip hands-free registers  34 ,  36  eliminate the need for a costly external speakerphone chip to implement the analog volume comparisons and make the speaker/microphone gain decisions.  
         [0287]     Software-programmable digital gains are provided on-chip, thus eliminating the need for expensive external analog decoders with resistor ladders. The user-controlled volume setting is typically implemented in hardware in an analog speakerphone via a potentiometer, but suffers from degraded audio quality over time due to dust in the potentiometer mechanism and DC offset drift. The speakerphone handles volume control via software.  
         [0288]     The present invention eliminates the need for a second codec in the base station (one codec is needed for the analog interface to the telephone line, and the second codec would be needed to handle the analog speakerphone interface). In the present invention, the second codec is provided in the portable handset  16  where it was already needed to complete the digital wireless voice connection.  
         [0289]     The user enjoys the obvious freedom of wires to the speakerphone enclosure, for example, when the wireless speakerphone is used in a large conference room, and when the same speakerphone is used in one of several different conference rooms.  
         [0290]     Multiple variations and modifications are possible in the embodiments of the invention described here. Although certain illustrative embodiments of the invention have been shown and described here, a wide range of modifications, changes, and substitutions is contemplated in the foregoing disclosure. In some instances, some features of the present invention may be employed without a corresponding use of the other features. For example, the algorithm  41  performs reasonably well if the following times are used:  
         [0291]     1. 125 Ts Timer increased to 1 ms or 2 ms  
         [0292]     2. 20 ms Timer increased to 80 ms  
         [0293]     3. 160 ms Hold Time+80 ms Duplex Time increased up to about  1  second  
         [0294]     4. Peak Detection Window reduced from 80 samples to 40 samples  
         [0295]     It is possible to decrease rather than increase these times and achieve the same performance, but it would result in a higher power consumption in the portable handset  16 , and therefore would reduce the user&#39;s maximum “talk time”, because it would drain the battery faster. On the other hand, if one increases the timing, he would thus be increasing the “talk time” by reducing the portable handset&#39;s power consumption.  
         [0296]     A slight change in the speakerphone algorithm  41  will allow the user to adjust the “background noise level thresholds” slightly, rather than having them fixed as they are in the preferred embodiment. For example, the background noise level is “pre-defined” for a typical quiet engineering office. On the other hand, for a typical noisy office at a stock brokerage, the user can press a near-end noise button on the handset  16  (not shown) a few times to adjust this background noise level (in small steps) for the cases when the noise level around him is higher. Likewise, if he hears that the noise level from the far-end is high, he can press a far-end noise button on the handset  16  (not shown) a few times to adjust the far-end background noise level threshold. The result is that the speakerphone would sound better.  
         [0297]     With the pre-defined noise thresholds currently in the algorithm  41 , if someone calls the user from an excessively noisy place (maybe a gym), the high background noise will make the speakerphone algorithm  41  think (falsely) that the far-end person is constantly talking, and consequently it would remain in the RX state  62  when neither person is talking (instead of in the Idle state  68 ). By making a slight modification to the speakerphone algorithm  41 , to allow the noise thresholds to be variable instead of fixed, the speakerphone algorithm  41  would yield better performance in some cases. However, the preferred embodiment enjoys simplicity of design and operation, and thus does not implement the variable noise thresholds. The algorithm  41  simply compares the current volume levels to noise thresholds. The algorithm  41  doesn&#39;t care if the threshold is fixed or variable, it just needs to know what is the threshold at the time it makes the comparison.  
         [0298]     Accordingly, it is appropriate that the foregoing description be construed broadly and understood as being given by way of illustration and example only, the spirit and scope of the invention being limited only by the appended claims.