cancel
Showing results for 
Search instead for 
Did you mean: 

FAT write problem uin sd card

rajesh23
Associate II
Posted on August 16, 2016 at 12:16

hi,

i am trying to do a data logger using FAT with sd card. in the below code trying to write in sd card with 100ms interval, the code has write into sdcard at only one time. latter it has gone to error


/*##-1- Link the micro SD disk I/O driver ##################################*/

if
(FATFS_LinkDriver(&SD_Driver, SDPath) == 0)

{

/*##-2- Register the file system object to the FatFs module ##############*/

if
(f_mount(&SDFatFs, (TCHAR 
const
*)SDPath, 0) != FR_OK)

{

/* FatFs Initialization Error */

Error_Handler();

}

else

{

/*##-3- Create a FAT file system (format) on the logical drive #########*/

/* WARNING: Formatting the uSD card will delete all content on the device */

// if(f_mkfs((TCHAR const*)SDPath, 0, 0) != FR_OK)

{

/* FatFs Format Error */

Error_Handler();

}

// else

{


while
(1)

{

/*##-4- Create and Open a new text file object with write access #####*/

if
(f_open(&MyFile, 
''STMTXT''
, FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)

{

/* 'STMTXT' file Open for write Error */

Error_Handler();

}

else

{



/*##-5- Write data to the text file ################################*/

res = f_write(&MyFile, wtext, bytesread, (
void
*)&byteswritten);

// while(byteswritten != bytesread)

{

BSP_LED_Toggle(LED1);

// HAL_Delay(1000);


}

f_close(&MyFile);

HAL_Delay(100);



}


}

{

}

what is the way to make a data logger using STM32F746G.disco baord regards Rajesh #stm32 #usb #fatfs #no-hablo-hal #fr_not_ready #stm32f746g-disco-
10 REPLIES 10
rajesh23
Associate II
Posted on September 08, 2016 at 13:18

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6Zj&d=%2Fa%2F0X0000000br2%2F3IhR6jrYEvtN2bYhw3_YGIDD9QfJQzd92LeWI9Bp3N8&asPdf=false