我向操作单元为“字”的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_InitTypeDef GPIO_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);
} |