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.

SD Card Write Crashes on Concerto using TI Example

I was able to get the sd_card_m3 example working on the F28M35 ControlCard. The example demonstrates reading an SD card using the FatFS library. I was disappointed that the example does not demonstrate writes. When I tried to execute a write command the program breaks to FaultISR. Since there was no writes in the example, I am inclined to believe that pins were not configured completely or that TI did not fully port the processor to work with FatFS. The library is very straight forward, only three lines of code were needed to create a new file, as shown at the bottom. Very little information was on the forum about using the SD card reader on the F28M35 ControlCard. My expectation is that the example would be preconfigured for writing and reading -- I would like to get some feedback from others before I start digging deeper. Thanks for the help.

FIL fil; // File object
fresult = f_open(&fil, "message.txt", FA_CREATE_ALWAYS | FA_WRITE);
f_close(&fil)

  • I pasted my whole main loop below.   No modifications were made to the original initialization. The debugger crashes on line 22 and goes into FaultISR in startup_ccs.c. Disabling lines 41-48, the program runs find.  I am at a loss on why this is happening and why it crashes before the problematic lines.  Problem has been tested in two Concerto cards.  All SSI pins are connected to port C (SD Card) all other jumpers have been removed.

    int main(void)
    {
        int nStatus;
        FIL fil;       /* File object */
        FRESULT fresult;
    
        // Disable Protection
        HWREG(SYSCTL_MWRALLOW) =  0xA5A5A5A5;
    
        // Setup main clock tree for 75MHz - M3 and 150MHz - C28x
        SysCtlClockConfigSet(SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 | SYSCTL_USE_PLL |
                             (SYSCTL_SPLLIMULT_M & 0x0F));
    
        PinoutSet();
    
        // Configure SysTick for a 100Hz interrupt.
        SysTickPeriodSet(SysCtlClockGet(SYSTEM_CLOCK_SPEED) / TICKS_PER_SECOND);
        SysTickEnable();
        SysTickIntEnable();
    
        // Register interrupt handlers in the RAM vector table
        IntRegister(FAULT_SYSTICK, SysTickHandler);
    
        // Enable Interrupts
        IntMasterEnable();
    
        // Initialize the UART as a console for text I/O.
        UARTStdioInit(0);
        IntRegister(INT_UART0, UARTStdioIntHandler);
    
        // Print hello message to user.
        UARTprintf("\n\nSD Card Example Program\n");
        UARTprintf("Type \'help\' for help.\n");
    
        // Mount the file system, using logical disk 0.
        fresult = f_mount(0, &g_sFatFs);
        if(fresult != FR_OK){
            UARTprintf("f_mount error: %s\n", StringFromFresult(fresult));
            return(1);
        }
        fresult = f_open(&fil, "ch1.dat", FA_WRITE | FA_OPEN_ALWAYS);
        if (fresult == FR_OK) {
        	UARTprintf("Created new file.\n");
        	f_close(&fil);
        }
        else{
        	UARTprintf("Failed to create file.\n");
        }
        while(1){}
    }

  • TI,

    Was able to write to the SD Card, but you have a serious issue with the posted example.  The interrupt handler for uartstudio is conflicting with something (probably the SSI), which was causing code to enter a FaultISR.  I worked around the problem by disabling everything related to UART debugging. If you want customers to be able to write to an SD Card you need to fix the example.  Working SD write code posted below.

    int main(void) {
    int nStatus;
    FIL fil; /* File object */
    FRESULT fresult;
    const char buffer[]= "Testing 1234";
    WORD bw = 0;
    
    HWREG(SYSCTL_MWRALLOW) = 0xA5A5A5A5;
    SysCtlClockConfigSet(SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 | SYSCTL_USE_PLL |
    (SYSCTL_SPLLIMULT_M & 0x0F));
    PinoutSet();
    fresult = f_mount(0, &g_sFatFs);
    if(fresult != FR_OK){
    UARTprintf("f_mount error: %s\n", StringFromFresult(fresult));
    return(1);
    }
    
    fresult = f_open(&fil, "ch1.dat", FA_WRITE | FA_CREATE_ALWAYS);
    if (fresult == FR_OK) {
    UARTprintf("Created new file.\n");
    fresult = f_write(&fil, &buffer, sizeof(buffer), &bw);
    f_close(&fil);
    }
    else{
    UARTprintf("Failed to create file.\n");
    }
    while(1){}
    }