2012-03-29 12:49 PM
Hi all, i'm sorry if this has been discuss before, but from reading posts i'm still some what unclear, thus my post.
Right here goes :)Has anyone implemented reliably SDIO using DMA along with say FatFS file system ? There seems to be alot of comments around interrupts and delays when setting DMA, and thus creating a race/lockout.2012-03-29 08:48 PM
Yes, it's been done, I've done it, as have others. (No I cannot post my code).
The Chan FatFS code works well and is very easy to port over to the STM32. You only need edit one file. The challenge lies with the ST-supplied SDIO code. It's useful as example code, but not very useful as ''production'' code. You'll spend a lot of time cleaning it up. Take a look through this forum for posts, and there's also some useful info here:2012-04-03 12:18 PM
Right dont seem to be getting very far with this. Code is just loop forever in the FindSCR function.
while (!(SDIO->STA & (SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR))) { if (SDIO_GetFlagStatus(SDIO_FLAG_RXDAVL) != RESET) { *(tempscr + index) = SDIO_ReadData(); index++; } }Can any offer some light on this ?2012-04-04 09:55 AM
right went back to basics and just tried raw readblock and writeblock, using stm32_eval_sdio_sd.c MCD Ver4.6.0 and this works fine.
If i add the read/write single blocks to the fatfs code it just ends up loop around in SD_GetStatus() status = SD_ReadBlock( (uint8_t *)buff, Memory_Offset, Transfer_Length); /* Check if the Transfer is finished */ status = SD_WaitReadOperation(); while(SD_GetStatus() != SD_TRANSFER_OK);2012-04-10 12:36 AM
more feedback, changed the stm32_eval_sdio_sd.c to version 4.6.1 and now i can get a file to write to the sd-card but only if i add a break point on f_close().
if( f_mount( 0, &fs ) != FR_OK) { } else { if( f_open( &file, ''test.dat'', FA_CREATE_ALWAYS | FA_WRITE ) != FR_OK ) { } else { f_write( &file, buffer, 7, &result ); f_close( &file ); } }My thinking is that f_write() is not waiting correctly for the sd-card and thus me adding a break point on f_close() adds some delay which enables the sd-card to finish its process.Can anyone add to this and help me out ?2012-04-10 01:00 AM
just to confirm can you check the optimisation level in your workspace.Try once minimising teh optimisation level.
And also one imp point: after closing teh file are you unmounting the drive. f_close(&file); f_mount(0, NULL); Regards, Rosarium2012-04-10 08:31 AM
I'm using Atollic Free IDE/Compiler thus opimisation is not Selectable, but it is currently set to None (-O0).
What is the lastest version of stm32_eval_sdio_sd.c from MCD team ?2012-04-10 09:34 AM
There seems to be a bug in this function with regards to the STM3210e evalkit.
When SD-Card is present the signal on PF.11 is LOW. Thus this function returns SD_NOT_PRESENT when the SD-Card is fitted !!!!!uint8_t SD_Detect(void){ __IO uint8_t status = SD_PRESENT; /*!< Check GPIO to detect SD */ if (GPIO_ReadInputDataBit(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) == Bit_RESET) { status = SD_NOT_PRESENT; } return status;}2012-04-10 09:37 AM
Strange thing is in 4.5.0 version it is correct !!!!!
uint8_t SD_Detect(void){ __IO uint8_t status = SD_PRESENT; /*!< Check GPIO to detect SD */ if (GPIO_ReadInputDataBit(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) != Bit_RESET) { status = SD_NOT_PRESENT; } return status;}