ADCMic driver is used to process analog and digital microphone signal and DC signal with the mxs40adcmic IP.
This IP interfaces with Delta-Sigma modulator part of the s40adcmic and implements CIC, decimation (FIR) and biquad filters. The ADC result is read by the CPU or the DMA from the FIFO of mxs40adcmic (and from CIC register for DC measurement). Instead of taking modulator data from s40adcmic, mxs40adcmic can also be configured to take PDM input directly from an external digital microphone.
Consult the datasheet of your device for details of the clocking system.
The high level features of the subsystem are:
The high level steps to use this driver are:
To configure the ADCMic subsystem call Cy_ADCMic_Init. Pass in a pointer to the MXS40ADCMIC_Type structure for the base hardware register address, pass in the configuration structure cy_stc_adcmic_config_t, and pass in the operation mode.
After initialization, call Cy_ADCMic_Enable to enable the block.
The configuration can be defined as follows:
Usually the MIC mode is used with FIFO, see FIFO Usage
Usually the MIC mode is used with FIFO, see FIFO Usage
The biquad filter usually is used to the audio stream equalization (in MIC or PDM modes):
The ADCMic requires two input clocks:
For more exact information on the ADCMic clock routing, refer to the datasheet for your device.
The ADCMic subsystem has two output triggers: from the timer and from the FIFO, the timer generates trigger always if enabled, the FIFO trigger could be configured separately for MIC and PDM modes by the cy_stc_adcmic_mic_config_t::fifoTrigger and cy_stc_adcmic_pdm_config_t::fifoTrigger respectively.
Also, they could be routed to any periphery using TrigMux (Trigger Multiplexer) driver, e.g. to DW block:
The Timer is used for DC measurement for two purposes:
The timer period and input signal source are configured by the cy_stc_adcmic_dc_config_t::timerPeriod and cy_stc_adcmic_dc_config_t::timerInput fields correspondingly.
The ADCMic subsystem has two interrupt sources: the timer and the FIFO. The FIFO interrupt can have several reasons, see FIFO Status Masks
The ADCMic interrupt to the NVIC is raised any time the intersection (logic and) of the interrupt flags and the corresponding interrupt masks are non-zero.
Implement an interrupt routine and assign it to the ADCMic interrupt. Use the pre-defined enumeration, adcmic_interrupt_adcmic_IRQn, as the interrupt source for the ADCMic.
The following code snippet demonstrates how to implement a routine to handle the interrupt. The routine gets called when any one of the ADCMic interrupts are triggered. When servicing an interrupt, the user must clear the interrupt so that subsequent interrupts can be handled.
The following code snippet demonstrates how to configure and enable the interrupt.
Alternately, instead of handling the interrupts, the Cy_ADCMic_IsEndConversion function allows for firmware polling of the end of DC conversion status.
The ADCMic subsystem in the MIC and PDM modes stores the audio data into the FIFO. It can be configured separately for the MIC and PDM modes using cy_stc_adcmic_mic_config_t::fifoFull, cy_stc_adcmic_mic_config_t::fifoEmpty and cy_stc_adcmic_pdm_config_t::fifoFull, cy_stc_adcmic_pdm_config_t::fifoEmpty respectively and served either by ISR:
Or by DMA:
The default Offset CY_ADCMIC_DC_OFFSET and Gain for both ranges CY_ADCMIC_DC_1_8_GAIN and CY_ADCMIC_DC_3_6_GAIN are precalculated based on the theory of the ADCMic operation DC measurement definitions.
So basically the raw count retrieved using Cy_ADCMic_GetDcResult for the desired DC input can be directly feed into any of the Cy_ADCMic_CountsTo_Volts, Cy_ADCMic_CountsTo_mVolts, or Cy_ADCMic_CountsTo_uVolts functions and have for some extend accurate result.
However, to increase the accuracy the real ADCMic Gain and Offset can be defined by physically measuring the Reference Ground CY_ADCMIC_REFGND and the Reference BandGap CY_ADCMIC_BGREF.
For example:
For further increase the measurement accuracy, the real BandGap voltage can be defined using external precise reference with exact known voltage:
Real BandGap voltage = external reference exact voltage * (BandGap counts - GND counts) / (external reference counts - GND counts).
And then use it in the Gain calculation as shown above instead of the nominal BandGap voltage CY_ADCMIC_DC_VBG.
To further improve the DC measurement accuracy, the low frequency Noise could be dynamically removed by performing two measurements for each input channel sequentially: one measuring the desired DC input and the other one measuring the CY_ADCMIC_REFGND. The second measurement of theCY_ADCMIC_REFGND contains only the low frequency Noise (Flick Noise) information. It is important to perform these two measurements one after another as close as possible. The final true ADC output value is then obtained by subtracting the ADC output of the second measurement from the ADC output of the first measurement.
For example:
For more information on the ADCMic ADC subsystem, refer to the datasheet of your device.
Version | Changes | Reason for Change |
---|---|---|
1.10 | The ADCMic PDL driver ID CY_ADCMIC_ID is updated | Avoiding possible driver ID collisions |
1.0 | The cy_en_adcmic_source_t is renamed to cy_en_adcmic_mode_t. The micPd parameter is removed from the cy_stc_adcmic_mic_config_t The next parameters are added into cy_stc_adcmic_mic_config_t :
The clockDiv parameter is removed from the cy_stc_adcmic_pdm_config_t The next parameters are added into cy_stc_adcmic_pdm_config_t :
The next parameters are removed from the cy_stc_adcmic_dc_config_t :
The next parameter is renamed in the cy_stc_adcmic_dc_config_t :
The next parameters are added into cy_stc_adcmic_dc_config_t :
The next parameters are removed from the cy_stc_adcmic_config_t :
The next parameters are renamed in the cy_stc_adcmic_config_t :
The new parameter 'mode' is added to the Cy_ADCMic_Init. | Usability review |
0.1 | This is a pre-production driver release. The driver is not recommended for production use, unless the functionality is delivered in Cypress-provided applications. | Pre-production support of the CAT1B Devices |
API Reference | |
Macros | |
Enumerated Types | |
Data Structures | |
Functions | |