PDM - Pulse Density Modulation#
Pulse Density Modulation API.
Modules#
Enumerations#
Configure channel clock polarity.
Configure FIFO Data valid level water-mark.
Configure PDM filter data output format.
Configure number of PDM channels.
Configure order of the PDM filter.
Variables#
Enable stereo mode for channel pair CH0 and CH1.
PDM filter order.
Number of PDM channels.
PDM filter data output format.
FIFO Data valid level water-mark.
Ch 0 clock polarity.
Ch 1 clock polarity.
PDM gain.
PDM down sampling rate.
PDM clock prescaler, resulting PDM clock is input clock / (prescaler + 1).
Functions#
Initialize the PDM peripheral.
Initialize PDM registers with reset values.
Waits for the PDM to complete all synchronization of register changes and commands.
Waits for the PDM to complete disabling procedure.
Enable the PDM peripheral.
Disable the PDM peripheral.
Clear the PDM filter.
Flush the PDM sample FIFO.
Start the PDM operation (start the PDM filter).
Stop the PDM operation (stop the PDM filter).
Read one entry from the PDM FIFO.
Get the PDM STATUS register.
Clear one or more pending PDM interrupts.
Set one or more pending PDM interrupts.
Enable one or more PDM interrupts.
Disable one or more PDM interrupts.
Get pending PDM interrupt flags.
Get enabled and pending PDM interrupt flags.
Macros#
Default PDM clock prescaler value, no prescaling.
Default PDM down sampling rate, 32 times oversampling.
Default PDM gain, 5 dB.
Default configuration for PDM.
Enumeration Documentation#
sl_hal_pdm_ch_clock_polarity_t#
sl_hal_pdm_ch_clock_polarity_t
Configure channel clock polarity.
| Enumerator | |
|---|---|
| SL_HAL_PDM_CH_CLOCK_POLARITY_RISING_EDGE | Input data clocked on rising clock edge. |
| SL_HAL_PDM_CH_CLOCK_POLARITY_FALLING_EDGE | Input data clocked on falling clock edge. |
sl_hal_pdm_fifo_valid_watermark_t#
sl_hal_pdm_fifo_valid_watermark_t
Configure FIFO Data valid level water-mark.
| Enumerator | |
|---|---|
| SL_HAL_PDM_FIFO_VALID_WATERMARK_ONE | At least one word. |
| SL_HAL_PDM_FIFO_VALID_WATERMARK_TWO | Two words. |
| SL_HAL_PDM_FIFO_VALID_WATERMARK_THREE | Three words. |
| SL_HAL_PDM_FIFO_VALID_WATERMARK_FOUR | Four words. |
sl_hal_pdm_data_format_t#
sl_hal_pdm_data_format_t
Configure PDM filter data output format.
| Enumerator | |
|---|---|
| SL_HAL_PDM_DATA_FORMAT_RIGHT_16 | Right aligned 16-bit, left bits are sign extended. |
| SL_HAL_PDM_DATA_FORMAT_DOUBLE_16 | Pack two 16-bit samples into one 32-bit word. |
| SL_HAL_PDM_DATA_FORMAT_RIGHT_24 | Right aligned 24bit, left bits are sign extended. |
| SL_HAL_PDM_DATA_FORMAT_FULL_32BIT | 32 bit data. |
| SL_HAL_PDM_DATA_FORMAT_LEFT_16 | Left aligned 16-bit, right bits are zeros. |
| SL_HAL_PDM_DATA_FORMAT_LEFT_24 | Left aligned 24-bit, right bits are zeros. |
| SL_HAL_PDM_DATA_FORMAT_RAW_32BIT | RAW 32 bit data from integrator. |
sl_hal_pdm_number_of_channels_t#
sl_hal_pdm_number_of_channels_t
Configure number of PDM channels.
| Enumerator | |
|---|---|
| SL_HAL_PDM_NUMBER_OF_CHANNELS_ONE | Only one Channel. |
| SL_HAL_PDM_NUMBER_OF_CHANNELS_TWO | Two Channels. |
sl_hal_pdm_filter_order_t#
sl_hal_pdm_filter_order_t
Configure order of the PDM filter.
| Enumerator | |
|---|---|
| SL_HAL_PDM_FILTER_ORDER_SECOND | Second order filter. |
| SL_HAL_PDM_FILTER_ORDER_THIRD | Third order filter. |
| SL_HAL_PDM_FILTER_ORDER_FOURTH | Fourth order filter. |
| SL_HAL_PDM_FILTER_ORDER_FIFTH | Fifth order filter. |
Variable Documentation#
ch0ch1_stereo_enable#
bool sl_hal_pdm_init_t::ch0ch1_stereo_enable
Enable stereo mode for channel pair CH0 and CH1.
number_channels#
sl_hal_pdm_number_of_channels_t sl_hal_pdm_init_t::number_channels
Number of PDM channels.
fifo_valid_watermark#
sl_hal_pdm_fifo_valid_watermark_t sl_hal_pdm_init_t::fifo_valid_watermark
FIFO Data valid level water-mark.
ch0_clock_polarity#
sl_hal_pdm_ch_clock_polarity_t sl_hal_pdm_init_t::ch0_clock_polarity
Ch 0 clock polarity.
ch1_clock_polarity#
sl_hal_pdm_ch_clock_polarity_t sl_hal_pdm_init_t::ch1_clock_polarity
Ch 1 clock polarity.
clk_prescaler#
uint32_t sl_hal_pdm_init_t::clk_prescaler
PDM clock prescaler, resulting PDM clock is input clock / (prescaler + 1).
Function Documentation#
sl_hal_pdm_init#
void sl_hal_pdm_init (PDM_TypeDef * pdm, const sl_hal_pdm_init_t * init)
Initialize the PDM peripheral.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
| const sl_hal_pdm_init_t * | [in] | init | A pointer to the initialization structure used to configure the PDM. |
This function will configure basic settings in PDM according to values in the initialization data structure. Notice that enabling of PDM clock, setup of PDM pins and setup of PRS is not covered by this function.
sl_hal_pdm_reset#
void sl_hal_pdm_reset (PDM_TypeDef * pdm)
Initialize PDM registers with reset values.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
sl_hal_pdm_wait_sync#
void sl_hal_pdm_wait_sync (PDM_TypeDef * pdm)
Waits for the PDM to complete all synchronization of register changes and commands.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
sl_hal_pdm_wait_ready#
void sl_hal_pdm_wait_ready (PDM_TypeDef * pdm)
Waits for the PDM to complete disabling procedure.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
Note
This function is only needed if the PDM peripheral supports disabling bit in the EN register. If the PDM peripheral doesn't support, this function will do nothing.
sl_hal_pdm_enable#
void sl_hal_pdm_enable (PDM_TypeDef * pdm)
Enable the PDM peripheral.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
sl_hal_pdm_disable#
void sl_hal_pdm_disable (PDM_TypeDef * pdm)
Disable the PDM peripheral.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
sl_hal_pdm_clear#
void sl_hal_pdm_clear (PDM_TypeDef * pdm)
Clear the PDM filter.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
sl_hal_pdm_fifo_flush#
void sl_hal_pdm_fifo_flush (PDM_TypeDef * pdm)
Flush the PDM sample FIFO.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
sl_hal_pdm_start#
void sl_hal_pdm_start (PDM_TypeDef * pdm)
Start the PDM operation (start the PDM filter).
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
sl_hal_pdm_stop#
void sl_hal_pdm_stop (PDM_TypeDef * pdm)
Stop the PDM operation (stop the PDM filter).
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
sl_hal_pdm_rx#
uint32_t sl_hal_pdm_rx (PDM_TypeDef * pdm)
Read one entry from the PDM FIFO.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
Returns
The entry read from the FIFO.
Note
This function will wait until a sample is available in the FIFO. Depending on PDM configuration, a FIFO entry can consist of one or two samples.
sl_hal_pdm_get_status#
uint32_t sl_hal_pdm_get_status (PDM_TypeDef * pdm)
Get the PDM STATUS register.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
Returns
STATUS register value.
sl_hal_pdm_clear_interrupts#
void sl_hal_pdm_clear_interrupts (PDM_TypeDef * pdm, uint32_t flags)
Clear one or more pending PDM interrupts.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
| uint32_t | [in] | flags | Pending PDM interrupt sources to clear. Use one or more valid interrupt flags for the PDM module. The flags are PDM_IFC_DV, PDM_IFC_DVL, PDM_IFC_OF and PDM_IFC_UF. |
sl_hal_pdm_set_interrupts#
void sl_hal_pdm_set_interrupts (PDM_TypeDef * pdm, uint32_t flags)
Set one or more pending PDM interrupts.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
| uint32_t | [in] | flags | PDM interrupt sources to set to pending. Use one or more valid interrupt flags for the PDM module. The flags are PDM_IFS_DV, PDM_IFS_DVL, PDM_IFS_OF and PDM_IFS_UF. |
sl_hal_pdm_enable_interrupts#
void sl_hal_pdm_enable_interrupts (PDM_TypeDef * pdm, uint32_t flags)
Enable one or more PDM interrupts.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
| uint32_t | [in] | flags | PDM interrupt sources to enable. Use one or more valid interrupt flags for the PDM module. The flags are PDM_IEN_DV, PDM_IEN_DVL, PDM_IEN_OF and PDM_IEN_UF. |
Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using sl_hal_pdm_clear_interrupts() prior to enabling the interrupt.
sl_hal_pdm_disable_interrupts#
void sl_hal_pdm_disable_interrupts (PDM_TypeDef * pdm, uint32_t flags)
Disable one or more PDM interrupts.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
| uint32_t | [in] | flags | PDM interrupt sources to disable. Use one or more valid interrupt flags for the PDM module. The flags are PDM_IEN_DV, PDM_IEN_DVL, PDM_IEN_OF and PDM_IEN_UF. |
sl_hal_pdm_get_pending_interrupts#
uint32_t sl_hal_pdm_get_pending_interrupts (PDM_TypeDef * pdm)
Get pending PDM interrupt flags.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
Returns
PDM interrupt sources pending. Returns one or more valid interrupt flags for PDM module. The flags are PDM_IF_DV, PDM_IF_DVL, PDM_IF_OF and PDM_IF_UF.
Note
Event bits are not cleared by the use of this function.
sl_hal_pdm_get_enabled_pending_interrupts#
uint32_t sl_hal_pdm_get_enabled_pending_interrupts (PDM_TypeDef * pdm)
Get enabled and pending PDM interrupt flags.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| PDM_TypeDef * | [in] | pdm | A pointer to the PDM peripheral register block. |
Useful for handling more interrupt sources in the same interrupt handler.
Returns
Pending and enabled PDM interrupt sources Return value is the bitwise AND of
the enabled interrupt sources in PDM_IEN and
the pending interrupt flags PDM_IF
Note
Interrupt flags are not cleared by the use of this function.