cancel
Showing results for 
Search instead for 
Did you mean: 

Dear Sir,I am using STM32L452RET6 for the SD card interface in SDIO with BUS_WIDE_4B mode in interrupt mode.You can find attached .ioc file for the reference. I am writing 512 bytes using f_write function then it takes time to write approx 13mili sec.

KPras.2
Associate III
 
2 REPLIES 2
KPras.2
Associate III

If i write 3 packet of 512 bytes then it takes more than 20 milisec. Yo can see the f_write function which i am usng.

if(f_open(&SDFile, "DATA.TXT", FA_OPEN_EXISTING |FA_WRITE | FA_OPEN_APPEND) != FR_OK)

  {

    Error_Handler();

  }

  else

  {

res = f_write(&SDFile, &sd_write_buff_New[0], 512, &byteswritten);

res = f_write(&SDFile, &sd_write_buff_New[512], 512, &byteswritten);

res = f_write(&SDFile, &sd_write_buff_New[1024], 512, &byteswritten);

if((byteswritten > 0) && (res == FR_OK))

if(f_open(&SDFile, "DATA.TXT", FA_OPEN_EXISTING |FA_WRITE | FA_OPEN_APPEND) != FR_OK)
    {
       Error_Handler();			
    }
    else
    {
			
				res = f_write(&SDFile, &sd_write_buff_New[0], 512, &byteswritten);
				res = f_write(&SDFile, &sd_write_buff_New[512], 512, &byteswritten);
				res = f_write(&SDFile, &sd_write_buff_New[1024], 512, &byteswritten);
				
 
 
 
				if((byteswritten > 0) && (res == FR_OK))
				{
//					if(Led_flag == 1)
//					{
//						HAL_GPIO_WritePin(Led_Red_GPIO_Port, Led_Red_Pin, GPIO_PIN_RESET);
//						Led_flag = 0;
//					}
//					else if (Led_flag == 0)
//					{
//						HAL_GPIO_WritePin(Led_Red_GPIO_Port, Led_Red_Pin, GPIO_PIN_SET);
//						Led_flag = 1;
//					}
					datawritecnt++;
					if(datawritecnt >= FILE_WRITE_COUNT)  //1382400 , 10000 means 55 minutes, 1000000  means 91 hour   40 mean 10sec data 7200 mean 30 minutes 
					{
            datawritecnt = 0;
					}
//						SendFlag = 1;
					#if SD_WRITE_DEBUG
						{
							char buf[10];
							sprintf(buf,"%d\n\r",datawritecnt);
							SendString(buf);
						}
					#endif
				}
				f_close(&SDFile);
 
   }

{

}

}

f_close(&SDFile);

  }

What is the reason of taking high writing time?? I want to write 4096 bytes in less than 1 mili second. It is possible??

Slow cards, large erase block size, and small writes?

Write more data less frequently.

S​uggest timing 32KB aligned f_write()

Should be able to sustain couple of MBps.

4 MBps might be a challenge, and I don't have L4 benchmarks to hand.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..