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.

CCS/MSP430F6736: Exporting data to an Excel spreadsheet

Part Number: MSP430F6736


Tool/software: Code Composer Studio

Hi team,

I am using code composer studio and msp430f6736 for a project.

I want to export the data I collect from an external device (for example ADC) to an excel spreadsheet.

Will I be able to do so?

If yes, what steps do I need to follow?

Thank you.

  • Hi Keval,

    First of all you need to transfer the data from the MSP to your PC.
    Depending if you want to transfer them only once or on the fly the methods are different.
    I would recommend to read the UG chapters 36-41 about serial communication.
    If you have still question, please don't hesitate to come back with questions.

    Best regards
    Lukas
  • Hi Lukas,

    Which material do I refer to for the serial communication chapters?

    Is it the slau208q?

    If yes, I've already gone through the USCI_A SPI mode of communication. I couldn't find anything helpful related to this.

    Does TI provide with the example codes for such kind of applications?

    If yes, where can I find them?

    Thank you.

  • Hi Keval,

    Yes, this is the correct document.

    As reference I would recommend to use the code examples from web.

    You might use one of the USCI examples.

    The functionality of the USCI is explained in UG slau208

    Best regards

    Lukas

  • Hi Lukas,

    I am using a MSPFET and MSP430F6736. I am using the internal ADC and SD converter. I want to export the output data to an excel sheet. I want to send the data continuously.

    I went through the USCI data given in the user guide.
    I couldn't find a way to transfer my data from the MCU to an excel sheet.


    Could you help me out with the issue?

    Thank you,
    Keval
  • Some ideas:

    The easiest way to generate a spreadsheet for almost any spreadsheet software, be it Excel, OpenOffice/LibreOffice, Numbers on a Mac, etc., is to generate CSV (Comma Separated Values). Almost all spreadsheet software supports CSV (as do other types of applications, such as relational databases).

    I'm not sure what kind of board you have and what its connectivity options are, but if it has a UART (e.g., UART to USB CDC that appears as a COM port on your PC) and if you can printf() to this UART inside your firmware, then you can generate comma separated values pretty easily. Output a first row that contains column headings. Thereafter output a row for each record of data. You can put quotes around each data value. Each data value is separated by a comma and the last data value in a row has a line feed character instead of a comma.

    For example, first row:

    printf("\"Column Heading 1\",\"Column Heading 2\",\"Column Heading 3\"\n");

    Each subsequent row:

    printf("\"%d\",\"%d\",\"%d\"\n", DataValue1, DataValue2, DataValue3);
    

    You will need to take into consideration (1) the communication speed, which will be a bottleneck to the amount of data you can output, and (2) the overhead of executing printf() in your firmware.

    Alternatives include: If there isn't too much information for your MCU's memory size, accumulate the data in a buffer and then output it over a communication channel once data acquisition has completed; if communication speed is not an issue (e.g., you're using DMA, double-buffering, and high BAUD rates) but printf() execution is adding too much overhead then you can send out raw binary data which a separate program on your PC can interpret and convert to CSV -- if you do that then be mindful of endianness of the data, e.g., 0x12345678 in one type of processor may be interpreted as 0x78563412 by another type of processor.

    Hope this helps.

  • By "send the data continuously" do you mean a live update of the spreadsheet? You will have to write a macro for excel that reads from the serial port.

    So, first get your program to send to a terminal program, than worry about excel.
  • Hi Keith,

    Yes, I want to achieve a live update of the spreadsheet.
    Could you give me a point from where I can start?
    How do I send my program to aterminal program?

    Thanks,
    Keval
  • Start with the UART echo programs and use the terminal in CCS, or Putty.

    I have no idea how to use the VBA functions in Excel for serial communication. I avoid it like the plague.
  • Hi,

    How do I generate CSV file after inserting the printf() commands in my program?

    I will get the output values on the console. How do I export those values and generate a CSV file with those values?



    Could you help me out?

    Thanks,
    Keval

  • /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP430F673x Demo - USCI_A0, Ultra-Low Power UART 9600 Echo ISR, 32kHz ACLK
    //
    //   Description: Echo a received character, RX ISR used. Normal mode is LPM3,
    //   USCI_A0 RX interrupt triggers TX Echo.
    //   ACLK = 32768Hz crystal, MCLK = SMCLK = DCO ~1.045MHz
    //   Baud rate divider with 32768Hz XTAL @9600 = 32768Hz/9600 = 3.41
    //   See User Guide for baud rate divider table
    //
    //
    //                MSP430F673x
    //             -----------------
    //        /|\ |              XIN|-
    //         |  |                 | 32kHz
    //         ---|RST          XOUT|-
    //            |                 |
    //            |     P1.3/UCA0TXD|------------>
    //            |                 | 9600 - 8N1
    //            |     P1.2/UCA0RXD|<------------
    //
    //  M. Swanson
    //  Texas Instruments Inc.
    //  December 2011
    //  Built with CCS Version: 5.1.0 and IAR Embedded Workbench Version: 5.40.1
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;               // Stop WDT
    
        // Setup P1.2 UCA0RXD, P1.3 UCA0TXD
        P1SEL |= BIT2 | BIT3;                   // Set P1.2, P1.3 to non-IO
        P1DIR |= BIT2 | BIT3;                   // Enable UCA0RXD, UCA0TXD
    
        // Setup LFXT1
        UCSCTL6 &= ~(XT1OFF);                   // XT1 On
        UCSCTL6 |= XCAP_3;                      // Internal load cap
        // Loop until XT1 fault flag is cleared
        do
        {
            UCSCTL7 &= ~(XT2OFFG | XT1LFOFFG | DCOFFG);
            // Clear XT2,XT1,DCO fault flags
            SFRIFG1 &= ~OFIFG;                  // Clear fault flags
        } while (SFRIFG1 & OFIFG);              // Test oscillator fault flag
    
        // Setup eUSCI_A0
        UCA0CTLW0 |= UCSWRST;                   // **Put state machine in reset**
        UCA0CTLW0 |= UCSSEL_1;                  // CLK = ACLK
        UCA0BRW_L = 0x03;                       // 32kHz/9600=3.41 (see User's Guide)
        UCA0BRW_H = 0x00;                       //
        UCA0MCTLW = 0x5300;                     // Modulation UCBRSx=0x53, UCBRFx=0
        UCA0CTLW0 &= ~UCSWRST;                  // **Initialize USCI state machine**
        UCA0IE |= UCRXIE;                       // Enable USCI_A0 RX interrupt
    
        __bis_SR_register(LPM3_bits | GIE);     // Enter LPM3, interrupts enabled
        __no_operation();                       // For debugger
    }
    
    // USCI_A0 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
        switch (__even_in_range(UCA0IV, 4))
        {
            case USCI_NONE: break;              // No interrupt
            case USCI_UART_UCRXIFG:             // RXIFG
                while (!(UCA0IFG & UCTXIFG)) ;  // USCI_A0 TX buffer ready?
                UCA0TXBUF = UCA0RXBUF;          // TX -> RXed character
                break;
            case USCI_UART_UCTXIFG: break;      // TXIFG
            case USCI_UART_UCSTTIFG: break;     // TTIFG
            case USCI_UART_UCTXCPTIFG: break;   // TXCPTIFG
            default: break;
        }
    }
    
    

    Hi Keith,

    How do I send the values that I need to print using UART echo programs?

    I found this example code on CCS Resource Explorer. 

    In this example it is echoing a received character. I want to send data to the computer.

    How do I achieve this?

    Could you help me out?

    Thanks,

    Keval

  • Correct, getting the MSP to send the serial data to the computer and receiving it correctly is half the battle. At this point simply google "receive serial data in excel" and you are on your own.
  • Thank you so much for the help Keith.
    Appreciate it.

**Attention** This is a public forum