sdm_channel_set_pulse_density() function
Set the pulse density of the PDM output signal.
Arguments
chan
SDM channel created by `sdm_new_channel`
density
Quantized pulse density of the PDM output signal, ranges from -128 to 127. But the range of [-90, 90] can provide a better randomness.
Return value
- ESP_OK: Set pulse density successfully - ESP_ERR_INVALID_ARG: Set pulse density failed because of invalid argument - ESP_FAIL: Set pulse density failed because of other error
Notes
The raw output signal requires a low-pass filter to restore it into analog voltage, the restored analog output voltage could be Vout = VDD_IO / 256 * density + VDD_IO / 2 This function is allowed to run within ISR context This function will be placed into IRAM if `CONFIG_SDM_CTRL_FUNC_IN_IRAM` is on, so that it's allowed to be executed when Cache is disabled
sdm_channel_set_pulse_density() calls 6 functions:
![]()
sdm_channel_set_pulse_density()
sdm_channel_set_pulse_density() reads 6 variables:
![]()
sdm_channel_set_pulse_density()