2024-07-02 12:38 PM
Hi,
I am using the STM32F407VG and PmodI2S2 to transfer 24-bit audio. For the most part I have followed this tutorial. So far everything works and I have audio throughput and the ability to manipulate it.
In order to understand better the underlying code, I want to understand the following:
1. In I2S2 > Parameter Settings > Data and Frame Format I have setup 24 bits Data on 32 Bits Frame and in DMA Settings > I2S2_EXT_RX and SPI2_TX I have Data Width set to Half Word. Currently I am receiving 16-bit data which I then restructure into a 32-bit int variable. Would it be possible to receive 32-bit data directly by selecting a data width of Word? I'm a bit confused about this as the method to setup the DMA (HAL_I2SEx_TransmitReceive_DMA) only accepts pointers to a uint16_t even after selecting a data width of word.
2. If I2S2 > DMA Settings has two DMA requests (I2S2_EXT_RX and SPI2_TX), does this mean that the callbacks 'HAL_I2SEx_TxRxHalfCpltCallback' and 'HAL_I2SEx_TxRxCpltCallback' are called on both Tx and Rx interrupts? My concern here is that the incoming samples would then be processed twice.
Thanks
2024-07-02 01:19 PM
Hi,
>1. read in rm :
So you can set here 32b data, but the SPI has only 16b shifter, so it needs 2x load with 16b to send /receive a 32b word. (On "bigger" chips you could use SAI , can set data 8...32 bits. But here only 8...16.)
Maybe you could set the buffer as a union, 16b for dma and 32b for "data" .
>2. Try it...
Should be: on half/full TxRx---fCpltCallback you get this buffer to use, and have to set the next data in to send, before next callback coming. Then process read/write the other half of each buffer.
2024-07-02 01:24 PM
2024-07-02 02:09 PM
1. I just can say: with F411, also F4 series, on I2C , with 16b working fine; with 32b - i didnt get it work correct.
Maybe chip problem, because sometimes it working correct, most (!) time it puzzled data, sync was in middle of 32b - unusable. (I use H743 now...SAI working perfect .)
Here probably just wrong order (big/little endian problem), so try : reorder by software. (exchange lo/hi 16b part)
2. TxRx is at same time, so if calling TxRxHalfCpltCallback should be only one time, for both, rx tx.
Try...it will nothing explode.