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

markwj
Posts: 90
Joined: Tue Mar 08, 2016 5:03 am

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

Postby markwj » Mon Feb 26, 2018 2:43 pm

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.
Last edited by markwj on Tue Feb 27, 2018 2:04 am, edited 1 time in total.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Mon Feb 26, 2018 6:41 pm

Are you talking about the Arduino version? If so you should post in Arduino forum.

markwj
Posts: 90
Joined: Tue Mar 08, 2016 5:03 am

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

Postby markwj » Mon Feb 26, 2018 11:31 pm

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.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Tue Feb 27, 2018 1:08 am

Do you set host.flags = SDMMC_HOST_FLAG_1BIT and slot_config.width = 1 ?

markwj
Posts: 90
Joined: Tue Mar 08, 2016 5:03 am

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

Postby markwj » Tue Feb 27, 2018 2:00 am

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

Who is online

Users browsing this forum: Google [Bot] and 272 guests