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.

How to store data from MSP EXP430G2 into Database??????

According to the "Hello-world" example. The code use "UARTprintf" to send data to PC. BUT why there's only a USB emulator connection on the board rather than a serial connection? I am a total novice so I am confused. 

Moreover, if I want to store the data, for example, the "helloworld" string into a database. What should I do in the PC program? Is there any API of the board that I can make use of?  And which program language is the best to choose? VB or C#?

Thank you.

  • I'm not sure what board you have, but for example the MSP-EXP430F5438 experimenter's kit has similar setup. The USB connection is provided by a TUSB 3410 chip, which is essentially a serial-to-usb bridge. So the MSP430 talks serial/uart (TXD/RXD) to the uart side of the TUSB 3410, and the TUSB 3410 talks usb to the PC.


    On the PC side, I like to use Qt for my applications and write them in C++. Qt has a nice, easy database API and you can use it with SQLite, a simple file-based database system.

    --Randy

  • With C# you can create a uart port and speak to the msp430.
    C# can then manipulate the data, display or save it in some data base format.

    Here is a part of a C# program that opens a local firmware file and sends it to the msp430
    But it's easy to send more data the other way too.

    using (StreamReader sr = new StreamReader("firmware.txt")) // same folder
                    {
                        String line = sr.ReadToEnd().Replace(" ","").Replace("\r\n","");
                   
                        byte[] mydata = new byte[5120];                         // msp430 flash size 0xec00 0xffff                                               
                        SerialPort port = new SerialPort("COM11", 9600, Parity.None, 8, StopBits.One);
                        port.Open();
                        port.Write(new byte[] {0x5D}, 0, 1);                  // 0x5d init command

  • Tony Philipsson said:

    With C# you can create a uart port and speak to the msp430.
    C# can then manipulate the data, display or save it in some data base format.

    Here is a part of a C# program that opens a local firmware file and sends it to the msp430
    But it's easy to send more data the other way too.

    using (StreamReader sr = new StreamReader("firmware.txt")) // same folder
                    {
                        String line = sr.ReadToEnd().Replace(" ","").Replace("\r\n","");
                   
                        byte[] mydata = new byte[5120];                         // msp430 flash size 0xec00 0xffff                                               
                        SerialPort port = new SerialPort("COM11", 9600, Parity.None, 8, StopBits.One);
                        port.Open();
                        port.Write(new byte[] {0x5D}, 0, 1);                  // 0x5d init command

    Thank you for instruction. But there are still a few questions.

    1. What  "0x5d" stands for? Can I find this in some documents?

    2. If I want to send mydata to the msp430, can I just simply change into "port.Write(mydata,0,1)"?

    3.How can I know the msp430 gets the data I sent correctly?

    Thanks Tony

  • Randy Yates said:

    I'm not sure what board you have, but for example the MSP-EXP430F5438 experimenter's kit has similar setup. The USB connection is provided by a TUSB 3410 chip, which is essentially a serial-to-usb bridge. So the MSP430 talks serial/uart (TXD/RXD) to the uart side of the TUSB 3410, and the TUSB 3410 talks usb to the PC.


    On the PC side, I like to use Qt for my applications and write them in C++. Qt has a nice, easy database API and you can use it with SQLite, a simple file-based database system.

    --Randy

    Thank Randy. I am using MSP EXP430G2. But----

    Through which funciton or api can I get the data transferred from msp430?

    And does it mean that I can just simply regard the usb port as a COM port and get the data from COM on windows

  • The 0x5d is just a password-byte I send to the msp430 so it knows that it's not random pulses on rx-pin
    that is causing it start a new firmware update.
    for error checking, you can use checksum system you add up all the bytes and send the 16bit value at the end.


    You would use port.Read to for incoming data.


    As com port number will not be the same from computer top computer.
    (it does tend to stay static on same computer), but hard-coding the com number is
    not recommend so you should do a search for available comports later on in code development.

    http://stackoverflow.com/search?q=com+port

    if you want a simple C# develop tool:
    http://quicksharp.sourceforge.net/

  • Tony Philipsson said:

    The 0x5d is just a password-byte I send to the msp430 so it knows that it's not random pulses on rx-pin
    that is causing it start a new firmware update.
    for error checking, you can use checksum system you add up all the bytes and send the 16bit value at the end.


    You would use port.Read to for incoming data.


    As com port number will not be the same from computer top computer.
    (it does tend to stay static on same computer), but hard-coding the com number is
    not recommend so you should do a search for available comports later on in code development.

    http://stackoverflow.com/search?q=com+port

    if you want a simple C# develop tool:
    http://quicksharp.sourceforge.net/

    Thank you Tony. It makes it much more clear.

  • If you use Qt, then you can use the QSerialPort class, http://qt-project.org/doc/qt-5/qserialport.html


    Yes, you could use the usb port as a COM port and use, e.g., Hyperterminal.

    --Randy

**Attention** This is a public forum