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.

Compiler/MSP430F5529: How to input 64-bit string data from user ?

Part Number: MSP430F5529
Other Parts Discussed in Thread: MSP-IQMATHLIB

Tool/software: TI C/C++ Compiler

Hello,

I am working with MSP430F5529 launchpad and want to input frequencies for a PLL algorithm in string format. As the frequencies are all in Mhz range and I have to work in Hz, I need to work with 64-bit data. The idea of inputting the frequency in string format is that I can extract the fraction part and make it into integer (for e.g. 123.456789 Mhz to 123456789 Hz). I am trying to code my algorithm in CCS 7.2.0 and here it does not recognize "string datatype". Also since F5529 is a 16-bit processor is there a way of doing 64-bit arithmetic in it?

Please help!!

  • Same way you do 4 digit arithmetic when you only can do 1 digit in your head. You write stuff down. The compiler probably supports a 64 bit type (long long)

    As for the other, you are not telling us how you are inputting your characters, but check out the functions in string.h.

    At the worst, load in all your characters and just create the number yourself.


    This actually belongs in the MSP430 forum.
  • Hello Soumit,

    The MSP430F5529 features a 32-bit x 32-bit hardware multiplier module (MPY32) and the CCS compiler does support 64-bit (long long, signed or unsigned) data types. This is shown in Table 5-1 in the MSP430 Optimizing C/C++ Compiler v17.9.0.STS User's Guide.

    For your application, you may be interested in the Fixed Point Math Library (MSP-IQMATHLIB).


    Regards,

    James

    MSP Customer Applications

  • Hello,

    Thanks for your immediate response. I would try the fixed point math library for my application. It is quite helpful. One query still is the use of strings. While writing the C- code in Visual Studio i used string data type to input frequencies from the user. But in MSP430 while implementing it I found that string datatype is not supported nor "strtod" function. I have posted the code I wrote. Please can you help in how should I implement in MSP430.

     /* User has to give the i/o values */
     cout << "Please provide (in MHz) input Ref frequency : ";
      string inputVal;
      cin >> inputVal;
    
      char *inStr1 = new char[inputVal.length() + 1];
      strcpy_s(inStr1, inputVal.length() + 1, inputVal.c_str());
      char *endptr1;
      char* loc1 = strchr(inStr1, '.');
      int count1 = 0;
      if (loc1 != NULL)
      {
        long int mantissa1 = strtod(loc1 + 1, &endptr1);                       //seperates the mantissa part from the decimal number eg: 23.456 : mantissa 456
        long int whole1 = strtod(inStr1, &endptr1);                            //seperates the whole part from the decimal number eg: 23.456 : whole 23
        long int var1 = mantissa1;
    }
    

  • strtod() is included, you need to include stdlib.h. But that is not what you want. You want strtoul() which converts the string to a long unsigned long, which is 32 bits. You will probably have to roll your own for a 64 bit long long. I suggest yuo chck out K&R which has an atoi() implementation you can modify to long long.

**Attention** This is a public forum