Problem to use USDHC2 with fatfs_sdcard exemple

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem to use USDHC2 with fatfs_sdcard exemple

2,839 Views
lacouturepatric
Contributor I
Hello,
I have design a board that includes :
- a MIMXRT1064DVL6A processor,
- Memory IS42s16160j,
- 2 SD card slot (USDHC1 and USDHC2)
- JTAG,
- A led,
I am trying to test the SD card slot 1 and slot 2.
I am using "the fat" exemple to init and configure the USDHC and to do a "f_mkdir".
Test on slot 1: I succeed to init and configure USDHC1  and to create the directory "dir_1' into a SDcard from slot 1.
Test on slot 2: I have the code error = 6502 during the "f_mkdir" called. The error
appears from SD_SendInterfaceCondition function.
I modified the following functions :
- sdcardWaitCardInsert_SD2() : to take USDHC2 base address
g_sd.host.base           = MMC_HOST_BASEADDR;  
g_sd.host.sourceClock_Hz =  MMC_HOST_CLK_FREQ;
- BOARD_InitPinsSD2() : to init Pins SD2 card
- BOARD_USDHC2ClockConfiguration : to configure the USDHC2Clock.
Do you think I forgot a configuration to use USDHC2 instead of USDHC1?
Please find attached my modified code (fatfs_sdcard.c and pin_mux).
Thank you for your help.
Best Regards,
Patrice
Labels (1)
Tags (3)
0 Kudos
Reply
6 Replies

2,708 Views
lacouturepatric
Contributor I

Do you know why I have kStatus_SDMMC_SwitchBusTimingFailed error with USDHC2?

I have not with USDHC1 when I use GPIO_B1_14 pin as GPIO.

0 Kudos
Reply

2,708 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Lacouture Patrice,

Thanks for your reply.
1) Do you know why I have kStatus_SDMMC_SwitchBusTimingFailed error with USDHC2?
-- I think it's related to the switch voltage sequence, whether you can tell the what response of the SD_SwitchVoltage(card) function.

pastedImage_2.png

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

2,708 Views
lacouturepatric
Contributor I
Hello,
Thank you for your answer.
My board is already built, I have no possbility to connect GPIO_EMC_38 to the switch and this pin is used by the memory (SEMC_DM1).
I found the possibility to use GPIO_B1_14 pin as GPIO instead of USDHC1_VSELECT to set NVCC_SD1  at 1.8V (NVCC_SD0 and NVCC_SD1 are powered with USDHC1_VSELECT).
In the DMMC_SwitchToVoltage(fsl_sdmmc_common) function, I do a GPIO_PinWrite(GPIO2, 30U, 1U) instead of SDMMCHOST_SWITCH_VOLTAGE180V(base, true);
It works, the NVCC_SD1 is well at 1.8V but I have a kStatus_SDMMC_SwitchBusTimingFailed error in SD_CardInit function.
If I put in comment the error (line 1885, fsl-sd.c) and if I use the GPIO, the directory is created without error but at 50MHz clock rate.
Do you think there are other solutions than using USDHC1_VSELECT as GPIO or using GPIO_EMC_38?
Best regards,
Patrice
PS : This is the same with Test_sd_polling exemple.
0 Kudos
Reply

2,708 Views
lacouturepatric
Contributor I
Hello,
Thank you for your answer, I found where the problem is.
In pin_mux.c, I should set pin mux at the address IOMUXC_GPIO_SD_B1_04_USDHC2_CLK instead of IOMUXC_GPIO_AD_B1_09_USDHC2_CLK (BOARD_InitPinsSD2 function).
I have not now the error 6502 but I have another problem. When I try to switch voltage at 1.8V (SD_ProbeBusVoltage), I have the error kStatus_SDMMC_SwitchVoltageFail.
In fact, my switch GPIO is GPIO_B1_14, configured as IOMUXC_GPIO_B1_14_USDHC1_VSELECT.
It enables to switch the voltage for USDHC1 well but not USDHC2.
In my design, I use the same regulator for NVCC_SD0 and NVCC_SD1 with the command GPIO_B1_14.
Can I use GPIO_B1_14 as VSELECT for USDHC2?
If yes, how?
Thank you,
Regards
Patrice
0 Kudos
Reply

2,708 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Lacouture Patrice,

Thanks for your reply.
I think you should use the GPIO_EMC_38 pin as the USDHC2_VSELECT if you want to port the same voltage switch mechanism from the USDHC1 to USDHC2.

pastedImage_1.png

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

2,708 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Patrice,

Thank you for your interest in NXP Semiconductor products and
for the opportunity to serve you.
After having a brief review of the code, I've not found any errors in them.
So I suspect that it may be related to the hardware circuit, I'd highly recommend you to modify the sdcard_polling or sdcard_interrupt to test the USDHC2, as software architecture of these demo projects is more simple and close to the hardware layer, please give a try.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply