README


fatsd


Example Summary

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

Peripherals Exercised

Resources & Jumper Settings

If you’re using an IDE (such as CCS or IAR), please refer to Board.html in your project directory for resources used and board-specific jumper settings. Otherwise, you can find Board.html in the directory <SDK_INSTALL_DIR>/source/ti/boards/<BOARD>.

This example requires an external SD Card boosterpack. This example is only available for the TI toolchain.

Example Usage

The connection will have the following settings:

    Baud-rate:     115200
    Data bits:          8
    Stop bits:          1
    Parity:          None
    Flow Control:    None
    "***********************************************************************\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"

Application Design Details

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

Additional Features:

    #include <third_party/fatfs/ff.h>
    #include <third_party/fatfs/ffcio.h>
    #include <third_party/fatfs/diskio.h>

    unsigned int ramdiskData[RAMDISKSIZE];
    DRESULT result;

    result = ramdisk_start(ramdiskDriveId, ramdiskData, RAMDISKSIZE, 0);

    if (result != RES_OK) {
        /* ramdisk_start failed */
        while (1);
    }

If using both the RAM disk and SD card filesystems, separate drive ID’s must be used.

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:

FreeRTOS:

References