2023-11-20 05:07 AM
Hi All
Trying to get an understanding of how I2S with DMA works using the STM32Cube IDE by implementing a simple audio loop-through application.
Connected the STM32F407G Discovery board to a Digilent PMOD I2S2 codec and set up using the STMCube IDE GUI as follows: PC2 = I2S2_ext_SD, PC3 = I2S2_SD, PB10 = I2S2_CK, PB12 = I2S2_ WS and PC6 = I2S2_MCK
I2S2 set as: Full-Duplex Master with Master clock output enabled.
Parameter settings: Mode Master Transmit, I2S Philips, 24 bits on 32 bit frame, 96kHz, I2S PLL Clock, Polarity LOW.
DMA settings: I2S2_RX, Circular buffer, DMA1 Stream 3. I2S2, Circular buffer, DMA1 stream 4.
I2S clock set to give sampling frequency of 96kHz.
Added the buffer definitions, DMA startup code and the half and full callbacks to main program.
Everything works as expected.
Next, tried the same trick with the L-TEK audio board (codec) connected to the Discovery.
Same basic IDE setup except I2S2_CK = PC13 (pre-wired connection to codec) and I2S clock set to give sampling frequency of 48kHz. Also using 16bit data on a 16 bit frame.
Added code to set up the TLV320AIC23B codec on the L-TEK audio board. The I2C data is reaching the codec's registers because I can set the bypass mode where input is directly routed to the output, bypassing the codec itself (no read registers on the codec, so can't check that way).
The system does not appear to be receiving data into the receive buffer. Putting dummy data into the receive buffer does produce output so the output side is working.
The clocks are all there (checked on a 'scope) and the full and half full call backs are being fired.
Anybody any idea what I'm doing wrong - any help appreciated ?
Solved! Go to Solution.
2023-11-23 05:17 AM
Hi All (again!)
Final update on this post. A workaround to the problem :-
1. Set PC2 and PC3 to their reset states.
2. Configure PB14 to I2S2_ext_SD and PB15 to I2S2_SD and flash this new configuration.
3. After steps 1 and 2, connect female to female Dupont leads from PB14 to PC3 and PB15 to PC2. The pins on the top of the Discovery board just about make this possible.
Note that with the Dupont leads in place, PC2 and PC3 can not be used for any other function.
That's a wrap !
2023-11-20 08:39 AM
Observe the data line (together with the clocks) in the direction in question, using LA or oscilloscope.
JW
2023-11-20 09:34 AM
Hi Jan - thanks for your reply.
I've looked at the data signal along with the clock and it looks fine.
A bit of background and some new information.
Background:
I've had problems with the L-TEK board from the start. I emailed L-TEK several times asking for information on how their Audio board and the Discovery board were connected but have received no response. So, buzzed out the connections and set up the STMCube IDE GUI accordingly but have not been able to get the two working together.
Loading a supplied loop-through application onto the Discovery using the Keil uVision 5 IDE the two boards work OK. Unfortunately I can't get any setup information from that application.
I have had the Discovery board and the Digilent PMOD codec working OK using the STMCube IDE, so the basic Cube setup seems to be OK.
New information:
I have unhooked the two boards and reconnected them using the 9 way SIL connector located at one end of the L-TEK board. The connections from the Discovery board are the same as they would be if the boards were hooked up by their two 50 way DIL headers but are now supplied via Dupont leads.
Connected in this way I am getting the loop-through working (I have absolutely no idea why !) but there is also a loud background hiss, even when no input signal is connected. I read something you posted online about incorrect data formats and noise, noise and more noise and wondered if you had any advice on how to get rid of the noise. I also read this may have something to do with a PSIZE variable but have no idea how to access this.
Again, any help appreciated.
2023-11-21 02:58 PM
Hi All
Update on the post. One of the L-TEK Audio board' 50 way connectors appears to have a wiring error.
They have cross connected the Discovery board's PC2 and PC3 with the Audio board's Data In and Data Out pins, effectively connecting the ADC output to PC3 (SPI_TX, also an output) and the DAC input to PC2 (I2S2_EXT_RX, an input). Connecting the two outputs together may well have damaged the ADC output which could account for the noise which is now evident.
2023-11-23 05:17 AM
Hi All (again!)
Final update on this post. A workaround to the problem :-
1. Set PC2 and PC3 to their reset states.
2. Configure PB14 to I2S2_ext_SD and PB15 to I2S2_SD and flash this new configuration.
3. After steps 1 and 2, connect female to female Dupont leads from PB14 to PC3 and PB15 to PC2. The pins on the top of the Discovery board just about make this possible.
Note that with the Dupont leads in place, PC2 and PC3 can not be used for any other function.
That's a wrap !
2024-04-23 10:56 PM
Hi Waddy,
I am trying to also use the PMOD I2S2 with an STM32F407 MCU. I was wondering if you need a driver for the PMOD I2S2 since some ICs you need to setup a separate driver software. I was not able to find any information on this anywhere. I am using the STM3240G-EVAL board so was wondering if you had any idea on the driver situation. Any help would be greatly appreciated!
2024-04-24 03:10 AM
Hi
The PMODI2S2 codec module conforms to I2S digital audio standards so as long as it is correctly connected to another I2S device all should be well. I don't think there is a driver for the PMODI2S2 as such. However, drivers of some description may be required by the device controlling it. These will usually be installed as part of the controllers I2S bus setup. Phil Schatzmann has posted an excellent YouTube tutorial on how to use the PMODI2S2 with the STM32F407 board using the STMCUBE IDE. It goes through the process of setting up the controller for use with the codec and uses an IIR filter design as a vehicle for doing so. Googling [#5] IIR Filters Audio DSP should find it. I've modified his code to provide a simple audio loop through and it works OK.
Hope this helps !
2024-04-24 04:01 PM
This was an awesome resource! Thank you very much!