2025-11-27 2:41 AM
I am developing I2S on the NUCLEO-L433RC-P development board using a BT401 bluetooth audio receiver and MAX98357A I2S amplifier.
I need to pass the I2S audio data through the STM32L4333 (refer to diagram below).
I have done this before using a Microchip dsPIC33E but this has both DATA IN and DATA OUT pins for I2S.
Whereas the STM32 only has a single DATA pin (SD), so it can only be DATA IN or DATA OUT.
Does this mean I cannot use the STM32 to pass through I2S data ?
Solved! Go to Solution.
2025-12-02 2:32 AM
Hm, ok, now i know. :)
Seems ok, but :
set SAI1_A as slave receiver , connected to BT40xx; and SAI1_B (syncron. to A) transmitter ;
then you are sync to the data stream from BT and stay sync , also for sending same data.
You just need two DMA streams in circular mode, to write+read same buffer area.
Then you get continuous "pass through" , without any cpu load or action.
Only if you want to add your message, you have to fill the buffer in the callbacks with the cpu doing this.
2025-11-30 1:19 PM - last edited on 2025-12-01 7:27 AM by mƎALLEm
Merged threads.
I am using an STM32L433 to pass I2S audio from a bluetooth receiver (BT401) to a PCM amplifier (MAX98357A) using DMA.
I have got it working, but there is an issue with the clock. It plays the audio fine for a few seconds and then there is some interference for a few seconds and this repeats.
I have concluded that its due to the two seperate clocks i.e. the clock in the bluetooth receiver and the clock in the STM32.
The bluetooth receiver is configured to play 48kHz audio but the STM32 is configured to play 49.107kHz.
Even when I configured the STM32 to play 48kHz, the same issue occured but for different durations (assume due to discrepancies between the seperate clocks).
Below is my current architecture...
I am thinking that the bluetooth receiver and the STM32 need to use a common clock, so need to either change the architecture and/or configuration, but I am not sure what setup I need to achieve this.
The bluetooth receiver can be configured as:
The STM32 SAI blocks can be configure as:
Note that the PCM amp does not require a master clock.
2025-12-01 11:57 AM - edited 2025-12-01 1:37 PM
I was wondering if I could use the master clock from the bluetooth receiver (which is 12.288MHz) as the clock for the STM32 SAI.
Then I noticed there is an option in CubeMX Clock Configuration to use SAI1_EXT...
So I enabled the SAI1 external clock...
And connected the bluetooth receiver master clock output to the STM32 SAI external clock input....
With the bluetooth master clock of 12.288MHz going to the STM32 SAI1_EXTCLK pin, I can see data on the SAI1_B DMA Rx buffer and can see data copied to the SAI1_A DMA Tx buffer, but there are no signals on the SAI1_A pins (FS, SCK and SD) when I look at them on an oscilloscope. So why is SAI1_A not transmitting data on these pins since changing the SAI clock source to SAI_EXTCLK ?
2025-12-01 12:39 PM
Why you want "pass through " ? sense ? compared, to just connect it, to pass data ?
And with SAI it should work:
- have receiver : slave receiver
- transmit: synchronous sync to receiver , slave transmitter
2025-12-01 11:55 PM - edited 2025-12-01 11:55 PM
Because I want to intercept the Bluetooth audio when an event occurs and replace it with a voice prompt stored in external flash.
Once I get pass through working I can modify the code to replace one of the audio channels (left or right) with the voice prompt. The result will be a mix of the Bluetooth audio and the voice prompt. because the amplifier is configured to convert the stereo I2S to mono (by summing both channels)
unless there is some other way to achieve this ?
2025-12-02 2:32 AM
Hm, ok, now i know. :)
Seems ok, but :
set SAI1_A as slave receiver , connected to BT40xx; and SAI1_B (syncron. to A) transmitter ;
then you are sync to the data stream from BT and stay sync , also for sending same data.
You just need two DMA streams in circular mode, to write+read same buffer area.
Then you get continuous "pass through" , without any cpu load or action.
Only if you want to add your message, you have to fill the buffer in the callbacks with the cpu doing this.
2025-12-02 11:00 AM - edited 2025-12-02 12:08 PM
Thanks AScha.3
So should the configuration be like this...
SAI_A is configured to be Asynchronous slave receive and connected to the bluetooth receiver. In CubeMX this exposes all I2S pins:
SAI_B is configured to be Synchronous slave transmit and connected to the amp. In CubeMX this only exposes the data pin:
So does this mean the SCK and FS pin from the bluetooth receiver have to be connected to the amp (as shown in the diagram) ?
Below are the SAI settings in CubeMX for this configuration:
PS. For some reason, if select SAI_A to be Synchronous slave, CubeMX disables both SAI_A and SAI_B. So it seems SAI_A cannot be Synchronous slave (if so then why is it an option) ?
2025-12-02 11:46 AM
>So does this mean the SCK and FS pin from the bluetooth receiver have to be connected to the amp (as shown in the diagram) ?
Right, all data in + out now sync to the incoming sck+fs .
+
>For some reason, if select SAI_A to be Synchronous slave, CubeMX disables both SAI_A and SAI_B.
I tried (on H743, SAI1 ) :
+
- i see no problem. Just the sequence...set first the input, then B to be sync output.
2025-12-02 1:26 PM
Many thanks for your help AScha.3 it is now working :)
There are so many different configurations, I could have spent weeks trying different things and still might not have got it working, so I really appreciate your help :)
Thanks again, I owe you a beer !