SDIO Conflict with I2S on modded F4 Discovery Board

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm
Location: India

SDIO Conflict with I2S on modded F4 Discovery Board

Postby Abhishek » Tue Feb 04, 2014 11:20 am

Hello,

In order to be able to use SDIO interface and also I2S3 on a F4 Discovery board, I cut the traces going to the CS43L22 from PC10 and PC12 and connected them to PB3 and PB5 respectively, and appropriately remapped the GPIOs.

However I found that I am unable to send data on the I2S3 and simulatenously read another chunk of data from the SD card to enable continuous playback, it fails with a CRC Check Fail error on the sdcRead. After every I2S transfer I have to wait for TX to complete and then receive data from the SD Card before beginning another transmission.

The SDIO_STA register contains the value 1026 = (SDIO_STA_DBCKEND + SDIO_STA_DCRCFAIL bits)

So instead of using this code for double-buffered continuous playback:

Code: Select all

    uint32_t t = 0;

    bufSwitch = 0;

    wf_read(&f1, buf, PLAYBACK_BUFFER_SIZE, &temp);
    bytesToPlay-=temp;

    wf_read(&f1, buf2, PLAYBACK_BUFFER_SIZE, &temp);
    bytesToPlay-=temp;

    codec_audio_send(buf, temp/sizeof(uint16_t));

    while(bytesToPlay)
    {
      dmaWaitCompletion(i2sdma);
      codec_audio_send(bufSwitch ? buf : buf2, temp / sizeof(uint16_t));

      t =  wf_read(&f1, bufSwitch ? buf2 : buf, PLAYBACK_BUFFER_SIZE, &temp);

      bufSwitch = 1 - bufSwitch;

      bytesToPlay-=temp;
    }


I have to use this code which waits till reading completes before I can send another chunk [Which works, I get clear stereo audio, but playback is obviously glitchy]

Code: Select all

    uint32_t t = 0;

    bufSwitch = 0;

    wf_read(&f1, buf, PLAYBACK_BUFFER_SIZE, &temp);
    bytesToPlay-=temp;

    wf_read(&f1, buf2, PLAYBACK_BUFFER_SIZE, &temp);
    bytesToPlay-=temp;

    codec_audio_send(buf, temp/sizeof(uint16_t));

    while(bytesToPlay)
    {
      dmaWaitCompletion(i2sdma);
      t =  wf_read(&f1, bufSwitch ? buf2 : buf, PLAYBACK_BUFFER_SIZE, &temp);
      codec_audio_send(bufSwitch ? buf : buf2, temp / sizeof(uint16_t));


      bufSwitch = 1 - bufSwitch;

      bytesToPlay-=temp;
    }


I am unable to troubleshoot further, but suspect a hardware issue.

I attach the screenshot of the modded F4 board
The left trace cut was PC12 (SDIO_CK) and now connected to PB5 (Alt. I2S3_SD)
The right trace cut was PC10 (SDIO_D2) and now connected to PB3(Alt. I2S3_CK)
Attachments
hacked F4D.jpg
hacked F4D.jpg (44.41 KiB) Viewed 5573 times

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: SDIO Conflict with I2S on modded F4 Discovery Board

Postby Giovanni » Tue Feb 04, 2014 11:25 am

Are there DMA conflicts?

Giovanni

Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm
Location: India

Re: SDIO Conflict with I2S on modded F4 Discovery Board

Postby Abhishek » Tue Feb 04, 2014 11:44 am

I don't think so, SDIO uses STM32_DMA_STREAM_ID(2, 3) while I2S3 TX uses STM32_DMA_STREAM_ID(1, 7).

Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm
Location: India

Re: SDIO Conflict with I2S on modded F4 Discovery Board

Postby Abhishek » Wed Feb 05, 2014 8:11 am

The issue was of signal integrity.

I observed that the SD Card worked fine and concurrently with I2S3 in 1-bit bus mode (by commenting out bus width change part in sdc.c), but problems arose in 4-bit mode. This meant there was maybe some sort of signal crosstalk between PC10, PC12, PB3 and PB5 near the trace cut (the SDIO bus is operating at 48MHz).

It got fixed by adding a 100 Ohm series resistor between PC12 and SDIO_CK of SD Card. Now I can obtain circular buffer continuous playback.

Maybe someone more experienced than me can help throw light on why it happened. I will try to obtain scope traces.

Regards
Abhishek

pito
Posts: 199
Joined: Sun Nov 06, 2011 3:54 pm

Re: SDIO Conflict with I2S on modded F4 Discovery Board

Postby pito » Sat Feb 08, 2014 3:12 pm

Adding the 100ohm resistor in series limits the "ringing" when the wires are long. How is your sdcard wired? Do you have pullups there? How is your decoupling? Any schematics available?

Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm
Location: India

Re: SDIO Conflict with I2S on modded F4 Discovery Board

Postby Abhishek » Sat Feb 08, 2014 5:25 pm

My hardware is built wire-wrap. The wires are not quite long from the pinheaders connecting the Discovery board to the microSD connector.
I have 47K pull-ups on all pins except SDIO_CK.

Now I have put 100E resistors in series with SDIO_D2 and SDIO_CK.

The 0.1uF decoupling cap, 10uF capacitor are connected to the power rail via a "via" (4 filled holes in the middle of the SD Card socket) - which I now realise was a bad idea as the via inductance is "killing" the decoupling capacitor. Power to the SD Card is controlled by a PMOS transistor on the bottom layer.

Here is a screenshot. Not quite neat, but it is hopefully working OK now.

What problems could I face in the future? Should I add another 0.1uF decoupling cap near the SD power pins?

Regards
Abhishek
Attachments
SDCard.jpg
SDCard.jpg (50.94 KiB) Viewed 5504 times

pito
Posts: 199
Joined: Sun Nov 06, 2011 3:54 pm

Re: SDIO Conflict with I2S on modded F4 Discovery Board

Postby pito » Sat Feb 08, 2014 6:29 pm

An sdcard can take 100mA peak. So I would use thicker wires for its power and ground. Also I always use few ceramic multilayer 10u smd capacitors (2-3) for its decoupling, instead of an aluminum or tantalum types. Place the decoupling capacitors close at sdcard's vcc pins (when using transistor for switching the power always place the capacitors at sdcard's side).

alexblack
Posts: 276
Joined: Mon Sep 24, 2012 3:52 pm
Location: Donetsk
Been thanked: 32 times
Contact:

Re: SDIO Conflict with I2S on modded F4 Discovery Board

Postby alexblack » Sat Feb 08, 2014 7:21 pm

Hi.
pito wrote:An sdcard can take 100mA peak.

I had problems with some cards because it has current consumption more than 250 - 300mA in peak at insertion moment!!!

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: SDIO Conflict with I2S on modded F4 Discovery Board

Postby Giovanni » Sat Feb 08, 2014 7:49 pm

Probably this is why I have seen inductors in some designs.

Giovanni

Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm
Location: India

Re: SDIO Conflict with I2S on modded F4 Discovery Board

Postby Abhishek » Sat Feb 08, 2014 7:56 pm

Indeed. I have a 4.7uH 0805 inductor in series with the MOSFET before the filter capacitors.

The audio sounds very good on headphones but I notice some audible hum in my USB Speakers at maximum volume ,the frequency of which varies inversely with the DMA buffer size. I will try and increase the inductance to see if has any effect on reducing the hum. There is no hum when the board and the speakers are placed on separate power supplies.

Edit: Giovanni was faster :)

Regards


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 59 guests