Hi,
I do the following sequence (psuedo code):
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
SIM_SCGC3.SDHC_clockgate_control.enable;
SDHC_SYSCTL.IPGEN.enabled;
SDHC_SYSCTL.HCKEN.enabled;
SDHC_SYSCTL.PEREN.enabled;
SDHC_SYSCTL.SDCLKEN.enabled;
SDHC_IRQSTATEN.ALL_BITS.enabled;
while (1) {
read_and_print_SDHC_IRQSTAT();
read_and_print_SDHC_PRSSTAT();
}
Basically I initialize pins, clock and enable sdhc clock and enable interrrupts.
I ran the above code and I inserted the SD card. The SD card has an LED on it and it goes ON. But, the IRQSTAT and PRSSTAT don't indicate that the card is detected.
The example code provided along with KDS for SDHC is based on gpio and not on the actual SD card interface so I'm not sure what I'm missing.
Any help is greatly appreciated.
Thanks,
Dinakar
Hi Dinakar Kondru
I don't see your SDHC initialization, are you writing to CINSIEN bit to enable card detection interrupt?
If you are using SDK 2.x package, then you could check the example code provided frdmk66f_driver_examples_sdcard_interrupt located in SDK_2.2_FRDM-K66F\boards\frdmk66f\driver_examples\sdcard\
as you mentioned it uses GPIO to detect card, but all this implementation is located in fsl_host.c, which is application specific, so you could change it as needed. If you check this file you will find a definition like:
sdhcHost->config.cardDetectDat3 = false;
sdhcHost->config.endianMode = SDHC_ENDIAN_MODE;
sdhcHost->config.dmaMode = SDHC_DMA_MODE;
sdhcHost->config.readWatermarkLevel = SDHC_READ_WATERMARK_LEVEL;
sdhcHost->config.writeWatermarkLevel = SDHC_WRITE_WATERMARK_LEVEL;
SDHC_Init(sdhcHost->base, &(sdhcHost->config));
inside HOST_Init function, if you enable cardDetectDat3 as true, it will trigger the card insertion callback defined (by user) in insdhcCallback (similar to sdhcCallback.TransferComplete = SDHC_TransferCompleteCallback;)
Hope this information could help you.
Best Regards
Jorge Alcala
I understand what needs to be done now. I'll let you know once I get it to work. Thank you so much.
-Dinakar