2014-04-19 08:22 PM
Guys,
I tried to read SDHC 8Gb with SDIO and it works fine, but when I change into 64Gb SDXC, it doesn't work ? Do you have any ideas what the cause is ? When I tried with SPI and Atmega controller and SPI , they're all working properly. Thanks2014-04-19 09:08 PM
Do you have any ideas what the cause is ?
Well my list of probable issues would by the driver, the commands it uses, and the block/byte addressing methods employed, and the file system, the 64GB card likely doesn't use FAT32.2014-04-20 04:55 AM
I used FAT32 for 64 Gb and it works fine on atmega MCU with SPI, and I'm still using FAT32 for STM32 with SDIO interface, I'll see the driver....
I'm using FATFs for STM32......2014-04-20 04:58 AM
I tested with 1Gb and it doesn't work too....strange..
2014-04-20 06:51 PM
Probably from here ?
What's HCLK ? is it 72MHz ? I have 8MHz external Crystal * @brief SDIO Intialization Frequency (400KHz max) */ #define SDIO_INIT_CLK_DIV ((uint8_t)0xB2) //#define SDIO_INIT_CLK_DIV ((uint8_t)0xB5)
/*!< Power ON Sequence -----------------------------------------------------*/
/*!< Configure the SDIO peripheral */
/*!< SDIOCLK = HCLK, SDIO_CK = HCLK/(2 + SDIO_INIT_CLK_DIV) */
/*!< SDIO_CK for initialization should not exceed 400 KHz */
SDIO_InitStructure.SDIO_ClockDiv = SDIO_INIT_CLK_DIV;
SDIO_InitStructure.SDIO_ClockEdge = SDIO_ClockEdge_Rising;
SDIO_InitStructure.SDIO_ClockBypass = SDIO_ClockBypass_Disable;
SDIO_InitStructure.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable;
SDIO_InitStructure.SDIO_BusWide = SDIO_BusWide_1b;
SDIO_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;
SDIO_Init(&SDIO_InitStructure);
2014-04-20 07:02 PM
Complete power on function
PowerON(void)
{
SD_Error errorstatus = SD_OK;
uint32_t response = 0, count = 0, validvoltage = 0;
uint32_t SDType = SD_STD_CAPACITY;
/*!<
Power
ON Sequence -----------------------------------------------------*/
/*!< Configure the SDIO peripheral */
/*!<
SDIOCLK
=
HCLK
,
SDIO_CK
=
HCLK
/(2 + SDIO_INIT_CLK_DIV) */
/*!< SDIO_CK for initialization should not exceed 400 KHz */
SDIO_InitStructure.SDIO_ClockDiv
=
SDIO_INIT_CLK_DIV
;
SDIO_InitStructure.SDIO_ClockEdge
=
SDIO_ClockEdge_Rising
;
SDIO_InitStructure.SDIO_ClockBypass
=
SDIO_ClockBypass_Disable
;
SDIO_InitStructure.SDIO_ClockPowerSave
=
SDIO_ClockPowerSave_Disable
;
SDIO_InitStructure.SDIO_BusWide
=
SDIO_BusWide_1b
;
SDIO_InitStructure.SDIO_HardwareFlowControl
=
SDIO_HardwareFlowControl_Disable
;
SDIO_Init(&SDIO_InitStructure);
/*!< Set Power State to ON */
SDIO_SetPowerState(SDIO_PowerState_ON);
/*!< Enable SDIO Clock */
SDIO_ClockCmd(ENABLE);
/*!< CMD0: GO_IDLE_STATE ---------------------------------------------------*/
/*!< No CMD response required */
SDIO_CmdInitStructure.SDIO_Argument
=
0x0
;
SDIO_CmdInitStructure.SDIO_CmdIndex
=
SD_CMD_GO_IDLE_STATE
;
SDIO_CmdInitStructure.SDIO_Response
=
SDIO_Response_No
;
SDIO_CmdInitStructure.SDIO_Wait
=
SDIO_Wait_No
;
SDIO_CmdInitStructure.SDIO_CPSM
=
SDIO_CPSM_Enable
;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus
=
CmdError
();
if (errorstatus != SD_OK)
{
/*!< CMD Response TimeOut (wait for CMDSENT flag) */
return(errorstatus);
}
/*!< CMD8: SEND_IF_COND ----------------------------------------------------*/
/*!< Send CMD8 to verify SD card interface operating condition */
/*!< Argument: - [31:12]: Reserved (shall be set to '0')
- [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)
- [7:0]: Check Pattern (recommended 0xAA) */
/*!< CMD Response: R7 */
SDIO_CmdInitStructure.SDIO_Argument
=
SD_CHECK_PATTERN
;
SDIO_CmdInitStructure.SDIO_CmdIndex
=
SDIO_SEND_IF_COND
;
SDIO_CmdInitStructure.SDIO_Response
=
SDIO_Response_Short
;
SDIO_CmdInitStructure.SDIO_Wait
=
SDIO_Wait_No
;
SDIO_CmdInitStructure.SDIO_CPSM
=
SDIO_CPSM_Enable
;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus
=
CmdResp7Error
();
if (errorstatus == SD_OK)
{
CardType
=
SDIO_STD_CAPACITY_SD_CARD_V2_0
; /*!< SD Card 2.0 */
SDType
=
SD_HIGH_CAPACITY
;
}
else
{
/*!< CMD55 */
SDIO_CmdInitStructure.SDIO_Argument
=
0x00
;
SDIO_CmdInitStructure.SDIO_CmdIndex
=
SD_CMD_APP_CMD
;
SDIO_CmdInitStructure.SDIO_Response
=
SDIO_Response_Short
;
SDIO_CmdInitStructure.SDIO_Wait
=
SDIO_Wait_No
;
SDIO_CmdInitStructure.SDIO_CPSM
=
SDIO_CPSM_Enable
;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus
=
CmdResp1Error
(SD_CMD_APP_CMD);
}
/*!< CMD55 */
SDIO_CmdInitStructure.SDIO_Argument
=
0x00
;
SDIO_CmdInitStructure.SDIO_CmdIndex
=
SD_CMD_APP_CMD
;
SDIO_CmdInitStructure.SDIO_Response
=
SDIO_Response_Short
;
SDIO_CmdInitStructure.SDIO_Wait
=
SDIO_Wait_No
;
SDIO_CmdInitStructure.SDIO_CPSM
=
SDIO_CPSM_Enable
;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus
=
CmdResp1Error
(SD_CMD_APP_CMD);
/*!< If errorstatus is Command TimeOut, it is a MMC card */
/*!< If errorstatus is SD_OK it is a SD card: SD card 2.0 (voltage range mismatch)
or SD card 1.x */
if (errorstatus == SD_OK)
{
/*!< SD CARD */
/*!< Send ACMD41 SD_APP_OP_COND with Argument 0x80100000 */
while ((!validvoltage) && (count < SD_MAX_VOLT_TRIAL))
{
/*!< SEND CMD55 APP_CMD with RCA as 0 */
SDIO_CmdInitStructure.SDIO_Argument
=
0x00
;
SDIO_CmdInitStructure.SDIO_CmdIndex
=
SD_CMD_APP_CMD
;
SDIO_CmdInitStructure.SDIO_Response
=
SDIO_Response_Short
;
SDIO_CmdInitStructure.SDIO_Wait
=
SDIO_Wait_No
;
SDIO_CmdInitStructure.SDIO_CPSM
=
SDIO_CPSM_Enable
;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus
=
CmdResp1Error
(SD_CMD_APP_CMD);
if (errorstatus != SD_OK)
{
return(errorstatus);
}
SDIO_CmdInitStructure.SDIO_Argument
=
SD_VOLTAGE_WINDOW_SD
| SDType;
SDIO_CmdInitStructure.SDIO_CmdIndex
=
SD_CMD_SD_APP_OP_COND
;
SDIO_CmdInitStructure.SDIO_Response
=
SDIO_Response_Short
;
SDIO_CmdInitStructure.SDIO_Wait
=
SDIO_Wait_No
;
SDIO_CmdInitStructure.SDIO_CPSM
=
SDIO_CPSM_Enable
;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus
=
CmdResp3Error
();
if (errorstatus != SD_OK)
{
return(errorstatus);
}
response
=
SDIO_GetResponse
(SDIO_RESP1);
validvoltage = (((response >> 31) == 1) ? 1 : 0);
count++;
}
if (count >= SD_MAX_VOLT_TRIAL)
{
errorstatus = SD_INVALID_VOLTRANGE;
return(errorstatus);
}
if (response &= SD_HIGH_CAPACITY)
{
CardType = SDIO_HIGH_CAPACITY_SD_CARD;
}
}/*!< else MMC Card */
return(errorstatus);
}
2014-04-20 07:03 PM
anything missing / broken ? thanks
2014-04-20 07:45 PM
I tried on :
#define SDIO_TRANSFER_CLK_DIV ((uint8_t)0x3) and it's working on 64GB sdcard but there're some noises on the picture (256 colors), dot dot noise with random position... but with 0x3, it's not stable on 8Gb, stop in the middle.....don't know why ?2014-04-20 08:07 PM
Yes, if the PLL is clocking at 72 MHz, then HCLK is there.
When first configuring the card a 400 KHz SPI rate is used, after the performance has been determined, it switches up to higher speeds or 4-bits. I'd expect a Ultra/SDXC type card to work at pretty high speeds. Programming a value of 0 would get a 36 MHz clock.2014-04-20 08:19 PM
Different cards have different maximal frequencies, 14.4 MHz doesn't seem that high, a lot of cards are rated at 25 or 50 MHz, as I recall, but that does require a considered implementation with short consistent track lengths, effective grounding and guarding.