The pulse-density modulation to pulse-code modulation (PDM-PCM) driver provides an API to manage PDM-PCM conversion. A PDM-PCM converter is used to convert 1-bit digital audio streaming data to PCM data.
The functions and other declarations used in this driver are in cy_pdm_pcm.h. You can include cy_pdl.h to get access to all functions and declarations in the PDL.
Features:
Pulse-density modulation, or PDM, represents an analog signal with a binary signal. In a PDM signal, specific amplitude values are not encoded into codewords of pulses of different weight as they would be in pulse-code modulation (PCM); rather, the relative density of the pulses corresponds to the analog signal's amplitude. The output of a 1-bit DAC is the same as the PDM encoding of the signal.
Pulse-code modulation (PCM) is the method used to digitally represent sampled analog signals. It is the standard form of digital audio in computers, compact discs, digital telephony, and other digital audio applications. In a PCM stream, the amplitude of the analog signal is sampled regularly at uniform intervals, and each sample is quantized to the nearest value within a range of digital steps.
To set up a PDM-PCM, provide the configuration parameters in the cy_stc_pdm_pcm_config_t structure.
For example, set dataStreamingEnable to true, configure rxFifoTriggerLevel, dmaTriggerEnable (depending on whether DMA is going to be used), provide clock settings (clkDiv, mclkDiv and ckoDiv), set sincDecRate to the appropriate decimation rate, wordLen, and wordBitExtension. No other parameters are necessary for this example.
To initialize the PDM-PCM block, call the Cy_PDM_PCM_Init function, providing the filled cy_stc_pdm_pcm_config_t structure.
If you use a DMA, the DMA channel should be previously configured. PDM-PCM interrupts (if applicable) can be enabled by calling Cy_PDM_PCM_SetInterruptMask.
For example, if the trigger interrupt is used during operation, the ISR should call the Cy_PDM_PCM_ReadFifo as many times as required for your FIFO payload. Then call Cy_PDM_PCM_ClearInterrupt with appropriate parameters.
If a DMA is used and the DMA channel is properly configured, no CPU activity (or application code) is needed for PDM-PCM operation.
See: the PDM-PCM chapter of the device technical reference manual (TRM); the PDM_PCM_PDL Component datasheet; CE219431 - PSOC 6 MCU PDM-TO-PCM EXAMPLE.
Version | Changes | Reason for Change |
---|---|---|
2.30.1 | Added Note that this driver supports CAT1A devices only. | To avoid misunderstanding of pdm_pcm and pdm_pcm_v2 drivers usage. |
2.30 | Fixed MISRA 2012 violations. | MISRA 2012 compliance. |
2.20.2 | Minor documentation updates. | Documentation enhancement. |
2.20.1 | Snippet updated. | Old snippet outdated. |
2.20 | Flattened the organization of the driver source code into the single source directory and the single include directory. | Driver library directory-structure simplification. |
Added register access layer. Use register access macros instead of direct register access using dereferenced pointers. | Makes register access device-independent, so that the PDL does not need to be recompiled for each supported part number. | |
2.10 | The gain values in range +4.5...+10.5dB (5 items) of /ref cy_en_pdm_pcm_gain_t are corrected. Added Low Power Callback section. | Incorrect setting of gain values in limited range. Documentation update and clarification. |
2.0 | Enumeration types for gain and soft mute cycles are added.
The next functions behaviour are modified:
The Cy_PDM_PCM_GetFifoNumWords function is renamed to Cy_PDM_PCM_GetNumInFifo. | Improvements based on usability feedbacks. API is reworked for consistency within the PDL. |
1.0 | Initial version |
API Reference | |
Macros | |
Functions | |
Data Structures | |
Enumerated Types | |