1

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?

enter image description here

ocrdu
  • 8,705
  • 21
  • 30
  • 42
playmobox
  • 91
  • 8

2 Answers2

2

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.

Justme
  • 127,425
  • 3
  • 97
  • 261
2

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.

ocrdu
  • 8,705
  • 21
  • 30
  • 42
  • I've never tried it, but is there something which prevents us using the SPI of the ATMega328 to generate the I2S signals? – jonathanjo Apr 03 '23 at 08:12
  • @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. – Justme Apr 03 '23 at 21:34
  • @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. – Hearth Apr 04 '23 at 03:25
  • 1
    I was comparing the timing diagram 19.4 of [datasheet](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061B.pdf) with the that of i2s on [wikipedia](https://en.wikipedia.org/wiki/I%C2%B2S). With another output pin for WS. I don't see what stops us using this, even if I agree with you it's a lot easier with direct support. – jonathanjo Apr 04 '23 at 08:28
  • 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$). – playmobox Apr 07 '23 at 03:04