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