Page 1 of 1

SDC init crash

Posted: Mon Feb 23, 2015 11:22 am
by manuelseeboeck
Hello,

I'm trying to connect a sd card via sdio on an STM32F4. During sdcConnect the osalThreadSleep function is called (in sdc_init(..)) and the program crashes unexpectedly (the _unhandled_exception handler is not called, neither the hard fault handler). See attached image.
Below is the snippet of my init function, it is called from within a static thread (stack size is 1024 byte).

Code: Select all

  palSetPadMode(GPIOC, GPIOC_PIN8,  PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //D0
  palSetPadMode(GPIOC, GPIOC_PIN9,  PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //D1
  palSetPadMode(GPIOC, GPIOC_PIN10, PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //D2
  palSetPadMode(GPIOC, GPIOC_PIN11, PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //D3
  palSetPadMode(GPIOC, GPIOC_PIN12, PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //CLK
  palSetPadMode(GPIOD, GPIOD_PIN2,  PAL_MODE_ALTERNATE(12) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_HIGHEST); //CMD

  palClearPad(GPIOE, GPIOE_PIN3);
  palSetPadMode(GPIOE, GPIOE_PIN3, PAL_MODE_OUTPUT_OPENDRAIN | PAL_STM32_PUDR_FLOATING | PAL_STM32_OSPEED_LOWEST); //SD Power Enable

  sdcStart(&SDCD1, NULL);
  sdcConnect(&SDCD1);


Do you have any idea of why this error occours?

regards,
manuel

Re: SDC init crash

Posted: Mon Feb 23, 2015 1:32 pm
by Giovanni
Hi,

Which version? if 3.0 then you must pass a configuration structure to sdcStart(), it is a recent change.

Giovanni

Re: SDC init crash

Posted: Mon Feb 23, 2015 1:57 pm
by manuelseeboeck
Hi,
I added the SDCConfig struct with 512 byte working area as described in the documentation, the programm still crashes at the same point though.

manuel

Re: SDC init crash

Posted: Mon Feb 23, 2015 3:25 pm
by Giovanni
Hi,

We are still doing changes there, I just committed some changes, please monitor the SDC thread in this same forum.

Giovanni

Re: SDC init crash

Posted: Mon Feb 23, 2015 3:29 pm
by manuelseeboeck
OK, thanks for the help.

manuel

Re: SDC init crash

Posted: Mon Feb 23, 2015 6:27 pm
by barthess
Strange error. Not enough information. But I can write some tips:
1) It may be caused by overflow in some different point not necessary in SDC thread.
2) Do not leave bus lines floating. Set pull up for CMD and data lines, pull down for CLK.
3) Insert pause after card power enabling.
4) It is very unlikely but do you have revision A chip? If yes than you need to set STM32_USE_REVISION_A_FIX flag in your mcuconf.h