Hi,
My SD card works until certain functions are called which attempt to re-init the card and do card detect. E.g, f_mkfs(). When this happens it gets stuck in a loop with OSA_EventWait() coming back with KOSA_StatusIdle over and over.
f_mkfs() WILL work if I never call f_mount(). However, unmounting does not rectify the situation.
I should add that, with our PCB, an SD card will always be present. I'd like to forgo the check altogether really.
#define BOARD_SDMMC_SD_CD_TYPE kSD_DetectCardByHostDATA3
sdcard_fatfs_instance_t g_SDcardFatfsInstance is in non-cached sdram.
When f_mount() initially succeeds in detecting the card SDMMCHOST_CardDetectStatus() calls "USDHC_GetPresentStatusFlags(host->hostController.base) & (uint32_t)kUSDHC_CardInsertedFlag)" and the USDHC->PRES_STATE CINST bit comes back as set. As it should.
But when an f_mkfs() follows f_mount() and f_unmount() the CINST remains unset.
I'm aware of the following comments:
" * Note: Please pay attention, DAT3 card detection cannot works during the card access,
* since the DAT3 will be used for data transfer, thus the functionality of card detect will be disabled. Using card
* detect pin for card detection is recommended."
...and..
"PRES_STATE CINST [...] This bit indicates whether a card has been inserted.[...]The Software Reset For All in the System Control register does not effect this bit. A software reset does not effect this bit."
...but does this also implicate that once data transfers are done no amount of resetting and re-init will ever get DAT3 card detect to work again???
Hi @mspenard603,
This is correct. DAT3 line is configured as card detection pin for 1-bit mode, once 4 or 8 bit transfer transfer is being done it won't be able to detect a card. Additionally, the register will not update unless the card is removed and reinserted or after a POR.
Thanks for confirming that.
There's no explicit don't do CD option:
typedef enum _sd_detect_card_type
{
kSD_DetectCardByGpioCD, /*!< sd card detect by CD pin through GPIO */
kSD_DetectCardByHostCD, /*!< sd card detect by CD pin through host */
kSD_DetectCardByHostDATA3, /*!< sd card detect by DAT3 pin through host */
} sd_detect_card_type_t;
I was previously using SDK 2.5.x. It didn't have card detect code so baked into the SDK. And now the middleware (FatFS) attempts to do card detect, via the sdk, for f_mount() and f_mkfs() automatically because of the fact and the above two.
NXP should either include a no-detect option to that struct or provide an option to forgo FatFS from including card detect automatically.
with DAT3 as detection pin f_mkfs() is troubling me. Did you find any method to navigate this or did you change your approach, if any other method is possible to log data into sd card can you suggest?