WAN_0213 WM8903 ECM Microphone Detection

w
WAN_0213
WM8903 ECM Microphone Detection using MICBIAS Current
INTRODUCTION
The WM8903 is a high performance ultra-low power stereo CODEC optimised for portable audio
applications. Its inputs are able to interface to an Electret Condenser Microphone (ECM) for voice
recording purposes. The WM8903 includes features which permit detection of such microphone
when inserted, for example as part of a headset accessory.
MICROPHONE INTERFACE
ECMs are commonly used in a plug-in headset accessory, which can also include a “hook switch”
button for indicating call start/finish, and a pair of headphones/ear buds as shown in Figure 1.
Figure 1 Typical Microphone Interface
Headset connectors normally have a 4 pole connector (stereo ear buds), or 3 pole (single ear bud),
with a single MIC pin as shown in Figure 1, hence it is desirable for the MIC pin to be able to support
the following functions:
•
Supply MICBIAS current to ECM microphone
•
Receive signal from ECM microphone
•
Detect insertion/removal of headset event
•
Detect press/release of hook switch event
WM8903 contains detection circuitry which can sense the MICBIAS current flow, hence by sensing
the current flow with respect to pre-defined threshold, can detect whether the microphone is (1)
inserted and (2) inserted with hook switch pressed. Neither of these detection functions has any
effect on the audio signal from the ECM microphone.
MICBIAS CURRENT DETECT FUNCTION
Insertion/removal of a microphone or pressing/releasing a hook switch button will cause a significant
change of MICBIAS current flow. On WM8903, two current thresholds are provided, set by register
bits MICDET_THR and MICSHORT_THR. When a change of current flow which crosses either
threshold is detected, an interrupt event can be generated. In a typical application, accessory
insertion would be detected when the MICBIAS current exceeds MICDET_THR , and microphone
hookswitch operation would be detected when the MICBIAS current exceeds MICSHORT_THR.
The Threshold Detection functions are both inputs to the Interrupt control circuit and can be used to
trigger an Interrupt event when MICDET_ENA=1. The interrupt flag can be read back via the control
interface, or the microphone status can be outputted as a logic level on a GPIO pin (see WM8903
datasheet for further details about enabling interrupts or using GPIO).
WOLFSON MICROELECTRONICS plc
To receive regular email updates, sign up at http://www.wolfsonmicrophonero.com/enews
July 2009, Rev 1.0
Copyright ©2009 Wolfson Microelectronics plc
WAN_0213
Customer Information
Hysteresis and digital filtering are implemented in the hook switch detect circuit to improve reliability
in conditions where current spikes are present due to ambient noise conditions. Hysteresis and
digital filtering applies to both methods of detection, i.e. interrupt events, or GPIO pin state.
The register fields used to configure MICBIAS functionality are described in Table 1. Typical
performance parameters for this circuit block, including current thresholds, can be found in Table 2.
Minimum and maximum performance figures are quoted in the WM8903 device datasheet.
REGISTER
ADDRESS
BIT
R6 (06h)
Microphone
Bias Control 0
7:6
LABEL
DEFAULT
DESCRIPTION
Reserved
00
5:4
MICDET_THR
[1:0]
00
3:2
MICSHORT_TH
R [1:0]
00
1
MICDET_ENA
0
0
MICBIAS_ENA
0
Reserved. Writing ‘1’ to these
register bits will have no effect.
MICBIAS Current Detect Insertion
Threshold
00 = 0.063mA
01 = 0.26mA
10 = 0.45mA
11 = 0.635mA
If AVDD ≠ 1.8, values are scaled
MICBIAS Short Circuit Button Push
Threshold
00 = 0.52mA
01 = 0.77mA
10 = 1.2mA
11 = 1.43mA
If AVDD ≠ 1.8, values are scaled
MICBIAS Current and Short Circuit
Detect Enable
0 = disabled
1 = enabled
MICBIAS Enable
0 = disabled
1 = enabled
Table 1 MICBIAS Control
Microphone bias (for analogue electret condenser microphone)
Test conditions: MICBIAS_ENA=1, all parameters measured at the MICBIAS pin
PARAMETER
SYMBOL
TEST CONDITIONS
MIN
Bias Voltage
VMICBIAS
Maximum source current
IMICBIAS
3mA load current
TYP
MAX
UNIT
0.9×AVDD
V
4
mA
63
μA
1.25-15
ms
520
μA
MICBIAS Current Detect Function (See Notes 1, 2)
Current Detect Threshold
(Microphone insertion)
MICDET_THR = 00
Current Detect Threshold
(Microphone removal)
Delay Time for Current Detect
Interrupt
tDET
Please
refer to
WM8903
datasheet
Please refer to WM8903 datasheet
MICBIAS Short Circuit (Hook Switch) Detect Function (See Notes 1, 2)
Short Circuit Detect Threshold
(Button press)
MICSHORT_THR = 00
Short Circuit Detect Hysteresis
(See Note 3)
Minimum Delay Time for
Short Circuit Detect Interrupt
50
tSHORT
Short Circuit Detect
measurement frequency
40
ms
250
Hz
Table 2 Microphone Detect Parameters
w
Customer Information
June 2009, Rev 1.0
2
WAN_0213
Customer Information
Notes:
1.
2.
If AVDD ≠ 1.8, current threshold values should be multiplied by (AVDD/1.8)
MICBIAS current detect and short circuit (Hook switch) detect functionality tested using GPIO pin rather than by interrupt.
3.
Hysteresis = difference between Button Press and Button Release thresholds
Further guidance on the usage of the MICBIAS current monitoring features is described in the
following sections.
MICROPHONE INSERTION / REMOVAL DETECTION
In a typical application, microphone insertion would be detected when the MICBIAS current exceeds
the Current Detect threshold set by MICDET_THR . In order to generate a MICBIAS Current Detect
interrupt from this event, MICDET_INV must be cleared to 0 (see WM8903 datasheet for further
details about enabling interrupts).
For detection of microphone removal, the MICDET_INV bit must be set to 1. In this case, a MICBIAS
Current Detect interrupt is generated when the MICBIAS current falls below the threshold set by
MICDET_THR .
The detection of these events is bandwidth limited for best noise rejection, and is subject to detection
delay time tDET. Provided that the MICDET_THR field has been set appropriately, each insertion or
removal event is guaranteed to be detected within the delay time tDET.
A clock is required for the Current Detect circuit. This requires:
1.
MCLK to be present
2.
CLK_SYS_ENA = 1
3.
WSMD_CLK_ENA = 1
The above register bits are detailed in the WM8903 datasheet.
It is likely that the microphone socket contacts will have mechanical “bounce” when a microphone is
inserted or removed, and hence the resultant control signal will not be a clean logic level transition.
Since tDET has a range of values, it is possible that the interrupt will be generated before the
mechanical “bounce” has ceased. Hence after a microphone insertion or removal has been detected,
after detecting an interrupt event using the control interface, a time delay should be applied before
re-configuring the MICDET_INV bit. The maximum possible mechanical bounce times for
microphone insertion and removal must be understood by the software programmer.
Utilising a GPIO pin to monitor the steady state of the microphone detection function does not
change the timing of the detection mechanism, so there will also be a delay tDET before the signal
changes state. It may be desirable to implement de-bounce in the host processor when monitoring
the state of the GPIO signal.
To illustrate this, an example sequence including microphone insertion detection is detailed in the
“Microphone detection sequence using MICBIAS current” section on page 4.
MICROPHONE HOOK SWITCH DETECTION
In a typical application, microphone hook switch operation would be detected when the MICBIAS
current exceeds the Short Circuit Detect threshold set by MICSHORT_THR. In order to generate a
MICBIAS Short Circuit Detect interrupt from this event, MICSHRT_INV must be cleared to 0 (see
WM8903 datasheet for further details about enabling interrupts).
For detection of the hook switch release, the MICSHRT_INV bit must be set to 1. In this case, a
MICBIAS Short Circuit Detect interrupt is generated when the MICBIAS current falls below the
threshold set by MICSHORT_THR.
A clock is required for the Hook Switch Detect circuit. This requires:
1.
MCLK to be present
2.
CLK_SYS_ENA = 1
3.
WSMD_CLK_ENA = 1
The above register bits are detailed in the WM8903 datasheet.
w
Customer Information
June 2009, Rev 1.0
3
WAN_0213
Customer Information
The possibility of spurious hook switch interrupts due to ambient noise conditions can be removed by
careful analysis and understanding of:
1
Microphone behaviour under extremely high sound pressure levels or during mechanical
shock, such that the AC current swing during such conditions is understood.
2
Correct selection of the MICBIAS resistor value, such that current flow while the hook switch
is pressed is significantly higher than that caused by AC current swing during such
conditions.
Where the MICBIAS resistor is large enough such that the specified threshold level (see datasheet
electrical characteristics for minimum value) when MICSHORT_THR = 00 is close to the level of
possible MICBIAS AC current spikes, the probability of false detections is greatly reduced by 2
design features:
1.
Hysteresis of the hook switch detect function means that a different current threshold is
used for detecting button push and button release.
2.
Digital filtering means that the hook switch detection event is only signalled when the
MICBIAS current has satisfied the threshold condition for 10 successive measurements, as
shown in Figure 2. The hook switch detect measurement frequency and the detection delay
time tSHORT are detailed in Table 2.
Figure 2 MIC Hook Switch Detect Filtering
The filtering algorithm helps to reject spurious interrupts caused by very high current spikes due to
ambient conditions such as wind noise or mechanical shock.
Note that the filtering algorithm provides only limited rejection of current spikes with:
w
Customer Information
1.
Frequencies less than or equal to the hook switch detect measurement frequency.
2.
Frequencies equal to harmonics of the hook switch detect measurement frequency.
June 2009, Rev 1.0
4
WAN_0213
Customer Information
EXAMPLE SEQUENCE
This section details an example sequence which summarises how the host processor can configure
and detect the events supported by the MICBIAS current detect function:
•
Microphone insertion/removal
•
Hook switch press/release
Figure 3 shows an example of how the MICBIAS current flow varies versus time, during microphone
insertion and hook switch events. The Y axis is annotated with the Microphone detection thresholds,
and the X axis is annotated with the stages of an example sequence as detailed in Table 3, to
illustrate how the host processor can implement microphone insertion and hook switch detection.
The sequence assumes that the polling of the control interface, by checking the interrupt flags (see
WM8903 datasheet for further details about enabling interrupts) has been used to monitor changes
in the microphone insertion or hook switch detection functions, rather than connection of a WM8903
GPIO. This means that the maximum possible mechanical bounce times for microphone insertion
and removal must be understood by the software programmer.
At every step in the following process, the host processor should poll the interrupt status register.
Figure 3 Microphone Insert and Hook Switch Detect: Example MICBIAS Current Plot
w
Customer Information
June 2009, Rev 1.0
5
WAN_0213
STEP
Customer Information
DETAILS
1
Microphone not inserted. To detect microphone insertion, Host processor must initialise interrupts and clear
MICDET_INV = 0.
2
Mechanical bounce of jack socket during Microphone insertion. Host processor may detect a microphone insertion
interrupt during this step. Once detected, the host processor can set MICDET_INV = 1, unless mechanical bounce can
last longer than the shortest possible TDET, in which case the host processor should not set MICDET_INV = 1 until step
3.
3
Microphone fully inserted. If not already set, Host processor must now set MICDET_INV = 1. To detect Hook switch
press, Host processor must clear MICSHRT_INV = 0. At this step, the diagram shows no AC current swing, due to a
very low ambient noise level.
4
Microphone fully inserted. Diagram shows AC current swing due to high levels of background noise (such as wind).
5
Mechanical bounce during hook switch press. The hook switch interrupt is unlikely to be set during this step, because 10
successive samples of the MICBIAS current exceeding the hook switch threshold have not yet been sampled.
6
Hook switch is fully pressed down. After TSHORT, 10 successive samples of the MICBIAS current exceeding the hook
switch threshold have been detected, hence a hook switch interrupt will be generated, and the host processor can
immediately set MICSHRT_INV = 1.
7
Mechanical bounce during hook switch release. The hook switch interrupt is unlikely to be set during this step, because
10 successive samples of the MICBIAS current lower than the hook switch threshold have not yet been sampled.
8
Hook switch fully released. After TSHORT, 10 successive samples of the MICBIAS current lower than the hook switch
threshold have been detected, hence a hook switch interrupt will be generated, and the host processor can immediately
clear MICSHRT_INV = 0.
9
Mechanical bounce of jack socket during Microphone removal. Host processor may already detect a microphone
removal interrupt during this step. Once detected, the host processor can clear MICDET_INV = 0, unless mechanical
bounce can last longer than the shortest possible TDET, in which case the host processor should not clear MICDET_INV
= 0 until step 10.
10
Microphone fully removed. If not already cleared, Host processor must now clear MICDET_INV = 0.
Table 3 Microphone Insert and Hook Switch Detect: Example Sequence
Alternatively, utilising a GPIO pin to monitor the MICBIAS current detect functionality (see WM8903
datasheet for further details about enabling GPIO functionality) permits the host processor to monitor
the steady state of microphone detection or hook switch press functions. Because the GPIO shows
the steady state condition, software de-bounce may be easier to implement in the host processor,
dependant on the processor performance characteristics, hence use of the GPIO is likely to simplify
the rejection of mechanical bounce. Changes of state in the GPIO pin are also subject to the time
delays tDET and tSHORT.
CONCLUSION
As well as providing a microphone bias supply to the ECM, the WM8903 MICBIAS detect circuit also
permits detection of headset microphone insertion and hook switch press.
A number of features have been implemented to improve the robustness of this detection system in
conditions of high ambient noise, thus reducing the possibility of spurious hook switch detection
events.
w
Customer Information
June 2009, Rev 1.0
6
WAN_0213
Customer Information
APPLICATION SUPPORT
If you require more information or require technical support, please contact the Wolfson
Microelectronics Applications group through the following channels:
Email:
Telephone Apps:
Fax:
Mail:
[email protected]
+44 (0) 131 272 7070
+44 (0) 131 272 7001
Applications Engineering at the address on the last page
or contact your local Wolfson representative.
Additional information may be made available on our web site at:
http://www.wolfsonmicrophonero.com
w
Customer Information
June 2009, Rev 1.0
7
WAN_0213
Customer Information
IMPORTANT NOTICE
Wolfson Microelectronics plc (“Wolfson”) products and services are sold subject to Wolfson’s terms and conditions of sale, delivery
and payment supplied at the time of order acknowledgement.
Wolfson warrants performance of its products to the specifications in effect at the date of shipment. Wolfson reserves the right to
make changes to its products and specifications or to discontinue any product or service without notice. Customers should
therefore obtain the latest version of relevant information from Wolfson to verify that the information is current.
Testing and other quality control techniques are utilised to the extent Wolfson deems necessary to support its warranty. Specific
testing of all parameters of each device is not necessarily performed unless required by law or regulation.
In order to minimise risks associated with customer applications, the customer must use adequate design and operating
safeguards to minimise inherent or procedural hazards. Wolfson is not liable for applications assistance or customer product
design. The customer is solely responsible for its selection and use of Wolfson products. Wolfson is not liable for such selection
or use nor for use of any circuitry other than circuitry entirely embodied in a Wolfson product.
Wolfson’s products are not intended for use in life support systems, appliances, nuclear systems or systems where malfunction can
reasonably be expected to result in personal injury, death or severe property or environmental damage. Any use of products by the
customer for such purposes is at the customer’s own risk.
Wolfson does not grant any licence (express or implied) under any patent right, copyright, mask work right or other intellectual
property right of Wolfson covering or relating to any combination, machine, or process in which its products or services might be or
are used. Any provision or publication of any third party’s products or services does not constitute Wolfson’s approval, licence,
warranty or endorsement thereof. Any third party trade marks contained in this document belong to the respective third party
owner.
Reproduction of information from Wolfson datasheets is permissible only if reproduction is without alteration and is accompanied by
all associated copyright, proprietary and other notices (including this notice) and conditions.
Wolfson is not liable for any
unauthorised alteration of such information or for any reliance placed thereon.
Any representations made, warranties given, and/or liabilities accepted by any person which differ from those contained in this
datasheet or in Wolfson’s standard terms and conditions of sale, delivery and payment are made, given and/or accepted at that
person’s own risk. Wolfson is not liable for any such representations, warranties or liabilities or for any reliance placed thereon by
any person.
ADDRESS:
Wolfson Microelectronics plc
Westfield House
26 Westfield Road
Edinburgh
EH11 2QB
United Kingdom
Tel :: +44 (0)131 272 7000
Fax :: +44 (0)131 272 7001
w
Customer Information
June 2009, Rev 1.0
8