README


fatsdraw


Example Summary

Example to read and write data onto an SD Card.

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.

Example Usage

The connection will have the following settings:

    Baud-rate:     115200
    Data bits:          8
    Stop bits:          1
    Parity:          None
    Flow Control:    None

Application Design Details

    #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:

mainThread performs the following actions:

  1. Creates and initializes SDFatFS driver object.

  2. Prints the disk size and the amount of free space on it.

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

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

  5. Copy the contents of input.txt to output.txt. Closes both files afterwards.

  6. Open output.txt, read the file, print the contents to the display and close output.txt.

  7. Again, print the disk size and the amount of free space on it. If the disk was empty, the difference in free space can be observed.

  8. Close the SDFatFS driver and terminate the example.

TI-RTOS:

FreeRTOS:

References