realingrui 发表于 2015-3-2 20:55:23

stm32-SDIO-4bits发送数据时出错(有谁调通过SDIO的帮忙看一下)

我向操作单元为“字”的FIFO中写入一个“字”;查询时,发现FIFO中被重复写了32个“字”。(FIFO一共有32个字的存储空间)
以下是我针对此问题写的一段代码:
#include "stm32f10x.h"
#include "stm32f10x_conf.h"

SDIO_DataInitTypeDef SDIO_DataInitStructure;   
SDIO_InitTypeDef SDIO_InitStructure;

void SD_LowLevel_Init(void)      ;
void SDIO_DataInit(void);


int main(void)
{
    char *character= "abcdefghijklmnop" ;
      uint32_t*data= (uint32_t *)character ;

    SD_LowLevel_Init();
    SDIO_DataInit();


    SDIO->DCTRL = 0;

      SDIO_DataInitStructure.SDIO_DataLength = 16;

    SDIO_SetSDIOOperation(ENABLE);
      SDIO_DataInitStructure.SDIO_DataTimeOut = 0xffffffff;

    SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToCard;    //SDIO_TransferDir_ToCard=0 SDIO_TransferDir_ToSDIO=2
    SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Stream;   // SDIO_TransferMode_Stream SDIO_TransferMode_Block
    SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable;
    SDIO_DataConfig(&SDIO_DataInitStructure);

         SDIO->FIFOCNT;
         SDIO->DCOUNT;
         SDIO_WriteData(0X12345678);
         SDIO->FIFOCNT;
         SDIO->DCOUNT;

         SDIO_WriteData(*data++);
         SDIO->FIFOCNT;
         SDIO->DCOUNT;

         SDIO_WriteData(*data++);
         SDIO->FIFOCNT;
         SDIO->DCOUNT;

         SDIO_WriteData(*data);
         SDIO->FIFOCNT;
         SDIO->DCOUNT;

}









void SD_LowLevel_Init(void)
{
GPIO_InitTypeDefGPIO_InitStructure;

/*!< GPIOC and GPIOD Periph clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD , ENABLE);

/*!< Configure PC.08, PC.09, PC.10, PC.11, PC.12 pin: D0, D1, D2, D3, CLK pin */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);

/*!< Configure PD.02 CMD line */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_Init(GPIOD, &GPIO_InitStructure);

      /*!< Enable the SDIO AHB Clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_SDIO, ENABLE);

/*!< Enable the DMA2 Clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE);
}


void SDIO_DataInit(void)
{
SDIO_DeInit();

/*!< Power ON Sequence -----------------------------------------------------*/
/*!< Configure the SDIO peripheral */
/*!< SDIO_CK = SDIOCLK / (SDIO_INIT_CLK_DIV + 2) */
/*!< on STM32F4xx devices, SDIOCLK is fixed to 48MHz */
/*!< SDIO_CK for initialization should not exceed 12 MHz */
SDIO_InitStructure.SDIO_ClockDiv = 0x04;
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_4b;
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);

/*******************************************Gainspan Testing******************************/
    SDIO_DataStructInit(&SDIO_DataInitStructure);

}

天好蓝 发表于 2015-3-2 21:10:27

s7631001 发表于 2015-3-3 01:21:44

还看不出来,需要继续学习呀:$

北斗光寒 发表于 2015-3-3 08:15:30

SDIO是啥东东?

wambob 发表于 2015-3-3 08:31:46

北斗光寒 发表于 2015-3-3 08:15
SDIO是啥东东?

SD卡的I/O口吧

拼命三郎 发表于 2015-3-3 10:26:13

拼命三郎 发表于 2015-3-3 10:26:30

北斗光寒 发表于 2015-3-4 20:43:02

wambob 发表于 2015-3-3 08:31
SD卡的I/O口吧

我去我说呢

handfriendly 发表于 2016-4-29 15:24:27

你的问题解决了吗? 我目前sdio 4bit 也是出读写出问题,可以交流下, 我的QQ: 740084209
页: [1]
查看完整版本: stm32-SDIO-4bits发送数据时出错(有谁调通过SDIO的帮忙看一下)