The main goal of the project was to minimize power consumption by replacing the existing gong module with a modern microprocessor.
The main microprocessor for the gong is the STM32L452RET6.
The microprocessor sleeps most of the time consuming only 5 μA. When the level changes on one of its interrupt lines, a WAKEUP interrupt awakens the microprocessor. The program detects which interrupt line awakened the system and plays a corresponding WAV file on its DAC. When it stops playing, the microprocessor goes back into sleeping.
WAV files are only a few seconds each, and they are stored in the microprocessor flash. The program uses a timer to transfer bytes to the DAC according to the bit rate, usually, 16 bit/44.1kHz or 16 bit/48kHz. As the STM32 DAC is only 12-bit, some conversion is done. First, bytes are read into a memory buffer. Then, they are transferred to the DAC using a DMA channel. The program waits until it receives a transfer complete interrupt, and send a new portion of the music file to the buffer.
The DAC signal is amplified by the amplifier chip NJM2135M (MC34119).
The software uses the Real-Time Operating System Zephyr to organize multiple threads and simplify writing drivers.
The gong schema.
I used a simpler and cheaper octocouple before, and the power consumption was similar.
The audio amplifier subschema.