2024-02-19 11:49 AM
It looks like the BSP_SD_IsDetected function from the sample codes is working backwards.
According to the SD-Card spec this pin has a weak pullup (50 kΩ) inside the card. So the STM32 should have a weaker pull down on the pin and detect the presence of the card if there is a high on the pin.
But the sample code activates the pull up and checks for a low as the indicator of the SD-Card presence.
2024-02-19 12:10 PM - edited 2024-02-19 12:53 PM
>SD-Card spec this pin has a weak pullup (50 kΩ) inside the card
Source please ?
afaik
Micro SD-cards - we talk about - right ?
Here the card holder usually has a switch to case/gnd, so its easy to detect a card-is-in , ie with a pin+pullup connected to this switch. Other way is just send command -- and wait for response, or not.
Cd is this card-detect pin:
2024-02-19 02:20 PM
Source: Simplified Physical Layer Specification
That is pin 1 on SD/miniSD and Pin 2 on micro.
While the other options may wirk too, detecting the card presence via the CD/Dat3 pin is what the sample code does.
2024-02-19 03:06 PM
Most sockets have a mechanical switch which grounds when a card is in the socket. It's rather rare for one to use the pull-up in the card itself, as again most sockets for SDIO/SDMMC need pull-ups for signal integrity with pins changing direction in 4-bit modes, and not using 1-bit modes beyond initialization.
2024-02-20 02:37 AM
Please, this question is about the sample code, not about the SD-Card specs or various sockets.
So again: The sample code for the F7 series seems to do the card detection wrong. I wonder if this has ever been tested?
Here is the function:
uint8_t BSP_SD_IsDetected(void)
{
__IO uint8_t status = SD_PRESENT;
/* Check SD card detect pin */
if (HAL_GPIO_ReadPin(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) == GPIO_PIN_SET)
{
status = SD_NOT_PRESENT;
}
return status;
}
So it definitely decides that the card is not present when the CD-pin is high. In the definitions the D3/CD pin is defined as the SD_DETECT_PIN and the internal pullup of the microcontroller is activated. This definitely can never work.
2024-02-20 02:42 AM
Use this button to properly post source code: