µTasker Forum
µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: jackking on December 27, 2023, 09:09:34 PM
-
Is there a section in the config file to set alternate pins for these SDCARD functions?
I didn't see any way to select an arbitrary GPIO pin for card detect (as can be done in the MCUXpresso SDK). I did manually change the PWREN pin, and I haven't found the VSELECT pin setting yet.
JK
-
Hi
The selections are in the file app_hw_xxxx.h since it is specific to the HW.
Assuming you are working with an i.MX RT the default tends to be
#define SDCARD_DETECT_INPUT_INTERRUPT // use card detect interrupt rather than polling the card
#define SDCARD_DETECTION() ((SDHC_PRSSTAT & SDHC_PRSSTAT_CINST) != 0) // card detection input
and if SDHC_DETECT_INTERRUPT_GPIO is enabled a GPIO can be used instead.
but it can be polled (via GPIO) with
#define SDCARD_DETECT_INPUT_POLL // use card detect switch for detection polling (use together with T_CHECK_CARD_REMOVAL)
or polled by reading an SD card register if neither is enabled.
There is no specific VSEL control for the i.MX RT but if needed it can be added to the POWER_TO_SD_CARD() macro via a GPIO.
Regards
Mark
P.S: Note that the i.MX RT project has only used the SDHC's dedicated card detection line and so I found that I needed to adjust some conditional defines in the mass storage code so that the GPIO interrupt initialisation was included (for example). I have checked these changes in but not tested on HW (only in simulator). I used this on an RT 1020:
#define SDCARD_DETECT_INPUT_INTERRUPT // use card detect interrupt rather than polling the card
#define SDHC_DETECT_INTERRUPT_GPIO // use general GPIO rather than the SDHC's detect input
#if defined SDHC_DETECT_INTERRUPT_GPIO
#define SDCARD_DETECT_PORT PORT2
#define SDCARD_DETECT_PIN PIN_GPIO_EMC_00_GPIO2_IO00
#define PRIORITY_SDCARD_DETECT_PORT_INT PRIORITY_PORT_2_LOW
#define SDCARD_DETECTION() (_READ_PORT_MASK(2, SDCARD_DETECT_PIN) == 0) // card detection input
-
Mark,
Thanks for that. I was able to test it. I think there is still some issue with the interrupt handler, I had to remove the SDHC_DETECT_INTERRUPT_GPIO exclusion in kinetis_SDHC.h before the card would move beyond the idle command. After removing this, I was able to get the card mounted.
line 193 - before removing the exclusion:
#if (defined SDCARD_DETECT_INPUT_INTERRUPT && !defined SDHC_DETECT_INTERRUPT_GPIO)
sdcard_handler[0] = int_handler;
#if (defined _iMX && defined USE_uSDHC2)
fnEnterInterrupt(irq_USDHC2_ID, SDCARD1_STATUS_INTERRUPT_PRIORITY, sdcard_state_change);
SDHC2_IRQSIGEN = (SDHC_IRQSIGEN_CRMIEN | SDHC_IRQSIGEN_CINSIEN); // enable interrupts on card insertion and removal
SDHC2_IRQSTATEN = 0xffffffff; // allow all enabled interrupts
#else
fnEnterInterrupt(irq_USDHC1_ID, SDCARD1_STATUS_INTERRUPT_PRIORITY, sdcard_state_change);
SDHC_IRQSIGEN = (SDHC_IRQSIGEN_CRMIEN | SDHC_IRQSIGEN_CINSIEN); // enable interrupts on card insertion and removal
SDHC_IRQSTATEN = 0xffffffff; // allow all enabled interrupts
#endif
#endif