This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello everyone,
Thanks to suggesting me in my previous posts.
I am working on sd card interfacing to tm4c123gh6pge microcontroller for data logging purpose. In this, first time execution file is creating,writing,synchronizing process are working perfectly. But in my application, controller is restarted after 4 hours without switching off the power supply. so in these condition again code execution starts from first step and here sd card mounting, writing not working, it creates restarting problem to the controller.
I want to solve this problem from your suggestions, Please find the below code.
void sd_init(void)
{
SysCtlDelay(SysCtlClockGet() / 12);
do
{
iFResult = f_mount(0, &fatfs);
}while(iFResult != FR_OK);
SysCtlDelay(SysCtlClockGet() / 12);
sd_check=0;
do
{
sd_check++;
if(sd_check>8)
{
return;
}
iFResult = f_open(&g_sFileObject, filename, FA_WRITE|FA_OPEN_ALWAYS| FA_READ);
}while(iFResult != FR_OK);
SysCtlDelay(SysCtlClockGet() / 12);
iFResult=f_lseek(&g_sFileObject, f_size(&g_sFileObject));
SysCtlDelay(SysCtlClockGet() / 12);
iFResult = f_write(&g_sFileObject, new_line, sizeof(new_line), &bw);
SysCtlDelay(SysCtlClockGet() / 12);
iFResult = f_write(&g_sFileObject, new_line, sizeof(new_line), &bw);
SysCtlDelay(SysCtlClockGet() / 12);
iFResult = f_write(&g_sFileObject, buf1, sizeof(buf1), &bw);
SysCtlDelay(SysCtlClockGet() / 12);
iFResult = f_write(&g_sFileObject, new_line, sizeof(new_line), &bw);
SysCtlDelay(SysCtlClockGet() / 12);
iFResult = f_sync(&g_sFileObject);
}
//***************************************************************************************
void sd_writing(void)
{
if(sd_check>8)
{
return;
}
SysCtlDelay(SysCtlClockGet() / 12);
strcat((char*)buf_rz+24, buffer2);
SysCtlDelay(SysCtlClockGet() / 12);
iFResult = f_write(&g_sFileObject, new_line, sizeof(new_line), &bw);
SysCtlDelay(SysCtlClockGet() / 3);
SysCtlDelay(SysCtlClockGet() / 6);
iFResult = f_write(&g_sFileObject, buf_rz, sizeof(buf_rz), &bw);
SysCtlDelay(SysCtlClockGet() / 12);
iFResult = f_sync(&g_sFileObject);
SysCtlDelay(SysCtlClockGet() / 12);
}
Here i am storing my data in buffer2 and i am storing my time and date in buf_rz,after these i concatenation of both and writing into the sd card.
I request you to please find the above code and give me the suggestion how to resolve the issue.
Thanks,
Regards,
Srinu.