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.
Hello everyone
I need help understanding the sendDataSDCard() function method from the out-of-box example code for the MSP430FR5994 launchpad. The code is located in the SDCardLogMode translation unit and is copied below. This function reads a log file from the SD Card and sends it to a PC GUI app. My big two questions are
My detailed walk through and understanding (immediately below) may help locate were I am confused (confusion is underneath in red).
“ SDCard Logging Start Time: “ + Timestamp “temperature and Voltage (12-bit ADC raw data):”
2 Close the file
3 Condition GPIO pins for UART operation.
4 Send the numDat count to the PC GUI App.
5 Open the file again and toss the next 5 buffers (strings)
6 Then for each string in numDat: Break into substrings using the “ “ delimiter. First substring holds both the timestamp and Temp reading. Second string holds only the battery voltage.
thank you for your help
jim
void sendDataSDCard() { //Plugin SDcard interface to SDCard lib SDCardLib_init(&sdCardLib, &sdIntf_MSP430FR5994LP); //Detect SD card SDCardLib_Status st = SDCardLib_detectCard(&sdCardLib); if (st == SDCARDLIB_STATUS_NOT_PRESENT) { SDCardLib_unInit(&sdCardLib); mode = '0'; noSDCard = 1; return; } // Construct log file's name if (numLogFiles == 0) numLogFiles++; strcpy(filename, "data_log/log_"); char num[5]; itoa(numLogFiles, num, 10); strcat(filename, num); strcat(filename, ".txt"); uint16_t numData = 0; rc = f_open(&fil, filename, FA_READ | FA_OPEN_EXISTING); if (rc) { numData = 0; } else { f_gets(buffer, MAX_BUF_SIZE, &fil); f_gets(buffer, MAX_BUF_SIZE, &fil); f_gets(buffer, MAX_BUF_SIZE, &fil); f_gets(buffer, MAX_BUF_SIZE, &fil); f_gets(buffer, MAX_BUF_SIZE, &fil); while (f_gets(buffer, MAX_BUF_SIZE, &fil) != NULL) { numData++; } } rc = f_close(&fil); // Select UART TXD on P2.0 GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN0, GPIO_SECONDARY_MODULE_FUNCTION); // Send FRAM Index EUSCI_A_UART_transmitData(EUSCI_A0_BASE, (uint8_t)((numData)>>8)); EUSCI_A_UART_transmitData(EUSCI_A0_BASE, (uint8_t)(numData)); __delay_cycles(900000); rc = f_open(&fil, filename, FA_READ | FA_OPEN_EXISTING); if (rc) { f_close(&fil); SDCardLib_unInit(&sdCardLib); return; } f_gets(buffer, MAX_BUF_SIZE, &fil); f_gets(buffer, MAX_BUF_SIZE, &fil); f_gets(buffer, MAX_BUF_SIZE, &fil); f_gets(buffer, MAX_BUF_SIZE, &fil); f_gets(buffer, MAX_BUF_SIZE, &fil); uint16_t i; char *dataStr; int data; for (i=0;i<numData;i++) { // Reads TimeStamp from SDCard log file f_gets(buffer, MAX_BUF_SIZE, &fil); dataStr = strtok(buffer, " "); data = atoi(dataStr); // Send logged Temperature Sensor ata EUSCI_A_UART_transmitData(EUSCI_A0_BASE, (uint8_t)(data>>8)); EUSCI_A_UART_transmitData(EUSCI_A0_BASE, (uint8_t)(data)); dataStr = strtok(NULL, " "); data = atoi(dataStr); // Send logged Battery Monitor data EUSCI_A_UART_transmitData(EUSCI_A0_BASE, (uint8_t)(data>>8)); EUSCI_A_UART_transmitData(EUSCI_A0_BASE, (uint8_t)(data)); } rc = f_close(&fil); SDCardLib_unInit(&sdCardLib); GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN0); mode = '0'; }
**Attention** This is a public forum