ESP32 provides a second-order sigma delta modulation module and 8 (4 for ESP32-C3) independent modulation channels. The channels are capable to output 1-bit signals (output index: 100 ~ 107) with sigma delta modulation.
ESP32 SoC | Number of SigmaDelta channels |
---|---|
ESP32 | 8 |
ESP32-S2 | 8 |
ESP32-S3 | 8 |
ESP32-C3 | 4 |
ESP32-C6 | 4 |
ESP32-H2 | 4 |
This function is used to set up the SigmaDelta channel with the selected frequency and attach it to the selected pin.
bool sigmaDeltaAttach(uint8_t pin, uint32_t freq);
pin
select GPIO pin.freq
select frequency.- range is 1-14 bits (1-20 bits for ESP32).
This function returns true
if the configuration was successful.
If false
is returned, an error occurred and the SigmaDelta channel was not configured.
This function is used to set duty for the SigmaDelta pin.
bool sigmaDeltaWrite(uint8_t pin, uint8_t duty);
pin
selects the GPIO pin.duty
selects the duty to be set for selected pin.
This function returns true
if setting the duty was successful.
If false
is returned, error occurs and duty was not set.
This function is used to detach a pin from SigmaDelta and deinit the channel that was attached to the pin.
bool sigmaDeltaDetach(uint8_t pin);
pin
select GPIO pin.
This function returns true
if detaching was successful.
If false
is returned, an error occurred and pin was not detached.
Here is example use of SigmaDelta:
.. literalinclude:: ../../../libraries/ESP32/examples/AnalogOut/SigmaDelta/SigmaDelta.ino :language: arduino