2024-01-22 11:51 PM
Hello
I've seen tons of posts about this, I'm hoping I'm just missing something simple, I would really love to get this working.
STM32H723ZG, DMA TX works, I can send a sine wave fine but the RX buffer never changes and is never filled.
I've put the RX and TX buffers in D2RAM but this seems to make no difference.
DMA half and complete callbacks trigger fine, everything else seems to be running right the RX just wont fill.
I2S = 96khz, 32bit on a 32bit frame,
DMA= half word, circular
__attribute__ ((section(".rxBuffer"), used)) __attribute__ (()) uint16_t rxBuf[8];
__attribute__ ((section(".txBuffer"), used)) __attribute__ (()) uint16_t txBuf[8];
HAL_I2SEx_TransmitReceive_DMA (&hi2s2, txBuf, rxBuf, 4);
//in flash file
.buffers(NOLOAD) :
{
. = ALIGN(4);
. = ABSOLUTE (0x30000000);
*(.rxBuffer)
. = ABSOLUTE (0x30000040);
*(.txBuffer)
} >RAM_D2
Solved! Go to Solution.
2024-01-23 12:17 PM
If the DMA data width is not set to "Word" (was using "Half-Word" like in my previous working project) then the rx just shows 0's. When switched to word the data populates correctly.
2024-01-23 12:12 AM - edited 2024-01-23 12:18 AM
Hi,
Just - why you have the buffers in int16 , but use int32 ?
(I do very similar, playing I2S to a DAC in int32. + also use D2 ram for buffers - same idea.)
I use int32 arrays, but had no success on H743ZI with I2S, so using SAI with I2S format, this running perfect.
The I2S worked with 16 bit format, but with 32bit (sometimes !!) wrong , looked like hi and lo 16bits puzzled.
With SAI no problem, 16 or 32 bit format.
So i would recommend : try with int32 (and word transfer) ; and try with SAI ...
+
HAL_I2SEx_TransmitReceive_DMA() with (so small) size 4 ?? I have the full buffer here, 16KB size.
Otherwise not enough time to prepare buffers .
+
Switch off D-cache (or : not enable in Cube) , if you have not yet cache management :)
2024-01-23 09:24 AM
Just - why you have the buffers in int16 , but use int32 ?
The data is 24bit on a 32bit frame, I saw in some other forum posts that h7 wont access the data correctly if its set to 24bit on a 32bit frame and to just choose 32bit frame. they are int16 since its set to half word. I did try changing it to int32 and DMA to "Word" but no difference. Still no data gets into rx, tx is working fine.
had no success on H743ZI with I2S, so using SAI with I2S format, this running perfect.
I'm "newer" to i2s so not really sure how to set that up, any good examples you recommend? If that works better I'd happily use that.
The thing stumping me is why the TX works fine but the RX doesn't.
2024-01-23 10:11 AM
So you giving 16b to the dma, to write 32b to the I2S ? Surprising me, this is working.
Check with a scope, what data is on tx + rx , maybe there is zero...
And
HAL_I2SEx_TransmitReceive_DMA() with (so small) size 4 ? Why?
2024-01-23 10:27 AM
// get audio samples
//restore signed 24 bit sample from 16-bit buffers
int lSample = (int) (rxBuf[0]<<16)|rxBuf[1];
int rSample = (int) (rxBuf[2]<<16)|rxBuf[3];
rSample = Sine24();
//restore audio to tx buffer
txBuf[0] = (lSample>>16)&0xFFFF;
txBuf[1] = lSample&0xFFFF;
txBuf[2] = (rSample>>16)&0xFFFF;
txBuf[3] = rSample&0xFFFF;
I thought maybe it was the ADC so I ran the data pins from the i2s to each other and I'm still getting nothing on the input. When I connect the tx to the DAC I get audio.
RX stays at 0 with no change.
HAL_I2SEx_TransmitReceive_DMA() with (so small) size 4 ? Why?
24bit on a 32 bit frame with half word DMA so 4 values to create 2 samples, L/R. This was how it was explained in a sample I built off of so thought it best to stick with what works.
I also have this code working fine on a M4 but something just isn't working which is also weird cause I did have this working like 5 months ago but can't seem to get it working now.
2024-01-23 11:09 AM
+
Switch off D-cache (or : not enable in Cube) , if you have not yet cache management :)
Did you ?
2024-01-23 11:24 AM
Dcache is not enabled in cube.
if there is anything I can provide please let me know.
I'm also using the NUCLEO-H723ZG
Maybe I will try a different I2S peripheral, haven't found a good SAI example yet either.
2024-01-23 11:41 AM
Changing to I2S3 did not help/change anything
2024-01-23 12:01 PM
I can say nothing about the I2S receive - i never used it. Only send to DAC .
But i expect it working...
Why you have so small buffers , only 2 samples (and wrong format also) ?
This is ...you want shoot on big distance, but insist on using 2mm bullets.
2024-01-23 12:01 PM
ooook really not sure what i did.
I created a new project and changed the optimization and its working.
I used the "Create from existing .ioc file so it literally is the same thing pretty much.
Maybe the optimization got it working idk
thank you for the help!