-1

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));  
    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:

enter image description here

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

enter image description here

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?

zapl
  • 63,179
  • 10
  • 123
  • 154
JMS
  • 1

2 Answers2

0

Is this using the FreeRTOS+FAT? Or something that shipped with your development environment? In any case, it looks like the timing your are measuring is related to the driver that is performing the actual write to the SD card, so I would suggest taking timings inside the driver. Also, have you tried different SD cards - our experience is that the difference in performance between different manufacturers is very large, to the point where some cards are almost unusable while others are very fast when subjected to the same tests.

Richard
  • 3,081
  • 11
  • 9
0

Writing to any sort of media in real time RELIABLY requires buffering on your side.

The SD controllers in the cards themselves do their best to decrease latency through fancy management of buffers, etc. but even the best ones can have latency on any given write that lasts 250ms or more as it performs garbage collection.

On average, they'll manage the throughput they advertise, but the host/library needs to manage asynchronous writes and buffering to isolate your timing critical portion of the system.

Russ Schultz
  • 2,545
  • 20
  • 22