Part Number: MSP432P401R
Tool/software: TI-RTOS
Hello,
I have been using the SDFatFS driver shipped with the last version of SimpleLink SDK for MSP432P401R (simplelink_msp432p4_sdk_2_30_00_14). I have imported the example "fatsd_MSP_EXP432P401R_freertos_ccs" from TI Resource Explorer and modified it to write a large array buffer (16 kbytes), filled with a dummy pattern data (0xAA), to SD Card. I realized that the write speed performance is poor, and then, I have attached a Logic Probe to SPI lines and I discovered even writing a multiple integer of a data block size (512 bytes) the Driver provided by TI is issuing multiples CMD24 (SINGLE DATA BLOCK WRITE) instead of a single CMD25 (MULTIPLE DATA BLOCK WRITE). I looked at the source code provided by TI and I realized that multiple data block (CMD25) is implemented in the TI current driver, but not working for some reason. Is it a possible bug?
The writing of sixteen data blocks is depicted bellow
Zooming around the time that precedes the writing of one of data blocks, the CMD24 can be seen.
I attached the CCS project working out of the box, in order to reproduce the problem, but my code is shown bellow
#include <file.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
/* POSIX Header files */
#include <pthread.h>
#include <third_party/fatfs/ffcio.h>
#include <ti/display/Display.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SDFatFS.h>
/* Example/Board Header files */
#include "Board.h"
/* Buffer size used for the file copy process */
#ifndef CPY_BUFF_SIZE
#define BUFF_SIZE 512*16
#endif
/* String conversion macro */
#define STR_(n) #n
#define STR(n) STR_(n)
/* Drive number used for FatFs */
#define SD_DRIVE_NUM 0
const char outputfile[] = "fat:"STR(SD_DRIVE_NUM)":data.dat";
static Display_Handle display;
/* Set this to the current UNIX time in seconds */
const struct timespec ts = {
.tv_sec = 1469647026,
.tv_nsec = 0
};
/* File name prefix for this filesystem for use with TI C RTS */
char fatfsPrefix[] = "fat";
unsigned char buff[BUFF_SIZE] __attribute__ ((aligned (4)));
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
SDFatFS_Handle sdfatfsHandle;
/* Variables for the CIO functions */
FILE *dst;
/* Variables to keep track of the file copy progress */
unsigned int bytesWritten = 0;
/* Call driver init functions */
GPIO_init();
Display_init();
SDFatFS_init();
/* Configure the LED pin */
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
/* add_device() should be called once and is used for all media types */
add_device(fatfsPrefix, _MSA, ffcio_open, ffcio_close, ffcio_read,
ffcio_write, ffcio_lseek, ffcio_unlink, ffcio_rename);
/* Open the display for output */
display = Display_open(Display_Type_UART, NULL);
if (display == NULL) {
/* Failed to open display driver */
while (1);
}
/* Initialize real-time clock */
clock_settime(CLOCK_REALTIME, &ts);
Display_printf(display, 0, 0, "Starting the fats application\n");
/* Mount and register the SD Card */
sdfatfsHandle = SDFatFS_open(Board_SDFatFS0, SD_DRIVE_NUM);
if (sdfatfsHandle == NULL) {
Display_printf(display, 0, 0, "Error starting the SD card\n");
while (1);
}
else {
Display_printf(display, 0, 0, "Drive %u is mounted\n", SD_DRIVE_NUM);
}
memset((void*) buff, (int) (0xAA), (size_t) BUFF_SIZE);
/* Create a new file object for the file copy */
dst = fopen(outputfile, "w");
if (!dst) {
Display_printf(display, 0, 0, "Error opening \"%s\"\n", outputfile);
Display_printf(display, 0, 0, "Aborting...\n");
while (1);
}
else {
Display_printf(display, 0, 0, "Starting file write\n");
}
/* Write buff to dst file */
bytesWritten = fwrite(buff, 1, BUFF_SIZE, dst);
if (bytesWritten < BUFF_SIZE) {
Display_printf(display, 0, 0, "Disk Full\n");
}
/* Close outputfile[] */
fclose(dst);
/* Stopping the SDCard */
SDFatFS_close(sdfatfsHandle);
Display_printf(display, 0, 0, "Drive %u unmounted\n", SD_DRIVE_NUM);
return (NULL);
}

