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.

MSP432P401R: Unable to read .wav files from SD card

Part Number: MSP432P401R


Hello,

I'm using the MSP432P401R and the SDK to do some SD card work, and I've been using the example FAT32 SD card example on the resource explorer for reference. I've gotten to the point where I can read files from the card, but it's inconsistent with files I want to read. I can read .txt files just fine, however it can't seem to read .wav files even though they're present on the card. I'll be using .wav files in my application so I would like to get those to work, but a general method for any files would be appreciated too!

Here's my code so far:

	WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD;		// stop watchdog timer

    SDFatFS_Handle sdfatfsHandle;

    FILE *src;

	Board_init();

    GPIO_init();
	SDFatFS_init();

    add_device(fatfsPrefix, _MSA, ffcio_open, ffcio_close, ffcio_read,
        ffcio_write, ffcio_lseek, ffcio_unlink, ffcio_rename);

    sdfatfsHandle = SDFatFS_open(CONFIG_SDFatFS_0, DRIVE_NUM);
    if (sdfatfsHandle == NULL) {
        //Display_printf(display, 0, 0, "Error starting the SD card\n");
        while (1);
    }

    src = fopen("fat:0:Test.wav", "rb");
    if (!src) {
        while (1);
    }
    else {
        while(1);
    }

I'm wondering if it's the way I'm initializing my SD card. Thank you for your help!

Best,

Colin

  • Dear customer,

    Thank you for your inquiry related to the MSP432 product. We recommend that you consult the many resources at  dev.ti.com, including SDK user’s guides, libraries, utilities, software examples and SimpleLink  Academy training modules.  

    Thank you for your time and consideration.

    PM

  • Hello,

    After doing a bit more work and research, I was able to read in wav files. I did notice however that there seemed to be a size limit on the name of the file, otherwise fread wouldn't be able to read it. The limit is 8 characters. An example of my code is shown below, both files exist on my SD card.

        src = fopen("fat:0:SSwavabc.wav", "r"); //8 character name, perfectly fine
        src = fopen("fat:0:SSwavabcb.wav", "r");//9 character name, can't open and returns NULL

    Any idea on why there would be a name limit and what I could do to fix it?

    Best,

    Colin Adema

  • ChaN's FATFS implementation had a symbol FF_USE_LFN to enable long filenames. It made the code (and RAM) grow by quite a bit. If you can stick with 8.3 names it's probably to your advantage.

**Attention** This is a public forum