Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

SIMPLELINK-MSP432-SDK: MSP432E401Y Launchpad: fatsd (No RTOS) and fatsdraw (No RTOS) example code not working

Part Number: SIMPLELINK-MSP432-SDK
Other Parts Discussed in Thread: MSP432E401Y, SYSCONFIG

Hi,

I've imported the fatsd and fatsd (the "no rtos" ones) for MSP432E401Y from ResourceExplorer and made the necessary SPI connections with a SD card reader.

The following output comes up on UART (for fatsd)

"

Starting the fatsd example

This example requires a FAT filesystem on the SD card.

You will get errors if your SD card is not formatted with a filesystem.

Drive 0 is mounted

Creating a new file "fat:0:input.txt"...
Error: "fat:0:input.txt" could not be created.
Please check the Board.html if additional jumpers are necessary.

Aborting...

"

and the following for fatsdraw

"

Starting the FatSD Raw example

This example requires a FAT filesystem on the SD card.

You will get errors if your SD card is not formatted with a filesystem.

Drive 0 is mounted

Reading disk information...
Error getting the free cluster count from the FatFs object

"

I had formatted the SD card with FAT using my PC. 

Please suggest some fix

  • Hi,

    Creating a new file "fat:0:input.txt"...
    Error: "fat:0:input.txt" could not be created.
    Please check the Board.html if additional jumpers are necessary.

    I'm not an expert in this particular example. The error seems to suggest the input.txt can not be created on the target SD card for some reason. Can you do a sanity check and see if the SPI interface has any signals toggling (e.g. SPICLK, MISO, MOSI, CS)? The example was created for use with BOOSTXL-SHARP128 LCD & SD Card BoosterPack. The example was meant to use the boosterpack 1 connector on the LaunchPad.  I will suggest you go through this boosterpack user's guide and make sure you hardware connection is the same between the LaunchPad and the boosterpack for which the example is targeted. Not that you must have the boosterpack, but it will be good if you have one that you can just plug to the LaunchPad and run the example as is. 

    fatsd

    Example Summary

    Example to read and write data onto a SD Card with a FAT file system.

    Peripherals & Pin Assignments

    When this project is built, the SysConfig tool will generate the TI-Driver configurations into the ti_drivers_config.c and ti_drivers_config.h files. Information on pins and resources used is present in both generated files. Additionally, the System Configuration file (*.syscfg) present in the project may be opened with SysConfig’s graphical user interface to determine pins and resources used.

    • CONFIG_GPIO_LED_0 - Indicates that the driver was initialized within mainThread()
    • CONFIG_SDFatFS_0 - Connection to SD card

    BoosterPacks, Board Resources & Jumper Settings

    This example requires a BOOSTXL-SHARP128 LCD & SD Card BoosterPack.

    For board specific jumper settings, resources and BoosterPack modifications, refer to the Board.html file.

    If you’re using an IDE such as Code Composer Studio (CCS) or IAR, please refer to Board.html in your project directory for resources used and board-specific jumper settings.

    The Board.html can also be found in your SDK installation:

        <SDK_INSTALL_DIR>/source/ti/boards/<BOARD>

    Example Usage

    • Example output is generated through use of Display driver APIs. Refer to the Display driver documentation found in the SimpleLink MCU SDK User’s Guide.

    • Open a serial session
      • (e.g. PuTTY, etc.) to the appropriate COM port.
      • The COM port can be determined via Device Manager in Windows or via ls /dev/tty* in Linux.

    The connection will have the following settings:

        Baud-rate:     115200
        Data bits:          8
        Stop bits:          1
        Parity:          None
        Flow Control:    None
    • Run the example. CONFIG_GPIO_LED_0 turns ON to indicate driver initialization is complete.

    • The example proceeds to read the SD card. If the input.txt file is not found, the file is created on the SD card with the following text:

        "***********************************************************************\n"
        "0         1         2         3         4         5         6         7\n"
        "01234567890123456789012345678901234567890123456789012345678901234567890\n"
        "This is some text to be inserted into the inputfile if there isn't     \n"
        "already an existing file located on the SDCard.                        \n"
        "If an inputfile already exists, or if the file was already once        \n"
        "generated, then the inputfile will NOT be modified.                    \n"
        "***********************************************************************\n"
    • The input.txt file is then read and it’s contents are written to a new file called output.txt. If the file already exists on the SD card, it will be overwritten.

    • The contents of the output.txt file are then written to the console.

    Application Design Details

    • The FatFs source is included and pre-built, together with support for SYS/BIOS or FreeRTOS synchronization. Also included is an implementation of the “device I/O” model for the TI compiler C runtime support (RTS) library. This provides transparent support for using the C stdio.h library functions (fopen, fread, fwrite, etc…) instead of the raw, project-specific, API functions provided by FatFs (f_open, f_write).

    • This application demonstrates how to use the SD Card driver to read and write data onto an SD Card using the aforementioned standard CIO runtime system calls.

    • Within the application, the fatfsPrefix parameter is used as the namespace “prefix” for the C RTS fopen() function. See the TI C Compiler User’s Guide (such as spru187) for more details. This prefix must be supplied as part of the filename when calling fopen(). For example, with the default value of “fat”, an application would use:

        FILE * fp = fopen("fat:/signal.dat", "w");

    Additional Features:

    • Users also have the option of writing to a RAM disk using either the CIO runtime system calls or raw FatFS API’s. Refer to the FatFS documentation for more information.

    This application uses one thread:

    The mainThread performs the following actions:

    1. Creates and initializes the SDFatFS driver object.

    2. Open the input.txt file. If not found, create the file for reading and writing. Write the default message to the file.

    3. Open the output.txt file. Content will be overwritten if found.

    4. Copy the contents of input.txt to output.txt. Close both files afterwards.

    5. Open output.txt, read the file and print the contents using the Display driver.

    6. The output.txt file and SDFatFS driver are closed and the example is terminated.

    TI-RTOS:

    • The timespec structure must be initialized with the current UNIX seconds count in order to write files with accurate timestamps. This is due to the fact that the BIOS Seconds module rather than the RTS library time() function is used.

    • When building in Code Composer Studio, the kernel configuration project will be imported along with the example. The kernel configuration project is referenced by the example, so it will be built first. The “release” kernel configuration is the default project used. It has many debug features disabled. These feature include assert checking, logging and runtime stack checks. For a detailed difference between the “release” and “debug” kernel configurations and how to switch between them, please refer to the SimpleLink MCU SDK User’s Guide. The “release” and “debug” kernel configuration projects can be found under <SDK_INSTALL_DIR>/kernel/tirtos/builds/<BOARD>/(release|debug)/(ccs|gcc).

    FreeRTOS:

    • The compiler specific RTS library functions for time() and localtime() are used. It is not necessary to initialize the timespec structure.

    • Please view the FreeRTOSConfig.h header file for example configuration information.

    References

  • There is some output coming from the SD card reader as well (MISO above). So the connections should be mostly be correct.

    I didn't used the BoosterPack for the example. Is it necessary for it? Shouldn't just SPI with the SD card reader work?

    What should I modify to make it work without the BoosterPack?

  • Hi,

      Not an expert in this subject but reading the source code below, it looks like it is unable to open the file for both reading and writing. Can you first use the filesystem to create the input.txt file manually? Will it be able to read the file if the file is already existing? Is the SD card protected? Normally the SD card has a slider on the side that you can toggle up or down for write protection. 

    /* Try to open the source file */
    src = fopen(inputfile, "r");
    if (!src) {
    Display_printf(display, 0, 0, "Creating a new file \"%s\"...",
    inputfile);

    /* Open file for both reading and writing */
    src = fopen(inputfile, "w+");
    if (!src) {
    Display_printf(display, 0, 0,
    "Error: \"%s\" could not be created.\nPlease check the "
    "Board.html if additional jumpers are necessary.\n",
    inputfile);
    Display_printf(display, 0, 0, "Aborting...\n");
    while (1);
    }