2025-10-20 12:04 PM - edited 2025-10-20 12:20 PM
Hello everyone,
I'm working with a NUCLEO-N657X0-Q board and trying to read audio data from an INMP441 I2S microphone using SAI2 in Master Receive mode with DMA. I have configured everything in STM32CubeIDE, but the DMA transfer complete interrupts are never firing.
Here is a summary of my setup and the troubleshooting steps I've taken.
Hardware Setup:
STM32CubeIDE Configuration (.ioc):
The Problem:
Troubleshooting Steps Taken:
My Question:
Before I proceed with probing the clock lines with an oscilloscope (which is far away), I wanted to ask the community: Is there a common configuration mistake or an essential initialization step for the STM32N6's SAI peripheral in Master Receive mode that could cause this behavior (i.e., failure to start clock generation)?
For your review, I have attached my main.c project file and screenshots of my HPDMA and SAI configurations.
(Please note: I used an AI assistant to help edit this text, so I apologize for any awkward phrasing.)
2025-10-25 11:17 AM - edited 2025-10-25 12:41 PM
Hi @AScha.3,
Thank you for your continued guidance. I am still stuck on the 0x82 (DMA/Overrun) error (with breakpoints enabled to see what is wrong), but based on your previous advice, I believe I have isolated the problem to the clock.
I have updated my configuration, and here are the latest details (I'm attaching the three relevant screenshots):
Clock Source: I've changed the SAI2 Source Mux to I2S_CKIN, which is now providing a 12.288 MHz clock, as you can see in the Clock Configuration image. This seems ideal for audio.
The Problem: Despite having this valid 12.288 MHz source clock, the SAI Parameter Settings page still shows Real Audio Frequency: 0. My target Audio Frequency is set to 32 KHz. This "0" frequency seems to be the root cause of all my errors.
DMA Settings: I have also completely revised my DMA settings.
I have two main questions:
Do you have any idea why the Real Audio Frequency would still be 0? Is there an additional step or a different PLL I need to enable in the RCC to make the I2S_CKIN path active for the SAI peripheral?
It seems STM32N657xx cards are so diffrent but just to be certain, could you confirm if my new DMA settings look correct to you?
Thank you again for your expertise. Best regards,
and this is the DMA setup, so yes it is not needed in N657
2025-10-25 2:06 PM - edited 2025-10-26 2:38 AM
Hi,
so...one after the other.
Fs = 0, cannot be.
Now i tried new project for N657 , FSBL only, as you do, just to test, what Cube doing;
and tried I7 as clock, close to 12.28 M , i got it to 12.307 . ok.
Then set on SAI2 B the I2S , master , receive; and it shows :
...what it should, close to target 48k .
Seems you have another problem here. I use IDE 1.18.1
+ ...you ?
+ And no error or warning anywhere ?
+ How you start the project ?
+ Try -new stm32project , just select the Nxxx cpu you have, give namexxx , set clock + SAI and check...
About dma tomorrow...bed calling now.
...ed today
Why not try the gpdma, no linked list needed:
2025-10-28 2:54 PM
Hey @AScha.3,
First off, thanks for the reply, and really sorry for the long delay. We've been buried in this problem and I'm only just now getting a chance to follow up.
So, we followed your advice and... you were right! When we opened the project in CubeIDE v1.18.1, the "Real Audio Frequency" was not 0 and looked correct, just as you said.
But...
We then tried the newer CubeIDE v1.19, and it generated the exact same code as v1.18.1. And when we ran it, we got the exact same error codes at the same breakpoints.
This makes me wonder that the whole "Real Audio Frequency: 0" thing was just a visual bug in the newer IDE, and my clock config was probably fine all along because of my oscilloscope results.
Which means... the real problem is still here.
Now that I'm ignoring that clock display, I've managed to isolate a very specific pattern of errors depending on the HPDMA/GPDMA setup, and I'd be really grateful for your opinion on this.
I'm seeing 3 distinct scenarios:
Scenario A: Using HPDMA/GPDMA Channel 0 (4 Words / 2 Words internal FIFO) When I use Channel 0, no error come up but i2s_buffer were all zero, with the help of breakpoints i see program error code 0x82 (DMA Error + ).
Scenario B: Using HPDMA/GPDMA Channel 12 (16 Words / 8 Words) (without Linked-List variables) When I switch to Channel 12 and configure it, still no error but still all i2s_buffers were zero. With help of breakpoints I get error code 0x01 (Overrun).
Scenario C: Using HPDMA Channel 12 (with Linked-List variables) When I configure Channel 12 correctly in Linked-List Circular mode, I get no error code at all. The program just crashes immediately, and the debugger dumps me right inside the HardFault_Handler.
My first guess for the HardFault in Scenario C was a cache coherency problem, so I declared my DMA buffer as __NON_CACHEABLE. Unfortunately, that didn't fix the crash.
I tried new project setups with c/c++ - FSBL/APPLI but no progresses. I'm kind of at a loss here. Appreciate any insight you can offer.
Thanks.
2025-10-28 3:20 PM
Hi,
>that the whole "Real Audio Frequency: 0" thing was just a visual bug in the newer IDE
...possible, now we know.
+
>Using HPDMA/GPDMA
? both tried or what? HPDMA and GPDMA are different dma units.
+
>guess for the HardFault in Scenario C was a cache coherency problem
No, i dont think so. A HardFault is triggered by a illegal address, or addressing mode etc. , not because cache used or not.
So i would do: disable D-cache, this is always first step. (cache can be used to speed up the last 2..20% , when calculating a lot with data, otherwise not useful, as long as program has basic errors.)
Then try the GPDMA , no linked list, and find a correct setting (data size, array size , settings in dma setup);
i suppose, there is something wrong , HardFault is not coming from accessing correct address.