Possible bug in sdmmc_execute_command()

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Possible bug in sdmmc_execute_command()

275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brownm on Tue Apr 22 00:53:34 MST 2014
HI There

I might be a bit of track here so please feel free to correct me.

I have a LPC4337 and I'm trying to initialise a single SD card (I have tried several). unfortunately I don't have a NXP 43xx development board to compare my results on, just our own boards, so there is the possibility of a hardware fault, although I did manage to get a single card to complete the SD card example code, a few times (but not any longer)

Reading the SD card spec, it appears that the initialisation requires a lower clock speed of 400kHz

the initialisation commands in the example set a low speed bit. (sdmmc_18xx_43xx.h)
#define CMD_SD_SEND_IF_COND CMD(SD_CMD8, 1)      | CMD_BIT_LS


this CMD_BIT_LS is not used anywhere. so I used it in
(sdmmc_18xx_43xx.c)
sdmmc_execute_command()



//added to slow down clock during CD card init
#define LOW_SPEED_CLOCK 800000 //4MHZ to test ratios

int32_t clock_rate = LOW_SPEED_CLOCK;
if (cmd & CMD_BIT_LS){
clock_rate = LOW_SPEED_CLOCK;
}
else{
clock_rate = g_card_info->card_info.speed;
}


then where the clock is changed in the while loop.
while (step) {
//Chip_SDIF_SetClock(pSDMMC, Chip_Clock_GetRate(CLK_MX_SDIO), g_card_info->card_info.speed);
Chip_SDIF_SetClock(pSDMMC, Chip_Clock_GetRate(CLK_MX_SDIO), clock_rate);


This seemed to make some difference to the initialisation but its still not quite right.

If you set the clock at 400kHz with a base clock of 204MHz it gives a divisor of 256, which ends up being a divisor of 1, there is no error checking in the clock divisor calculation to make sure that the divisor is within bounds (this is minor for right now) so I have set the initial clock to 800kHz which gives a reasonable result.

Can someone please confirm that this is something that needs addressing, or is it a red herring on my debug path.

Thanks and Regards
Marshall Brown

Labels (1)
1 Reply

225 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brownm on Tue Apr 22 16:01:44 MST 2014
While the above question still remains valid (should the initialisation drop down to 400kHz) I have solved the issue with not being able to init any cards.

We have a transistor controlling the power to the VDD on the SD card, which in turn is controlled from the microcontroller SD-Reset pin. This transistor was not turning on hard enough, so when the SD card went to write some data, the transistor was not able to supply the necessary current. Which in turn messed everything up.

Changing the biasing resistors solved the issue.

Thanks
Marshall

0 Kudos