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.

TM4C123GH6PGE: SD CARD writing issue

Part Number: TM4C123GH6PGE

Hello everyone,

                          Thanks to everyone for suggesting me in my previous issues.

                   Now this time i want to write the data into SD Card by using SPI Communication.Its writing perfect by the below code and i am using 5 interrupts parallel and  SD CARD data writing in while loop continuously. Here what i am getting the problem is when the data writing into SD CARD,at that time my other interrupts are stop few milliseconds and again it will start immediately.  Here what i want is, I do not want to disturb to my other interrupts when the data writing to SD Card. I attach the code below.

//*****************************sdcard *************************************************


iFResult = f_mount(0, &g_sFatFs);

if(iFResult != FR_OK)
{

return(1);
}


iFResult = f_open(&g_sFileObject, filename, FA_WRITE|FA_OPEN_ALWAYS| FA_READ);

iFResult=f_lseek(&g_sFileObject, f_size(&g_sFileObject));


do
{

iFResult = f_write(&g_sFileObject, buf2, sizeof(buf2) - 1, & ui32BytesWrite);
iFResult = f_sync(&g_sFileObject);
}while(ui32BytesWrite != sizeof(buf2)-1);

iFResult = f_write(&g_sFileObject, new_line, sizeof(new_line) - 1, & ui32BytesWrite);
iFResult = f_sync(&g_sFileObject);
iFResult = f_write(&g_sFileObject, new_line, sizeof(new_line) - 1, & ui32BytesWrite);
iFResult = f_sync(&g_sFileObject);
do
{

iFResult = f_write(&g_sFileObject, buf1, sizeof(buf1) - 1, & ui32BytesWrite);
iFResult = f_sync(&g_sFileObject);
}while(ui32BytesWrite != sizeof(buf1)-1);

iFResult = f_write(&g_sFileObject, new_line, sizeof(new_line) - 1, & ui32BytesWrite);
iFResult = f_sync(&g_sFileObject);


while(1)
{

strcat(buf_rz,buffer2);

iFResult = f_sync(&g_sFileObject);


iFResult = f_write(&g_sFileObject, new_line, sizeof(new_line) - 1, & ui32BytesWrite);


iFResult = f_sync(&g_sFileObject);


for(g=0;g<=2;g++)
{
for(h=1;h<=500;h++)
{
SysCtlDelay(16000);
}
}

iFResult = f_write(&g_sFileObject, buf_rz, sizeof(buf_rz) - 1, & ui32BytesWrite);

iFResult = f_sync(&g_sFileObject);

}

After debugging my code i found that  

iFResult = f_sync(&g_sFileObject);           is creating the issue to other my interrupts

Please suggest me how to resolve the issue.

Thanks,

Regards,

Srinu.V

 

  • f_sync actually forces the write to the SD card and it takes some time for that to occur. Are you calling the code above inside of an interrupt routine?
  • Hai sir,

    I am using the above code in while(1) for continue execution.

    Thanks,
    Regards,
    Srinu.V.
  • Which port are you using? Is it from mmc-dk-tm4c123g.c?
  • Hai sir,
    I'm using SSI0 From port-A and I am using mmc-dk-tm4c123g.c

    Thanks,
    Regards,
    Srinu.V.
  • That file uses ROM_SSIDataPut() and ROM_SSIDataGet(). ROM_SSIDataGet() will wait for the SSI transfer to complete, but it does not block interrupts. How did you determine that f_sync is the problem?
  • Thank you sir for your valuable suggestion,

    I am not sure f_sync is only creating the issue. In my code i am observing output results in ccs debugger along with oscilloscope. When the compiler starts execution and when the compiler execute the iFResult = f_sync(&g_sFileObject); instruction, then my PWM Stops working few nano to milliseconds and after completion of the execution of that instruction again my PWM comes into normal previous condition, I am using PWM interrupt for generating PWM Signal.
    Please suggest me anything wrong in my code.

    My main clock is

    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ);

    // Configure SysTick for a 100Hz interrupt. The FatFs driver wants a 10 ms tick.

    ROM_SysTickPeriodSet(SysCtlClockGet() / 100);
    ROM_SysTickEnable();
    ROM_SysTickIntEnable();


    void
    SysTickHandler(void)
    {
    //
    // Call the FatFs tick timer.
    //
    disk_timerproc();
    }


    I am using above instructions for clock signals, Please suggest me any mismatch in the clock signals or please suggest me any other instructions required.

    I attached the image of my debugger output, when the SD Card starts writing that time CPU RESET is enabling  (few nano to milliseconds time) and my PWM interrupt stops for few nano to milliseconds and again CPU RESET disable(within milliseconds) and PWM states will come on normal.This process is going continuously.

    I request you to please suggest me how to avoid this issue.

    Thanks,

    Regards,

    Srinu.V

  • I am confused. You circled the icon for asserting a CPU reset, and have labeled it "ENABLING". Is you system being periodically reset? This would explain why the PWM would be interrupted. If you put a breakpoint at the beginning of the "ResetISR" function you can see if you code is being reset. Then you can look at the system control RESC (reset cause) register to determine the source of the reset.
  • Yes sir,

    In my code CPU reset is happening in periodically.in this I think all my interrupts just halt and again it will starts.
    It's stop resetISR in start_up.ccs.

    I request you to please suggest me how to resolve this issue.

    Thanks,
    Regards,
    Srinu.V.
  • Is the watchdog enabled? What is the value in the SYSCTL_RESC register (System Control Reset Cause)?

  • Hai sir,

                Thanks for your valuable suggestions.

    I attach the snapshot of the  SYSCTL_RESC register. I request you to please find the attachment.

    when the reset occurs the my compiler goes to below function in startup_ccs.c

    void

    ResetISR(void)

    {

       //

       // Jump to the CCS C initialization routine.  This will enable the

       // floating-point unit as well, so that does not need to be done here.

       //

       __asm("    .global _c_int00\n"

             "    b.w     _c_int00");

    }

    I request you to please suggest me how to resolve this issue.

    Thanks,

    Regards,

    Srinu.V.