Hello,
I'm experiencing issues using the SDC driver on an STM32F407. I've got a generic STM32F4 board that has an onboard Micro SD card slot. It has 10k pullups to 3V3 on D0-D3, CMD, and SCK.
When calling sdcConnect it'll frequently fail. When it succeeds, I'm able to pull the CSD. I've pulled the CSD multiple times and it's always the same. I've tried multiple cards (which return different CSD's of course) and the result is the same. I'm running in 1BIT mode. I've set Alternate Mode 12. Activating the internal Pullups seems to make the issue less frequent, but even so I'm unable to mount with FatFS. It returns FR_DISK_ERR. Maybe data is getting corrupted while it tries to mount? Has anyone seen this before?
Thanks in advance!
SDC Sporadic Issues
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: SDC Sporadic Issues
Hi,
You should connect a logic analyzer, the pullup thing makes me think that you may need stronger pullups. Do you have capacitors close to the card?
Giovanni
You should connect a logic analyzer, the pullup thing makes me think that you may need stronger pullups. Do you have capacitors close to the card?
Giovanni
Re: SDC Sporadic Issues
Giovanni,
Thanks for your reply. There is one capacitor close to the card. Here's a schematic of the circuit. I was thinking the same thing, but I'd think that the internal pullups would get the job done, especially with the help of the 10k pullups. This is all SMD so changing resistors would be undesirable . I've also attached a snip of the related code. I noticed in the samples that Alternate Pin Mode isn't set. Am I missing something there? Side note, blkIsInserted(&SDCD1) always returns TRUE. Is this normal behavior?
Thanks for your reply. There is one capacitor close to the card. Here's a schematic of the circuit. I was thinking the same thing, but I'd think that the internal pullups would get the job done, especially with the help of the 10k pullups. This is all SMD so changing resistors would be undesirable . I've also attached a snip of the related code. I noticed in the samples that Alternate Pin Mode isn't set. Am I missing something there? Side note, blkIsInserted(&SDCD1) always returns TRUE. Is this normal behavior?
Code: Select all
palSetPadMode(GPIOD, 2, PAL_MODE_ALTERNATE(12) | PAL_STM32_PUPDR_PULLUP);
palSetPadMode(GPIOC, 12, PAL_MODE_ALTERNATE(12) | PAL_STM32_PUPDR_PULLUP);
palSetPadMode(GPIOC, 8, PAL_MODE_ALTERNATE(12) | PAL_STM32_PUPDR_PULLUP);
palSetPadMode(GPIOC, 9, PAL_MODE_ALTERNATE(12) | PAL_STM32_PUPDR_PULLUP);
palSetPadMode(GPIOC, 10, PAL_MODE_ALTERNATE(12) | PAL_STM32_PUPDR_PULLUP);
palSetPadMode(GPIOC, 11, PAL_MODE_ALTERNATE(12) | PAL_STM32_PUPDR_PULLUP);
sdcObjectInit(&SDCD1);
sdcStart(&SDCD1, &sdccfg);
if (blkIsInserted(&SDCD1)) {
debug("Card inserted, initing SD card...");
bool status = false;
do {
status = sdcConnect(&SDCD1);
if (status != HAL_SUCCESS) {
debug("SD Error!");
}
else {
chprintf(&SD1, "CSD : %08X %8X %08X %08X \r\n", SDCD1.csd[3],
SDCD1.csd[2], SDCD1.csd[1], SDCD1.csd[0]);
break;
}
} while (TRUE);
}
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: SDC Sporadic Issues
Hi,
blkIsInserted(&SDCD1) is something you need to implement in your board.c file, there is no standard way for detection.
Giovanni
blkIsInserted(&SDCD1) is something you need to implement in your board.c file, there is no standard way for detection.
Giovanni
Re: SDC Sporadic Issues
Thank you for your help, Giovanni. I found that I had some jumpers on the same pins that are connected to the Micro SD adapter on my board. Must have had some capacitance that was corrupting the data going through. Amateur mistake, but hopefully can benefit from this post.
Who is online
Users browsing this forum: No registered users and 23 guests