Page 1 of 1

[solved] SDMMC 1-line mode, free-up unused pins

Posted: Mon Feb 26, 2018 2:43 pm
by markwj
I'm running the SDMMC in 1-line mode, so would like to free-up the unused pins for other functions. Specifically SD_DATA1, SD_DATA2, and SD_DATA3. However, after mounting the SD CARD, it seems the driver re-maps those pins to SDMMC and I can't access them properly in the UART driver I am trying to work with.

Symptom is that the UART simply doesn't work. If I comment-out the SDCARD initialisation code, the UART then works fine.

Re: SDMMC 1-line mode, free-up unused pins

Posted: Mon Feb 26, 2018 6:41 pm
by WiFive
Are you talking about the Arduino version? If so you should post in Arduino forum.

Re: SDMMC 1-line mode, free-up unused pins

Posted: Mon Feb 26, 2018 11:31 pm
by markwj
WiFive wrote:Are you talking about the Arduino version? If so you should post in Arduino forum.
No. Straight C code, using latest ESP IDF.

Re: SDMMC 1-line mode, free-up unused pins

Posted: Tue Feb 27, 2018 1:08 am
by WiFive
Do you set host.flags = SDMMC_HOST_FLAG_1BIT and slot_config.width = 1 ?

Re: SDMMC 1-line mode, free-up unused pins

Posted: Tue Feb 27, 2018 2:00 am
by markwj
WiFive wrote:Do you set host.flags = SDMMC_HOST_FLAG_1BIT?
Yes.
WiFive wrote:and slot_config.width = 1 ?
No :-)

That fixed it. Best 1 line (pun intended) fix ever. Many thanks for the quick assistance.

So, code for 1 bit SDCARD is:

Code: Select all

    sdmmc_host_t host = SDMMC_HOST_DEFAULT();
    // this tells SD host to keep using 1-line bus mode
    host.flags = SDMMC_HOST_FLAG_1BIT;

    sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
    // this tells the driver to only initialize 1 data line
    slot_config.width = 1;
With that in place, GPIO4 and GPIO13 work for me with uart.

P.S. This thread (from last year) seems relevant as well:
viewtopic.php?t=3091