e12 wrote on Thursday, May 26, 2016:
I raise this question during use freertos fat.
The development environment using iar compiler and MCU is using the cortex-m4.
I use the hal library and the contents of FreeRTOS FAT Config.h are as follows:
#define BUS_4BITS 1
#define SDIO_USES_DMA 1
I generated only one task, SDcard write, which write 400byte with 50hz
the task is as follows:
void SDCARD_WRITE_Task(void * pvParameters)
{
uint32_t PreviousWakeTime = 0;
SDcard_Init();
SDcard_SetFileName(“FDR”,"/FDR");
for(;
{
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6,GPIO_PIN_SET); //pin high
PreviousWakeTime = osKernelSysTick();
SDcard_Write(ucFileName, SDCARD_Buffer, sizeof(SDCARD_Buffer)); //wirte 400byte
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_6,GPIO_PIN_RESET); // pin low
vTaskDelayUntil(&PreviousWakeTime, 20/portTICK_PERIOD_MS );
}
}
PG6, the pin is high at start, will be low state at the end of the cycle to check the processing time
SDcard Write the contents of the function is as follows:
void SDcard_Write(uint8_t * filename, uint8_t *buf, uint16_t size)
{
FF_FILE *pxFile;
int32_t lItemsWritten;
static int32_t cnt = 0;
pxFile = ff_fopen( (char const*)filename, "a" ); // open the file
if ((pxFile) != 0){SDCARD_STATUS.SD_IsFileOpened = SD_FILEOPENED;}
memset( buf, 0, size);
snprintf( (char*)(buf + 5), (size-5), "FDR_%020d", cnt);
cnt++;
*((buf + 0)) = 'S';
*((buf + (size-3))) = 'E';
*((buf + (size-2))) = '\r';
*((buf + (size-1))) = '\n';
lItemsWritten = ff_fwrite( buf, size, 1, pxFile ); // write 400 byte
SDCARD_STATUS.SD_FileWrittenSize = lItemsWritten*400;
ff_fclose( pxFile );
SDCARD_STATUS.SD_FileAffordSize = SDcard_Capacity_MB(pxDisk); // check SDcard Capacity
}
SDCARD WRITE Task oscilloscope results confirmed cases unexpected time length occurred during the test, I set it up 50hz to write 400byte but, sometime it takes 200~250ms oftenly
even if I change the length of bytes the problem still occurred
Why does this problem happen?
is there any chance I can write 512bytes with 50hz?
or is there any limitation of bytes or frequency for SDcard writing?