MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

The MCUXpresso SDK provides a peripheral driver for the Microphone Interface (PDM) module of MCUXpresso SDK devices.

PDM driver includes functional APIs and transactional APIs.

Functional APIs target low-level APIs. Functional APIs can be used for PDM initialization, configuration, and operation for the optimization and customization purpose. Using the functional API requires the knowledge of the PDM peripheral and how to organize functional APIs to meet the application requirements. All functional API use the peripheral base address as the first parameter. PDM functional operation groups provide the functional API set.

Transactional APIs target high-level APIs. Transactional APIs can be used to enable the peripheral and in the application if the code size and performance of transactional APIs satisfy the requirements. If the code size and performance are a critical requirement, see the transactional API implementation and write a custom code. Initialize the handle by calling the PDM_TransferCreateHandle() API.

Transactional APIs support asynchronous transfer. This means that the functions PDM_TransferReceiveNonBlocking() set up the interrupt for data transfer. When the transfer completes, the upper layer is notified through a callback function with kStatus_PDM_Idle status.

Typical use case

PDM receive using an interrupt method

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm_interrupt

PDM receive using a SDMA method

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_sdma_transfer

PDM receive using a EDMA method

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_edma_transfer Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_sai_edma Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_sai_multi_channel_edma

PDM receive using a transactional method

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/pdm/pdm_interrupt_transfer

Data Structures

struct  pdm_channel_config_t
 PDM channel configurations. More...
 
struct  pdm_config_t
 PDM user configuration structure. More...
 
struct  pdm_hwvad_config_t
 PDM voice activity detector user configuration structure. More...
 
struct  pdm_hwvad_noise_filter_t
 PDM voice activity detector noise filter user configuration structure. More...
 
struct  pdm_hwvad_zero_cross_detector_t
 PDM voice activity detector zero cross detector configuration structure. More...
 
struct  pdm_transfer_t
 PDM SDMA transfer structure. More...
 
struct  pdm_handle_t
 PDM handle structure. More...
 

Macros

#define PDM_XFER_QUEUE_SIZE   (4U)
 PDM XFER QUEUE SIZE.
 

Typedefs

typedef void(* pdm_transfer_callback_t )(PDM_Type *base, pdm_handle_t *handle, status_t status, void *userData)
 PDM transfer callback prototype.
 

Enumerations

enum  {
  kStatus_PDM_Busy = MAKE_STATUS(kStatusGroup_PDM, 0),
  kStatus_PDM_CLK_LOW = MAKE_STATUS(kStatusGroup_PDM, 1),
  kStatus_PDM_FIFO_ERROR = MAKE_STATUS(kStatusGroup_PDM, 2),
  kStatus_PDM_QueueFull = MAKE_STATUS(kStatusGroup_PDM, 3),
  kStatus_PDM_Idle = MAKE_STATUS(kStatusGroup_PDM, 4),
  kStatus_PDM_Output_ERROR = MAKE_STATUS(kStatusGroup_PDM, 5),
  kStatus_PDM_ChannelConfig_Failed = MAKE_STATUS(kStatusGroup_PDM, 6)
}
 PDM return status. More...
 
enum  _pdm_interrupt_enable {
  kPDM_ErrorInterruptEnable = PDM_CTRL_1_ERREN_MASK,
  kPDM_FIFOInterruptEnable = PDM_CTRL_1_DISEL(2U)
}
 The PDM interrupt enable flag. More...
 
enum  _pdm_internal_status {
  kPDM_StatusDfBusyFlag = (int)PDM_STAT_BSY_FIL_MASK,
  kPDM_StatusFIRFilterReady = PDM_STAT_FIR_RDY_MASK,
  kPDM_StatusFrequencyLow = PDM_STAT_LOWFREQF_MASK,
  kPDM_StatusCh0FifoDataAvaliable = PDM_STAT_CH0F_MASK,
  kPDM_StatusCh1FifoDataAvaliable = PDM_STAT_CH1F_MASK,
  kPDM_StatusCh2FifoDataAvaliable = PDM_STAT_CH2F_MASK,
  kPDM_StatusCh3FifoDataAvaliable = PDM_STAT_CH3F_MASK,
  kPDM_StatusCh4FifoDataAvaliable = PDM_STAT_CH4F_MASK,
  kPDM_StatusCh5FifoDataAvaliable = PDM_STAT_CH5F_MASK,
  kPDM_StatusCh6FifoDataAvaliable = PDM_STAT_CH6F_MASK,
  kPDM_StatusCh7FifoDataAvaliable = PDM_STAT_CH7F_MASK
}
 The PDM status. More...
 
enum  _pdm_channel_enable_mask {
  kPDM_EnableChannel0 = PDM_STAT_CH0F_MASK,
  kPDM_EnableChannel1 = PDM_STAT_CH1F_MASK,
  kPDM_EnableChannel2 = PDM_STAT_CH2F_MASK,
  kPDM_EnableChannel3 = PDM_STAT_CH3F_MASK,
  kPDM_EnableChannel4 = PDM_STAT_CH4F_MASK,
  kPDM_EnableChannel5 = PDM_STAT_CH5F_MASK,
  kPDM_EnableChannel6 = PDM_STAT_CH6F_MASK,
  kPDM_EnableChannel7 = PDM_STAT_CH7F_MASK
}
 PDM channel enable mask. More...
 
enum  _pdm_fifo_status {
  kPDM_FifoStatusUnderflowCh0 = PDM_FIFO_STAT_FIFOUND0_MASK,
  kPDM_FifoStatusUnderflowCh1 = PDM_FIFO_STAT_FIFOUND1_MASK,
  kPDM_FifoStatusUnderflowCh2 = PDM_FIFO_STAT_FIFOUND2_MASK,
  kPDM_FifoStatusUnderflowCh3 = PDM_FIFO_STAT_FIFOUND3_MASK,
  kPDM_FifoStatusUnderflowCh4 = PDM_FIFO_STAT_FIFOUND4_MASK,
  kPDM_FifoStatusUnderflowCh5 = PDM_FIFO_STAT_FIFOUND5_MASK,
  kPDM_FifoStatusUnderflowCh6 = PDM_FIFO_STAT_FIFOUND6_MASK,
  kPDM_FifoStatusUnderflowCh7 = PDM_FIFO_STAT_FIFOUND6_MASK,
  kPDM_FifoStatusOverflowCh0 = PDM_FIFO_STAT_FIFOOVF0_MASK,
  kPDM_FifoStatusOverflowCh1 = PDM_FIFO_STAT_FIFOOVF1_MASK,
  kPDM_FifoStatusOverflowCh2 = PDM_FIFO_STAT_FIFOOVF2_MASK,
  kPDM_FifoStatusOverflowCh3 = PDM_FIFO_STAT_FIFOOVF3_MASK,
  kPDM_FifoStatusOverflowCh4 = PDM_FIFO_STAT_FIFOOVF4_MASK,
  kPDM_FifoStatusOverflowCh5 = PDM_FIFO_STAT_FIFOOVF5_MASK,
  kPDM_FifoStatusOverflowCh6 = PDM_FIFO_STAT_FIFOOVF6_MASK,
  kPDM_FifoStatusOverflowCh7 = PDM_FIFO_STAT_FIFOOVF7_MASK
}
 The PDM fifo status. More...
 
enum  _pdm_range_status {
  kPDM_RangeStatusUnderFlowCh0 = PDM_RANGE_STAT_RANGEUNF0_MASK,
  kPDM_RangeStatusUnderFlowCh1 = PDM_RANGE_STAT_RANGEUNF1_MASK,
  kPDM_RangeStatusUnderFlowCh2 = PDM_RANGE_STAT_RANGEUNF2_MASK,
  kPDM_RangeStatusUnderFlowCh3 = PDM_RANGE_STAT_RANGEUNF3_MASK,
  kPDM_RangeStatusUnderFlowCh4 = PDM_RANGE_STAT_RANGEUNF4_MASK,
  kPDM_RangeStatusUnderFlowCh5 = PDM_RANGE_STAT_RANGEUNF5_MASK,
  kPDM_RangeStatusUnderFlowCh6 = PDM_RANGE_STAT_RANGEUNF6_MASK,
  kPDM_RangeStatusUnderFlowCh7 = PDM_RANGE_STAT_RANGEUNF7_MASK,
  kPDM_RangeStatusOverFlowCh0 = PDM_RANGE_STAT_RANGEOVF0_MASK,
  kPDM_RangeStatusOverFlowCh1 = PDM_RANGE_STAT_RANGEOVF1_MASK,
  kPDM_RangeStatusOverFlowCh2 = PDM_RANGE_STAT_RANGEOVF2_MASK,
  kPDM_RangeStatusOverFlowCh3 = PDM_RANGE_STAT_RANGEOVF3_MASK,
  kPDM_RangeStatusOverFlowCh4 = PDM_RANGE_STAT_RANGEOVF4_MASK,
  kPDM_RangeStatusOverFlowCh5 = PDM_RANGE_STAT_RANGEOVF5_MASK,
  kPDM_RangeStatusOverFlowCh6 = PDM_RANGE_STAT_RANGEOVF6_MASK,
  kPDM_RangeStatusOverFlowCh7 = PDM_RANGE_STAT_RANGEOVF7_MASK
}
 The PDM output status. More...
 
enum  pdm_dc_remover_t {
  kPDM_DcRemoverCutOff21Hz = 0U,
  kPDM_DcRemoverCutOff83Hz = 1U,
  kPDM_DcRemoverCutOff152Hz = 2U,
  kPDM_DcRemoverBypass = 3U
}
 PDM DC remover configurations. More...
 
enum  pdm_df_quality_mode_t {
  kPDM_QualityModeMedium = 0U,
  kPDM_QualityModeHigh = 1U,
  kPDM_QualityModeLow = 7U,
  kPDM_QualityModeVeryLow0 = 6U,
  kPDM_QualityModeVeryLow1 = 5U,
  kPDM_QualityModeVeryLow2 = 4U
}
 PDM decimation filter quality mode. More...
 
enum  _pdm_qulaity_mode_k_factor {
  kPDM_QualityModeHighKFactor = 1U,
  kPDM_QualityModeMediumKFactor = 2U,
  kPDM_QualityModeLowKFactor = 4U,
  kPDM_QualityModeVeryLow2KFactor = 8U
}
 PDM quality mode K factor. More...
 
enum  pdm_df_output_gain_t {
  kPDM_DfOutputGain0 = 0U,
  kPDM_DfOutputGain1 = 1U,
  kPDM_DfOutputGain2 = 2U,
  kPDM_DfOutputGain3 = 3U,
  kPDM_DfOutputGain4 = 4U,
  kPDM_DfOutputGain5 = 5U,
  kPDM_DfOutputGain6 = 6U,
  kPDM_DfOutputGain7 = 7U,
  kPDM_DfOutputGain8 = 8U,
  kPDM_DfOutputGain9 = 9U,
  kPDM_DfOutputGain10 = 0xAU,
  kPDM_DfOutputGain11 = 0xBU,
  kPDM_DfOutputGain12 = 0xCU,
  kPDM_DfOutputGain13 = 0xDU,
  kPDM_DfOutputGain14 = 0xEU,
  kPDM_DfOutputGain15 = 0xFU
}
 PDM decimation filter output gain. More...
 
enum  _pdm_data_width {
  kPDM_DataWwidth24 = 3U,
  kPDM_DataWwidth32 = 4U
}
 PDM data width. More...
 
enum  _pdm_hwvad_interrupt_enable {
  kPDM_HwvadErrorInterruptEnable = PDM_VAD0_CTRL_1_VADERIE_MASK,
  kPDM_HwvadInterruptEnable = PDM_VAD0_CTRL_1_VADIE_MASK
}
 PDM voice activity detector interrupt type. More...
 
enum  _pdm_hwvad_int_status {
  kPDM_HwvadStatusInputSaturation = PDM_VAD0_STAT_VADINSATF_MASK,
  kPDM_HwvadStatusVoiceDetectFlag = PDM_VAD0_STAT_VADIF_MASK
}
 The PDM hwvad interrupt status flag. More...
 
enum  pdm_hwvad_hpf_config_t {
  kPDM_HwvadHpfBypassed = 0x0U,
  kPDM_HwvadHpfCutOffFreq1750Hz = 0x1U,
  kPDM_HwvadHpfCutOffFreq215Hz = 0x2U,
  kPDM_HwvadHpfCutOffFreq102Hz = 0x3U
}
 High pass filter configure cut-off frequency. More...
 
enum  pdm_hwvad_filter_status_t {
  kPDM_HwvadInternalFilterNormalOperation = 0U,
  kPDM_HwvadInternalFilterInitial = PDM_VAD0_CTRL_1_VADST10_MASK
}
 HWVAD internal filter status. More...
 
enum  pdm_hwvad_zcd_result_t {
  kPDM_HwvadResultOREnergyBasedDetection,
  kPDM_HwvadResultANDEnergyBasedDetection
}
 PDM voice activity detector zero cross detector result. More...
 

Driver version

#define FSL_PDM_DRIVER_VERSION   (MAKE_VERSION(2, 5, 0))
 Version 2.5.0.
 

Initialization and deinitialization

void PDM_Init (PDM_Type *base, const pdm_config_t *config)
 Initializes the PDM peripheral. More...
 
void PDM_Deinit (PDM_Type *base)
 De-initializes the PDM peripheral. More...
 
static void PDM_Reset (PDM_Type *base)
 Resets the PDM module. More...
 
static void PDM_Enable (PDM_Type *base, bool enable)
 Enables/disables PDM interface. More...
 
static void PDM_EnableDoze (PDM_Type *base, bool enable)
 Enables/disables DOZE. More...
 
static void PDM_EnableDebugMode (PDM_Type *base, bool enable)
 Enables/disables debug mode for PDM. More...
 
static void PDM_EnableInDebugMode (PDM_Type *base, bool enable)
 Enables/disables PDM interface in debug mode. More...
 
static void PDM_EnterLowLeakageMode (PDM_Type *base, bool enable)
 Enables/disables PDM interface disable/Low Leakage mode. More...
 
static void PDM_EnableChannel (PDM_Type *base, uint8_t channel, bool enable)
 Enables/disables the PDM channel. More...
 
void PDM_SetChannelConfig (PDM_Type *base, uint32_t channel, const pdm_channel_config_t *config)
 PDM one channel configurations. More...
 
status_t PDM_SetSampleRateConfig (PDM_Type *base, uint32_t sourceClock_HZ, uint32_t sampleRate_HZ)
 PDM set sample rate. More...
 
status_t PDM_SetSampleRate (PDM_Type *base, uint32_t enableChannelMask, pdm_df_quality_mode_t qualityMode, uint8_t osr, uint32_t clkDiv)
 PDM set sample rate. More...
 
uint32_t PDM_GetInstance (PDM_Type *base)
 Get the instance number for PDM. More...
 

Status

static uint32_t PDM_GetStatus (PDM_Type *base)
 Gets the PDM internal status flag. More...
 
static uint32_t PDM_GetFifoStatus (PDM_Type *base)
 Gets the PDM FIFO status flag. More...
 
static uint32_t PDM_GetRangeStatus (PDM_Type *base)
 Gets the PDM Range status flag. More...
 
static void PDM_ClearStatus (PDM_Type *base, uint32_t mask)
 Clears the PDM Tx status. More...
 
static void PDM_ClearFIFOStatus (PDM_Type *base, uint32_t mask)
 Clears the PDM Tx status. More...
 
static void PDM_ClearRangeStatus (PDM_Type *base, uint32_t mask)
 Clears the PDM range status. More...
 

Interrupts

void PDM_EnableInterrupts (PDM_Type *base, uint32_t mask)
 Enables the PDM interrupt requests. More...
 
static void PDM_DisableInterrupts (PDM_Type *base, uint32_t mask)
 Disables the PDM interrupt requests. More...
 

DMA Control

static void PDM_EnableDMA (PDM_Type *base, bool enable)
 Enables/disables the PDM DMA requests. More...
 
static uint32_t PDM_GetDataRegisterAddress (PDM_Type *base, uint32_t channel)
 Gets the PDM data register address. More...
 

Bus Operations

void PDM_ReadFifo (PDM_Type *base, uint32_t startChannel, uint32_t channelNums, void *buffer, size_t size, uint32_t dataWidth)
 PDM read fifo. More...
 
static uint32_t PDM_ReadData (PDM_Type *base, uint32_t channel)
 Reads data from the PDM FIFO. More...
 

Voice Activity Detector

void PDM_SetHwvadConfig (PDM_Type *base, const pdm_hwvad_config_t *config)
 Configure voice activity detector. More...
 
static void PDM_ForceHwvadOutputDisable (PDM_Type *base, bool enable)
 PDM hwvad force output disable. More...
 
static void PDM_ResetHwvad (PDM_Type *base)
 PDM hwvad reset. More...
 
static void PDM_EnableHwvad (PDM_Type *base, bool enable)
 Enable/Disable Voice activity detector. More...
 
static void PDM_EnableHwvadInterrupts (PDM_Type *base, uint32_t mask)
 Enables the PDM Voice Detector interrupt requests. More...
 
static void PDM_DisableHwvadInterrupts (PDM_Type *base, uint32_t mask)
 Disables the PDM Voice Detector interrupt requests. More...
 
static void PDM_ClearHwvadInterruptStatusFlags (PDM_Type *base, uint32_t mask)
 Clears the PDM voice activity detector status flags. More...
 
static uint32_t PDM_GetHwvadInterruptStatusFlags (PDM_Type *base)
 Clears the PDM voice activity detector status flags. More...
 
static uint32_t PDM_GetHwvadInitialFlag (PDM_Type *base)
 Get the PDM voice activity detector initial flags. More...
 
static uint32_t PDM_GetHwvadVoiceDetectedFlag (PDM_Type *base)
 Get the PDM voice activity detector voice detected flags. More...
 
static void PDM_EnableHwvadSignalFilter (PDM_Type *base, bool enable)
 Enables/disables voice activity detector signal filter. More...
 
void PDM_SetHwvadSignalFilterConfig (PDM_Type *base, bool enableMaxBlock, uint32_t signalGain)
 Configure voice activity detector signal filter. More...
 
void PDM_SetHwvadNoiseFilterConfig (PDM_Type *base, const pdm_hwvad_noise_filter_t *config)
 Configure voice activity detector noise filter. More...
 
static void PDM_EnableHwvadZeroCrossDetector (PDM_Type *base, bool enable)
 Enables/disables voice activity detector zero cross detector. More...
 
void PDM_SetHwvadZeroCrossDetectorConfig (PDM_Type *base, const pdm_hwvad_zero_cross_detector_t *config)
 Configure voice activity detector zero cross detector. More...
 
static uint16_t PDM_GetNoiseData (PDM_Type *base)
 Reads noise data. More...
 
static void PDM_SetHwvadInternalFilterStatus (PDM_Type *base, pdm_hwvad_filter_status_t status)
 set hwvad internal filter status . More...
 
void PDM_SetHwvadInEnvelopeBasedMode (PDM_Type *base, const pdm_hwvad_config_t *hwvadConfig, const pdm_hwvad_noise_filter_t *noiseConfig, const pdm_hwvad_zero_cross_detector_t *zcdConfig, uint32_t signalGain)
 set HWVAD in envelope based mode . More...
 
void PDM_SetHwvadInEnergyBasedMode (PDM_Type *base, const pdm_hwvad_config_t *hwvadConfig, const pdm_hwvad_noise_filter_t *noiseConfig, const pdm_hwvad_zero_cross_detector_t *zcdConfig, uint32_t signalGain)
 brief set HWVAD in energy based mode . More...
 

Transactional

void PDM_TransferCreateHandle (PDM_Type *base, pdm_handle_t *handle, pdm_transfer_callback_t callback, void *userData)
 Initializes the PDM handle. More...
 
status_t PDM_TransferSetChannelConfig (PDM_Type *base, pdm_handle_t *handle, uint32_t channel, const pdm_channel_config_t *config, uint32_t format)
 PDM set channel transfer config. More...
 
status_t PDM_TransferReceiveNonBlocking (PDM_Type *base, pdm_handle_t *handle, pdm_transfer_t *xfer)
 Performs an interrupt non-blocking receive transfer on PDM. More...
 
void PDM_TransferAbortReceive (PDM_Type *base, pdm_handle_t *handle)
 Aborts the current IRQ receive. More...
 
void PDM_TransferHandleIRQ (PDM_Type *base, pdm_handle_t *handle)
 Tx interrupt handler. More...
 

Data Structure Documentation

struct pdm_channel_config_t

Data Fields

pdm_dc_remover_t cutOffFreq
 DC remover cut off frequency.
 
pdm_df_output_gain_t gain
 Decimation Filter Output Gain.
 
struct pdm_config_t

Data Fields

bool enableDoze
 This module will enter disable/low leakage mode if DOZEN is active with ipg_doze is asserted.
 
uint8_t fifoWatermark
 Watermark value for FIFO.
 
pdm_df_quality_mode_t qualityMode
 Quality mode.
 
uint8_t cicOverSampleRate
 CIC filter over sampling rate.
 
struct pdm_hwvad_config_t

Data Fields

uint8_t channel
 Which channel uses voice activity detector.
 
uint8_t initializeTime
 Number of frames or samples to initialize voice activity detector. More...
 
uint8_t cicOverSampleRate
 CIC filter over sampling rate.
 
uint8_t inputGain
 Voice activity detector input gain.
 
uint32_t frameTime
 Voice activity frame time.
 
pdm_hwvad_hpf_config_t cutOffFreq
 High pass filter cut off frequency.
 
bool enableFrameEnergy
 If frame energy enabled, true means enable.
 
bool enablePreFilter
 If pre-filter enabled.
 

Field Documentation

uint8_t pdm_hwvad_config_t::initializeTime
struct pdm_hwvad_noise_filter_t

Data Fields

bool enableAutoNoiseFilter
 If noise fileter automatically activated, true means enable.
 
bool enableNoiseMin
 If Noise minimum block enabled, true means enabled.
 
bool enableNoiseDecimation
 If enable noise input decimation.
 
bool enableNoiseDetectOR
 Enables a OR logic in the output of minimum noise estimator block.
 
uint32_t noiseFilterAdjustment
 The adjustment value of the noise filter.
 
uint32_t noiseGain
 Gain value for the noise energy or envelope estimated.
 
struct pdm_hwvad_zero_cross_detector_t

Data Fields

bool enableAutoThreshold
 If ZCD auto-threshold enabled, true means enabled. More...
 
pdm_hwvad_zcd_result_t zcdAnd
 Is ZCD result is AND'ed with energy-based detection, false means OR'ed.
 
uint32_t threshold
 The adjustment value of the noise filter.
 
uint32_t adjustmentThreshold
 Gain value for the noise energy or envelope estimated.
 

Field Documentation

bool pdm_hwvad_zero_cross_detector_t::enableAutoThreshold
struct pdm_transfer_t

Data Fields

volatile uint8_t * data
 Data start address to transfer. More...
 
volatile size_t dataSize
 Total Transfer bytes size. More...
 

Field Documentation

volatile uint8_t* pdm_transfer_t::data
volatile size_t pdm_transfer_t::dataSize
struct _pdm_handle

PDM handle.

Data Fields

uint32_t state
 Transfer status.
 
pdm_transfer_callback_t callback
 Callback function called at transfer event.
 
void * userData
 Callback parameter passed to callback function.
 
pdm_transfer_t pdmQueue [PDM_XFER_QUEUE_SIZE]
 Transfer queue storing queued transfer.
 
size_t transferSize [PDM_XFER_QUEUE_SIZE]
 Data bytes need to transfer.
 
volatile uint8_t queueUser
 Index for user to queue transfer.
 
volatile uint8_t queueDriver
 Index for driver to get the transfer data and size.
 
uint32_t format
 data format
 
uint8_t watermark
 Watermark value.
 
uint8_t startChannel
 end channel
 
uint8_t channelNums
 Enabled channel number.
 

Enumeration Type Documentation

anonymous enum
Enumerator
kStatus_PDM_Busy 

PDM is busy.

kStatus_PDM_CLK_LOW 

PDM clock frequency low.

kStatus_PDM_FIFO_ERROR 

PDM FIFO underrun or overflow.

kStatus_PDM_QueueFull 

PDM FIFO underrun or overflow.

kStatus_PDM_Idle 

PDM is idle.

kStatus_PDM_Output_ERROR 

PDM is output error.

kStatus_PDM_ChannelConfig_Failed 

PDM channel config failed.

Enumerator
kPDM_ErrorInterruptEnable 

PDM channel error interrupt enable.

kPDM_FIFOInterruptEnable 

PDM channel FIFO interrupt.

Enumerator
kPDM_StatusDfBusyFlag 

Decimation filter is busy processing data.

kPDM_StatusFIRFilterReady 

FIR filter data is ready.

kPDM_StatusFrequencyLow 

Mic app clock frequency not high enough.

kPDM_StatusCh0FifoDataAvaliable 

channel 0 fifo data reached watermark level

kPDM_StatusCh1FifoDataAvaliable 

channel 1 fifo data reached watermark level

kPDM_StatusCh2FifoDataAvaliable 

channel 2 fifo data reached watermark level

kPDM_StatusCh3FifoDataAvaliable 

channel 3 fifo data reached watermark level

kPDM_StatusCh4FifoDataAvaliable 

channel 4 fifo data reached watermark level

kPDM_StatusCh5FifoDataAvaliable 

channel 5 fifo data reached watermark level

kPDM_StatusCh6FifoDataAvaliable 

channel 6 fifo data reached watermark level

kPDM_StatusCh7FifoDataAvaliable 

channel 7 fifo data reached watermark level

Enumerator
kPDM_EnableChannel0 

channgel 0 enable mask

kPDM_EnableChannel1 

channgel 1 enable mask

kPDM_EnableChannel2 

channgel 2 enable mask

kPDM_EnableChannel3 

channgel 3 enable mask

kPDM_EnableChannel4 

channgel 4 enable mask

kPDM_EnableChannel5 

channgel 5 enable mask

kPDM_EnableChannel6 

channgel 6 enable mask

kPDM_EnableChannel7 

channgel 7 enable mask

Enumerator
kPDM_FifoStatusUnderflowCh0 

channel0 fifo status underflow

kPDM_FifoStatusUnderflowCh1 

channel1 fifo status underflow

kPDM_FifoStatusUnderflowCh2 

channel2 fifo status underflow

kPDM_FifoStatusUnderflowCh3 

channel3 fifo status underflow

kPDM_FifoStatusUnderflowCh4 

channel4 fifo status underflow

kPDM_FifoStatusUnderflowCh5 

channel5 fifo status underflow

kPDM_FifoStatusUnderflowCh6 

channel6 fifo status underflow

kPDM_FifoStatusUnderflowCh7 

channel7 fifo status underflow

kPDM_FifoStatusOverflowCh0 

channel0 fifo status overflow

kPDM_FifoStatusOverflowCh1 

channel1 fifo status overflow

kPDM_FifoStatusOverflowCh2 

channel2 fifo status overflow

kPDM_FifoStatusOverflowCh3 

channel3 fifo status overflow

kPDM_FifoStatusOverflowCh4 

channel4 fifo status overflow

kPDM_FifoStatusOverflowCh5 

channel5 fifo status overflow

kPDM_FifoStatusOverflowCh6 

channel6 fifo status overflow

kPDM_FifoStatusOverflowCh7 

channel7 fifo status overflow

Enumerator
kPDM_RangeStatusUnderFlowCh0 

channel0 range status underflow

kPDM_RangeStatusUnderFlowCh1 

channel1 range status underflow

kPDM_RangeStatusUnderFlowCh2 

channel2 range status underflow

kPDM_RangeStatusUnderFlowCh3 

channel3 range status underflow

kPDM_RangeStatusUnderFlowCh4 

channel4 range status underflow

kPDM_RangeStatusUnderFlowCh5 

channel5 range status underflow

kPDM_RangeStatusUnderFlowCh6 

channel6 range status underflow

kPDM_RangeStatusUnderFlowCh7 

channel7 range status underflow

kPDM_RangeStatusOverFlowCh0 

channel0 range status overflow

kPDM_RangeStatusOverFlowCh1 

channel1 range status overflow

kPDM_RangeStatusOverFlowCh2 

channel2 range status overflow

kPDM_RangeStatusOverFlowCh3 

channel3 range status overflow

kPDM_RangeStatusOverFlowCh4 

channel4 range status overflow

kPDM_RangeStatusOverFlowCh5 

channel5 range status overflow

kPDM_RangeStatusOverFlowCh6 

channel6 range status overflow

kPDM_RangeStatusOverFlowCh7 

channel7 range status overflow

Enumerator
kPDM_DcRemoverCutOff21Hz 

DC remover cut off 21HZ.

kPDM_DcRemoverCutOff83Hz 

DC remover cut off 83HZ.

kPDM_DcRemoverCutOff152Hz 

DC remover cut off 152HZ.

kPDM_DcRemoverBypass 

DC remover bypass.

Enumerator
kPDM_QualityModeMedium 

quality mode memdium

kPDM_QualityModeHigh 

quality mode high

kPDM_QualityModeLow 

quality mode low

kPDM_QualityModeVeryLow0 

quality mode very low0

kPDM_QualityModeVeryLow1 

quality mode very low1

kPDM_QualityModeVeryLow2 

quality mode very low2

Enumerator
kPDM_QualityModeHighKFactor 

high quality mode K factor = 1 / 2

kPDM_QualityModeMediumKFactor 

medium/very low0 quality mode K factor = 2 / 2

kPDM_QualityModeLowKFactor 

low/very low1 quality mode K factor = 4 / 2

kPDM_QualityModeVeryLow2KFactor 

very low2 quality mode K factor = 8 / 2

Enumerator
kPDM_DfOutputGain0 

Decimation filter output gain 0.

kPDM_DfOutputGain1 

Decimation filter output gain 1.

kPDM_DfOutputGain2 

Decimation filter output gain 2.

kPDM_DfOutputGain3 

Decimation filter output gain 3.

kPDM_DfOutputGain4 

Decimation filter output gain 4.

kPDM_DfOutputGain5 

Decimation filter output gain 5.

kPDM_DfOutputGain6 

Decimation filter output gain 6.

kPDM_DfOutputGain7 

Decimation filter output gain 7.

kPDM_DfOutputGain8 

Decimation filter output gain 8.

kPDM_DfOutputGain9 

Decimation filter output gain 9.

kPDM_DfOutputGain10 

Decimation filter output gain 10.

kPDM_DfOutputGain11 

Decimation filter output gain 11.

kPDM_DfOutputGain12 

Decimation filter output gain 12.

kPDM_DfOutputGain13 

Decimation filter output gain 13.

kPDM_DfOutputGain14 

Decimation filter output gain 14.

kPDM_DfOutputGain15 

Decimation filter output gain 15.

Enumerator
kPDM_DataWwidth24 

PDM data width 24bit.

kPDM_DataWwidth32 

PDM data width 32bit.

Enumerator
kPDM_HwvadErrorInterruptEnable 

PDM channel HWVAD error interrupt enable.

kPDM_HwvadInterruptEnable 

PDM channel HWVAD interrupt.

Enumerator
kPDM_HwvadStatusInputSaturation 

HWVAD saturation condition.

kPDM_HwvadStatusVoiceDetectFlag 

HWVAD voice detect interrupt triggered.

Enumerator
kPDM_HwvadHpfBypassed 

High-pass filter bypass.

kPDM_HwvadHpfCutOffFreq1750Hz 

High-pass filter cut off frequency 1750HZ.

kPDM_HwvadHpfCutOffFreq215Hz 

High-pass filter cut off frequency 215HZ.

kPDM_HwvadHpfCutOffFreq102Hz 

High-pass filter cut off frequency 102HZ.

Enumerator
kPDM_HwvadInternalFilterNormalOperation 

internal filter ready for normal operation

kPDM_HwvadInternalFilterInitial 

interla filter are initial

Enumerator
kPDM_HwvadResultOREnergyBasedDetection 

zero cross detector result will be OR with energy based detection

kPDM_HwvadResultANDEnergyBasedDetection 

zero cross detector result will be AND with energy based detection

Function Documentation

void PDM_Init ( PDM_Type *  base,
const pdm_config_t config 
)

Ungates the PDM clock, resets the module, and configures PDM with a configuration structure. The configuration structure can be custom filled or set with default values by PDM_GetDefaultConfig().

Note
This API should be called at the beginning of the application to use the PDM driver. Otherwise, accessing the PDM module can cause a hard fault because the clock is not enabled.
Parameters
basePDM base pointer
configPDM configuration structure.
void PDM_Deinit ( PDM_Type *  base)

This API gates the PDM clock. The PDM module can't operate unless PDM_Init is called to enable the clock.

Parameters
basePDM base pointer
static void PDM_Reset ( PDM_Type *  base)
inlinestatic
Parameters
basePDM base pointer
static void PDM_Enable ( PDM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
basePDM base pointer
enableTrue means PDM interface is enabled, false means PDM interface is disabled.
static void PDM_EnableDoze ( PDM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
basePDM base pointer
enableTrue means the module will enter Disable/Low Leakage mode when ipg_doze is asserted, false means the module will not enter Disable/Low Leakage mode when ipg_doze is asserted.
static void PDM_EnableDebugMode ( PDM_Type *  base,
bool  enable 
)
inlinestatic

The PDM interface cannot enter debug mode once in Disable/Low Leakage or Low Power mode.

Parameters
basePDM base pointer
enableTrue means PDM interface enter debug mode, false means PDM interface in normal mode.
static void PDM_EnableInDebugMode ( PDM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
basePDM base pointer
enableTrue means PDM interface is enabled debug mode, false means PDM interface is disabled after after completing the current frame in debug mode.
static void PDM_EnterLowLeakageMode ( PDM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
basePDM base pointer
enableTrue means PDM interface is in disable/low leakage mode, False means PDM interface is in normal mode.
static void PDM_EnableChannel ( PDM_Type *  base,
uint8_t  channel,
bool  enable 
)
inlinestatic
Parameters
basePDM base pointer
channelPDM channel number need to enable or disable.
enableTrue means enable PDM channel, false means disable.
void PDM_SetChannelConfig ( PDM_Type *  base,
uint32_t  channel,
const pdm_channel_config_t config 
)
Parameters
basePDM base pointer
configPDM channel configurations.
channelchannel number. after completing the current frame in debug mode.
status_t PDM_SetSampleRateConfig ( PDM_Type *  base,
uint32_t  sourceClock_HZ,
uint32_t  sampleRate_HZ 
)
Note
This function is depend on the configuration of the PDM and PDM channel, so the correct call sequence is
* PDM_Init(base, pdmConfig)
* PDM_SetChannelConfig(base, channel, &channelConfig)
* PDM_SetSampleRateConfig(base, source, sampleRate)
*
Parameters
basePDM base pointer
sourceClock_HZPDM source clock frequency.
sampleRate_HZPDM sample rate.
status_t PDM_SetSampleRate ( PDM_Type *  base,
uint32_t  enableChannelMask,
pdm_df_quality_mode_t  qualityMode,
uint8_t  osr,
uint32_t  clkDiv 
)
Deprecated:
Do not use this function. It has been superceded by PDM_SetSampleRateConfig
Parameters
basePDM base pointer
enableChannelMaskPDM channel enable mask.
qualityModequality mode.
osrcic oversample rate
clkDivclock divider
uint32_t PDM_GetInstance ( PDM_Type *  base)
Parameters
basePDM base pointer.
static uint32_t PDM_GetStatus ( PDM_Type *  base)
inlinestatic

Use the Status Mask in _pdm_internal_status to get the status value needed

Parameters
basePDM base pointer
Returns
PDM status flag value.
static uint32_t PDM_GetFifoStatus ( PDM_Type *  base)
inlinestatic

Use the Status Mask in _pdm_fifo_status to get the status value needed

Parameters
basePDM base pointer
Returns
FIFO status.
static uint32_t PDM_GetRangeStatus ( PDM_Type *  base)
inlinestatic

Use the Status Mask in _pdm_range_status to get the status value needed

Parameters
basePDM base pointer
Returns
output status.
static void PDM_ClearStatus ( PDM_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
basePDM base pointer
maskState mask. It can be a combination of the status between kPDM_StatusFrequencyLow and kPDM_StatusCh7FifoDataAvaliable.
static void PDM_ClearFIFOStatus ( PDM_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
basePDM base pointer
maskState mask.It can be a combination of the status in _pdm_fifo_status.
static void PDM_ClearRangeStatus ( PDM_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
basePDM base pointer
maskState mask. It can be a combination of the status in _pdm_range_status.
void PDM_EnableInterrupts ( PDM_Type *  base,
uint32_t  mask 
)
Parameters
basePDM base pointer
maskinterrupt source The parameter can be a combination of the following sources if defined.
  • kPDM_ErrorInterruptEnable
  • kPDM_FIFOInterruptEnable
static void PDM_DisableInterrupts ( PDM_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
basePDM base pointer
maskinterrupt source The parameter can be a combination of the following sources if defined.
  • kPDM_ErrorInterruptEnable
  • kPDM_FIFOInterruptEnable
static void PDM_EnableDMA ( PDM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
basePDM base pointer
enableTrue means enable DMA, false means disable DMA.
static uint32_t PDM_GetDataRegisterAddress ( PDM_Type *  base,
uint32_t  channel 
)
inlinestatic

This API is used to provide a transfer address for the PDM DMA transfer configuration.

Parameters
basePDM base pointer.
channelWhich data channel used.
Returns
data register address.
void PDM_ReadFifo ( PDM_Type *  base,
uint32_t  startChannel,
uint32_t  channelNums,
void *  buffer,
size_t  size,
uint32_t  dataWidth 
)
Note
: This function support 16 bit only for IP version that only supports 16bit.
Parameters
basePDM base pointer.
startChannelstart channel number.
channelNumstotal enabled channelnums.
bufferreceived buffer address.
sizenumber of samples to read.
dataWidthsample width.
static uint32_t PDM_ReadData ( PDM_Type *  base,
uint32_t  channel 
)
inlinestatic
Parameters
basePDM base pointer.
channelData channel used.
Returns
Data in PDM FIFO.
void PDM_SetHwvadConfig ( PDM_Type *  base,
const pdm_hwvad_config_t config 
)
Parameters
basePDM base pointer
configVoice activity detector configure structure pointer .
static void PDM_ForceHwvadOutputDisable ( PDM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
basePDM base pointer
enabletrue is output force disable, false is output not force.
static void PDM_ResetHwvad ( PDM_Type *  base)
inlinestatic

It will reset VADNDATA register and will clean all internal buffers, should be called when the PDM isn't running.

Parameters
basePDM base pointer
static void PDM_EnableHwvad ( PDM_Type *  base,
bool  enable 
)
inlinestatic

Should be called when the PDM isn't running.

Parameters
basePDM base pointer.
enableTrue means enable voice activity detector, false means disable.
static void PDM_EnableHwvadInterrupts ( PDM_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
basePDM base pointer
maskinterrupt source The parameter can be a combination of the following sources if defined.
  • kPDM_HWVADErrorInterruptEnable
  • kPDM_HWVADInterruptEnable
static void PDM_DisableHwvadInterrupts ( PDM_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
basePDM base pointer
maskinterrupt source The parameter can be a combination of the following sources if defined.
  • kPDM_HWVADErrorInterruptEnable
  • kPDM_HWVADInterruptEnable
static void PDM_ClearHwvadInterruptStatusFlags ( PDM_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
basePDM base pointer
maskState mask,reference _pdm_hwvad_int_status.
static uint32_t PDM_GetHwvadInterruptStatusFlags ( PDM_Type *  base)
inlinestatic
Parameters
basePDM base pointer
Returns
status, reference _pdm_hwvad_int_status
static uint32_t PDM_GetHwvadInitialFlag ( PDM_Type *  base)
inlinestatic
Parameters
basePDM base pointer
Returns
initial flag.
static uint32_t PDM_GetHwvadVoiceDetectedFlag ( PDM_Type *  base)
inlinestatic

NOte: this flag is auto cleared when voice gone.

Parameters
basePDM base pointer
Returns
voice detected flag.
static void PDM_EnableHwvadSignalFilter ( PDM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
basePDM base pointer
enableTrue means enable signal filter, false means disable.
void PDM_SetHwvadSignalFilterConfig ( PDM_Type *  base,
bool  enableMaxBlock,
uint32_t  signalGain 
)
Parameters
basePDM base pointer
enableMaxBlockIf signal maximum block enabled.
signalGainGain value for the signal energy.
void PDM_SetHwvadNoiseFilterConfig ( PDM_Type *  base,
const pdm_hwvad_noise_filter_t config 
)
Parameters
basePDM base pointer
configVoice activity detector noise filter configure structure pointer .
static void PDM_EnableHwvadZeroCrossDetector ( PDM_Type *  base,
bool  enable 
)
inlinestatic
Parameters
basePDM base pointer
enableTrue means enable zero cross detector, false means disable.
void PDM_SetHwvadZeroCrossDetectorConfig ( PDM_Type *  base,
const pdm_hwvad_zero_cross_detector_t config 
)
Parameters
basePDM base pointer
configVoice activity detector zero cross detector configure structure pointer .
static uint16_t PDM_GetNoiseData ( PDM_Type *  base)
inlinestatic
Parameters
basePDM base pointer.
Returns
Data in PDM noise data register.
static void PDM_SetHwvadInternalFilterStatus ( PDM_Type *  base,
pdm_hwvad_filter_status_t  status 
)
inlinestatic

Note: filter initial status should be asserted for two more cycles, then set it to normal operation.

Parameters
basePDM base pointer.
statusinternal filter status.
void PDM_SetHwvadInEnvelopeBasedMode ( PDM_Type *  base,
const pdm_hwvad_config_t hwvadConfig,
const pdm_hwvad_noise_filter_t noiseConfig,
const pdm_hwvad_zero_cross_detector_t zcdConfig,
uint32_t  signalGain 
)

Recommand configurations,

* static const pdm_hwvad_config_t hwvadConfig = {
* .channel = 0,
* .initializeTime = 10U,
* .cicOverSampleRate = 0U,
* .inputGain = 0U,
* .frameTime = 10U,
* .cutOffFreq = kPDM_HwvadHpfBypassed,
* .enableFrameEnergy = false,
* .enablePreFilter = true,
};
* static const pdm_hwvad_noise_filter_t noiseFilterConfig = {
* .enableNoiseMin = true,
* .enableNoiseDecimation = true,
* .noiseFilterAdjustment = 0U,
* .noiseGain = 7U,
* .enableNoiseDetectOR = true,
* };
*
Parameters
basePDM base pointer.
hwvadConfiginternal filter status.
noiseConfigVoice activity detector noise filter configure structure pointer.
zcdConfigVoice activity detector zero cross detector configure structure pointer .
signalGainsignal gain value.
void PDM_SetHwvadInEnergyBasedMode ( PDM_Type *  base,
const pdm_hwvad_config_t hwvadConfig,
const pdm_hwvad_noise_filter_t noiseConfig,
const pdm_hwvad_zero_cross_detector_t zcdConfig,
uint32_t  signalGain 
)

Recommand configurations, code static const pdm_hwvad_config_t hwvadConfig = { .channel = 0, .initializeTime = 10U, .cicOverSampleRate = 0U, .inputGain = 0U, .frameTime = 10U, .cutOffFreq = kPDM_HwvadHpfBypassed, .enableFrameEnergy = true, .enablePreFilter = true, };

static const pdm_hwvad_noise_filter_t noiseFilterConfig = { .enableAutoNoiseFilter = true, .enableNoiseMin = false, .enableNoiseDecimation = false, .noiseFilterAdjustment = 0U, .noiseGain = 7U, .enableNoiseDetectOR = false, }; code param base PDM base pointer. param hwvadConfig internal filter status. param noiseConfig Voice activity detector noise filter configure structure pointer. param zcdConfig Voice activity detector zero cross detector configure structure pointer . param signalGain signal gain value, signal gain value should be properly according to application.

void PDM_TransferCreateHandle ( PDM_Type *  base,
pdm_handle_t *  handle,
pdm_transfer_callback_t  callback,
void *  userData 
)

This function initializes the handle for the PDM transactional APIs. Call this function once to get the handle initialized.

Parameters
basePDM base pointer.
handlePDM handle pointer.
callbackPointer to the user callback function.
userDataUser parameter passed to the callback function.
status_t PDM_TransferSetChannelConfig ( PDM_Type *  base,
pdm_handle_t *  handle,
uint32_t  channel,
const pdm_channel_config_t config,
uint32_t  format 
)
Parameters
basePDM base pointer.
handlePDM handle pointer.
channelPDM channel.
configchannel config.
formatdata format, support data width configurations,_pdm_data_width.
Return values
kStatus_PDM_ChannelConfig_Failedor kStatus_Success.
status_t PDM_TransferReceiveNonBlocking ( PDM_Type *  base,
pdm_handle_t *  handle,
pdm_transfer_t xfer 
)
Note
This API returns immediately after the transfer initiates. Call the PDM_RxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_PDM_Busy, the transfer is finished.
Parameters
basePDM base pointer
handlePointer to the pdm_handle_t structure which stores the transfer state.
xferPointer to the pdm_transfer_t structure.
Return values
kStatus_SuccessSuccessfully started the data receive.
kStatus_PDM_BusyPrevious receive still not finished.
void PDM_TransferAbortReceive ( PDM_Type *  base,
pdm_handle_t *  handle 
)
Note
This API can be called when an interrupt non-blocking transfer initiates to abort the transfer early.
Parameters
basePDM base pointer
handlePointer to the pdm_handle_t structure which stores the transfer state.
void PDM_TransferHandleIRQ ( PDM_Type *  base,
pdm_handle_t *  handle 
)
Parameters
basePDM base pointer.
handlePointer to the pdm_handle_t structure.