Closed waruqi closed 1 year ago
Do you mean controlling the gain of MAX98357
? According to the datasheet, it seems to be controlled by pull-up/pull-down resistors.
Do you mean controlling the gain of
MAX98357
? According to the datasheet, it seems to be controlled by pull-up/pull-down resistors.
What api should I use to control it? pwm? gpio? ledc?
chatgpt tell me:
#include "driver/gpio.h"
#include "driver/dac.h"
void set_volume(int volume) {
gpio_set_direction(GPIO_NUM_25, GPIO_MODE_OUTPUT);
int voltage = volume * 255 / 100;
dac_output_voltage(DAC_CHANNEL_1, voltage);
}
or
gpio_set_direction(6, GPIO_MODE_OUTPUT);
gpio_set_level(6, 1);
ets_delay_us(900);
gpio_set_level(6, 0);
ets_delay_us(100);
Is it correct?
The ChatGPT didn't give a correct answer... You can search the datasheet of MAX98357 online or the official website of Analog Devices
Here is the datasheet I found: https://www.analog.com/media/en/technical-documentation/data-sheets/MAX98357A-MAX98357B.pdf
In the section Gain Selection
, the table shows how to set the gain by pull-up or pull-down resistor:
That means the gain should NOT controlled by a GPIO theoretically, it's supposed to be fixed according to your PCB design. If you have to control it by a GPIO, you may try to tie a GPIO to the GAIN_SLOT
pin of MAX98357
and set the gpio pulled up/ pulled down or float to select the different gain. But I can't guarantee it will work, please read the MAX98357
datasheet carefully to see if it support to be controlled by a GPIO.
thanks!
maybe problem solve whit 100k pot. Because manual says need analog voltage
Answers checklist.
General issue report
I have a MAX98357 I2S module, I want to control it's volume.
How do I read and write its gain gpio to control the volume?