How to continuously store data into SD card?
I have SD card interfaced with stm32f407 through 4bit SDIO. I am writing data from I2S _DMA_receive buffer into the sd card. This write should happen continuously,but it happens only once.Here is the piece of the code:
FATFS myFATAFS;
FATFS *myFATAFS1;
FIL myFILE;
UINT testByte;
FRESULT res;
uint16_t i2s_rcvbf[2];
uint32_t i2s_final;
while(1)
{
HAL_I2S_Receive_DMA(&hi2s2,i2s_rcvbf,2);
i2s_final= (i2s_rcvbf[0]<<16)+ i2s_rcvbf[1];
HAL_Delay(500);
if(f_mount(&myFATAFS,SD_Path,1)==FR_OK)
{
char myPath[]="0:rec.wav";
if(f_open(&myFILE,myPath,FA_WRITE | FA_OPEN_ALWAYS)== FR_OK)
{
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_14);
if(f_write(&myFILE,(void*)&i2s_final,sizeof(i2s_final),&testByte)==FR_OK)
{
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_15);
}
f_close(&myFILE);
i2s_final=0x00000000;
HAL_Delay(1000);
}
}
}
