cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube bug with FatFS

Osto
Senior
Posted on September 18, 2015 at 19:24

Hi ST,

When configuring  the FatFS in Platform settings, I can configure the pin for card detect function. When using this config, following code in generated:

uint8_t BSP_SD_IsDetected(void)

{

  __IO uint8_t status = SD_PRESENT;

  /* Check SD card detect pin */

  if (HAL_GPIO_ReadPin(SD_PORT,SD_PIN) == GPIO_PIN_RESET) {

    status = SD_NOT_PRESENT;

  }

  return status;

}

but this code is wrong because of wrong polarity. The CD pin of the socket (all I know) make a short to GND when card is inserted. So the function returns oposite status of the real situation.

Either the polarity have to be adjustable or the code snipet have to be reversed.

Thanks,

Osto

#cube-bug-fatfs
2 REPLIES 2
tm3341
Associate II
Posted on September 19, 2015 at 15:58

This is technically not a bug always.

Some of card socket uses 2 pins for card detect, like switch. One to desired polarity and one to microcontroller. Desired polarity will be on MCU pin when card is inserted.

I agree with you, at least they should add option in CubeMX to select which polarity you use.

Posted on September 22, 2015 at 18:49

Hi guys,

It is true that the function BSP_SD_IsDetected() is implemented in differents ways from one example to another depending on the hardware. However,  if the user generates a code with CubeMx after enabling Fatfs/SDIO, the function is empty and user can implement it as he wants. so, there is no need to add polarity.

-Shahrzad-