2010-09-16 06:07 PM
STM3210VE, 8G SD card , SDIO 4bits bus, DMA mode-STOne-32,help me please
2011-05-17 05:07 AM
Can you pleas attach the whole project, that works with such SD cards?
It would be very helpful. Thanks in advance.2011-05-17 05:07 AM
420KB / S to write the file is too slow, I'm improving.
When writing the file the CPU is waiting for DMA, DMA can not play the greatest effectiveness.
I was to change the code, it will be updated here.
Tomorrow is
China National Day
, I come back in 7 days.Happy Holidays!
2011-05-17 05:07 AM
DMA_TxConfiguration(writebuff, (NumberOfBlocks * BlockSize));
while ((DMA_GetFlagStatus(DMA2_FLAG_TC4) == RESET) && (DMA_GetFlagStatus(DMA2_FLAG_TE4) == RESET) && (TransferError == SD_OK)); // TransferError set by interrupt handler.
//--Every time when configuring DMA, CPU in a wait state.
This is very bad you know.
2011-05-17 05:07 AM
please attach the whole project...I have same problem.....
Thanks...2011-05-17 05:07 AM
I rewrite the code,There are few
Changes
in the sdcard.c. I try to attach the new project,but the Great Fire Wall......you know...... so.the changs below:SD_Error SD_EnableWideBusOperation(u32 WideMode)
{ SD_Error errorstatus = SD_OK;/* MMC Card doesn't support this feature */
if (SDIO_MULTIMEDIA_CARD == CardType) { errorstatus = SD_UNSUPPORTED_FEATURE; return(errorstatus); } else if ((SDIO_STD_CAPACITY_SD_CARD_V1_1 == CardType) || (SDIO_STD_CAPACITY_SD_CARD_V2_0 == CardType) || (SDIO_HIGH_CAPACITY_SD_CARD == CardType)) { if (SDIO_BusWide_8b == WideMode) { errorstatus = SD_UNSUPPORTED_FEATURE; return(errorstatus); } else if (SDIO_BusWide_4b == WideMode) { errorstatus = SDEnWideBus(ENABLE);if (SD_OK == errorstatus)
{ /* Configure the SDIO peripheral */ // SDIO_InitStructure.SDIO_ClockDiv = SDIO_TRANSFER_CLK_DIV; SDIO_InitStructure.SDIO_ClockDiv = SDIO_TRANSFER_CLK_DIV + 9;//6M 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_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;
SDIO_Init(&SDIO_InitStructure);
} } ----------------------------------------------------------------- SD_Error SD_WriteMultiBlocks(u32 addr, u32 *writebuff, u16 BlockSize, u32 NumberOfBlocks) { ............................................DMA_TxConfiguration(writebuff, (NumberOfBlocks * BlockSize));
while ((DMA_GetFlagStatus(DMA2_FLAG_TC4) == RESET) && (DMA_GetFlagStatus(DMA2_FLAG_TE4) == RESET) && (TransferError == SD_OK)); // TransferError set by interrupt handler.
if (DMA_GetFlagStatus(DMA2_FLAG_TE4)==SET) TransferError = SD_ERROR; //uart_puts(''DMA Transfer error\n'');
if (TransferError!=SD_OK) return(TransferError);// while (DMA_GetFlagStatus(DMA2_FLAG_TC4) == RESET)
// {} while ((TransferEnd == 0) && (TransferError == SD_OK)) {} if (TransferError != SD_OK) { return(TransferError); } } } /* Clear all the static flags */ SDIO_ClearFlag(SDIO_STATIC_FLAGS);/* Wait till the card is in programming state *///�?等待flash擦写完毕
// errorstatus = IsCardProgramming(&cardstate); // // while ((errorstatus == SD_OK) && ((cardstate == SD_CARD_PROGRAMMING) || (cardstate == SD_CARD_RECEIVING))) // { // errorstatus = IsCardProgramming(&cardstate); // }return(errorstatus);
}............................................
FRESULT f_write ( FIL *fp, /* Pointer to the file object */ const void *buff, /* Pointer to the data to be written */ UINT btw, /* Number of bytes to write */ UINT *bw /* Pointer to number of bytes written */ ) ........................... for ( ; btw; /* Repeat until all data transferred */ wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ if (fp->csect >= fp->fs->csize) { /* On the cluster boundary? */ if (fp->fptr == 0) { /* On the top of the file? */ clst = fp->org_clust; /* Follow from the origin */ if (clst == 0) /* When there is no cluster chain, */ fp->org_clust = clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ } else { /* Middle or end of the file */ clst = create_chain(fp->fs, fp->curr_clust); /* Follow or streach cluster chain */ } if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ if (clst == 1) ABORT(fp->fs, FR_INT_ERR); if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); fp->curr_clust = clst; /* Update current cluster */ fp->csect = 0; /* Reset sector address in the cluster */ }//before i am writting,i format the clusters to 32KB because i write less than 32KB one time .........................2011-05-17 05:07 AM
There are much other codes in the whole project and it is b
elonging to the company,i'm sorry.
If you attach your project,I can fix it and test it in the t
he same environment
for you.2011-05-17 05:07 AM
Howdy
I'm using 4bit wide SDIO with DMA. I haven't encountered any problems with DMA, only SDIO CRC errors after writing. Increasing SDIO_TRANSFER_CLK_DIV by one solved the problem. I'm using the code from CMSIS 3.3.0 examples directory.