Skip to main content
Explorer
September 19, 2024
Solved

Design of PCB with SDIO and USB (STM32F411CEU6)

  • September 19, 2024
  • 2 replies
  • 2663 views
 

Here's a corrected version of your text:


Hi!
I would like to ask the community if my design of the SDIO and USB bus looks fine. Previously, I was using a dev board (BlackPill STM32) to write data to an SD card, but I encountered some issues during the communication stage. The problem occurs when the SDIO protocol starts sending data at a 24 MHz frequency. When I try to write or read a block of data in common mode, without DMA and interrupt handling (IT), I always get a HAL_TIMEOUT error.

After researching the issue, I found that some people suggest it might be caused by incorrect SDIO bus design, specifically related to impedance and trace length control.

To address this, I redesigned the PCB. It now consists of four layers, with the top and bottom as signal layers, and the two middle layers as GND and VCC (which are not shown in the design). I hope you can review it and provide some feedback, whether positive or negative.

I have tried several variations of the code and tested it on another board (STM32 BlackBoard with an SD slot), where it works but only with a 10x SDIO_CK divider or higher. This fact also leads me to conclude that the initial design (BlackPill) used a chip SD adapter with an undefined wire length and impedances. Furthermore, I later discovered that the second design (BlackBoard) also had a few mistakes,like weird trace path through 2.54 contact row. 

image_2024-09-19_234840770.png

    This topic has been closed for replies.
    Best answer by FBL

    @Photonic_nail 

    90Ohms is USB requirement Introduction to USB hardware and PCB guidelines using STM32 MCUs - Application note

    Please note that Black board is not ST board.

    FBL_1-1726838781049.png

    FBL_0-1726838633381.png

    2 replies

    Super User
    September 19, 2024

    > When I try to write or read a block of data in common mode, without DMA and interrupt handling (IT), I always get a HAL_TIMEOUT error.

    It's probably more likely to be caused by the code being unable to keep up, causing an underflow and a bus error that manifests as a timeout. Especially if it works with DMA.

    Layout looks good. Shouldn't have any issues operating at 24 MHz. Thick traces aren't necessary here, but aren't hurting either. Similar with length matching. Adding terminating resistors will add some amount of noise resistance but with short traces and without much else happening on the board shouldn't be necessary.

    Consider putting a header connector on there and looking at the signals with a logic analyzer or scope. It will give you a lot more insight into what is going on at the hardware level.

    > Here's a corrected version of your text:

    ??? Forget to delete that part of the AI response?

    Explorer
    September 19, 2024

    >It's probably more likely to be caused by the code being unable to keep up, causing an underflow and a bus error that manifests as a timeout. Especially if it works with DMA.

    Thank you so much for your answer!

    Actually, DMA doesn’t help; it just goes into an infinite loop, and the SD card status become BUSY.

    >Layout looks good. Shouldn't have any issues operating at 24 MHz. Thick traces aren't necessary here, but aren't hurting either. Similar with length matching. Adding terminating resistors will add some amount of noise resistance but with short traces and without much else happening on the board shouldn't be necessary.

    Thanks again! If everything is fine, I will proceed with manufacturing.

    >Consider putting a header connector on there and looking at the signals with a logic analyzer or scope. It will give you a lot more insight into what is going on at the hardware level.

    I was thinking about , but i want to try to keep signal part as clear as possible. I think will order two versions of PCB (with and without them)

    >??? Forget to delete that part of the AI response?

    In addition to being so good at electronic engineering (not sarcasm), you're also a pretty good detective:)

     

    Technical Moderator
    September 20, 2024

    Hello @Photonic_nail 

    Potentially, as detailed @TDK something is missing in your software. Could you test with different SDIO clock dividers? About your HW design, did you make sure of controlled 90Ohms impedance? and ESD protection?

    Explorer
    September 20, 2024

    As I said before , different clock divider works if it higher then X10 and only with BlackBoard.

    90Ohms ? SDIO specification says that it's 50 Ohms .

    FBLAnswer
    Technical Moderator
    September 20, 2024

    @Photonic_nail 

    90Ohms is USB requirement Introduction to USB hardware and PCB guidelines using STM32 MCUs - Application note

    Please note that Black board is not ST board.

    FBL_1-1726838781049.png

    FBL_0-1726838633381.png