Is it possible to make a MAX98357A class-D amplifier work with a normal Arduino? I've only found solutions based on an ESP32. If not, why not, and is there a solution or an alternative solution?
-
\$\begingroup\$ thx, updated the title. \$\endgroup\$– playmoboxCommented Apr 3, 2023 at 21:31
-
\$\begingroup\$ @playmobox OK, what audio file? MP3, OGG, WMA, etc? Well, it does not matter, it's still impossible, or at least impractical. \$\endgroup\$– JustmeCommented Apr 3, 2023 at 21:49
2 Answers
The MAX98357A uses I2S to receive audio for amplification, and the ATmega32 doesn't have an I2S peripheral/interface, so no, they don't play together.
The ATmega32 doesn't have a DAC either, so generating analog audio is out as well. You could use PWM (with a low-pass filter) for audio out and amplify that, but you can't use the MAX98357A for that.
If you want to work with I2S and the MAX98357A, you need a different microcontroller/Arduino; the SAMD21-based Arduinos have I2S (and a DAC), for example. If you want to generate and amplify audio using PWM with an ATmega32, you need a different amplifier.
-
\$\begingroup\$ I've never tried it, but is there something which prevents us using the SPI of the ATMega328 to generate the I2S signals? \$\endgroup\$ Commented Apr 3, 2023 at 8:12
-
\$\begingroup\$ @jonathanjo Yes, SPI and I2S protocols are not compatible and ATMega328 SPI module has no I2S mode even if some other MCUs do. It is just an underpowered and unsuitable MCU for I2S and any 32-bit ARM with DMA supported I2S would be more suitable. \$\endgroup\$– JustmeCommented Apr 3, 2023 at 21:34
-
\$\begingroup\$ @jonathanjo I2S is a lot more like I2C than SPI. You might be able to get things to work using an I2C peripheral, but definitely not SPI. \$\endgroup\$– HearthCommented Apr 4, 2023 at 3:25
-
1
-
\$\begingroup\$ Okay, after doing some research, I landed at the microcontroller STM32F103VCT6 because it has build in I2S, DAC, USB support, is faster and even cheaper (2.40$) than ATMEGA328P (2.9$). \$\endgroup\$ Commented Apr 7, 2023 at 3:04
No because the Atmega32 has no I2S digital audio interfaces which the audio DAC amplifier chip requires.
There is no solution to connect them that would make sense, as the Atmega32 has no capabilities to move around streams of I2S audio data in software.
An alternative solution can't be suggested, because it is unknown what you are trying to achieve and why, so what would fit to your specs is unknown and it would be also off-topic to suggest what to buy.