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.

Needed help for using function of String in IAR.

Other Parts Discussed in Thread: MSP430FG4618

Hi All.

I'm need to send string via RS-232 connected to MSP 430 FG4618.

Because i used printf  function to send string but not success, I rewrite  writestring  function to send follow as :

 

void writestring(char * str)

{

    int i = 0;

    for(i = 0; i < strlen(str); i++)

    {

        while (!(IFG2 & UCA0TXIFG)); 

        UCA0TXBUF = str[i];

    }

}

But i didn't get the string not like original. (error some character).

 

and i want to know how to use function of string in IAR complier .exp:

1)  printf ( " Hello Wolrd ") ; // this function can send string Hello Wolrd to RS-232 port.

2) putc (x) ;

i added string.h, stdio.h in my code .

Please help me to solve this problems.

thanks a lot.

  • Don't re-invent the wheel!

    Use the uartstdio functions included in Stellarisware!

    http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/474/t/113624.aspx

     

  • This is also the wrong forum for the MSP processors.  This forum is for the Stellaris family of processors.  Stellarisware won't help you much on the MSP430.

     

     

  • When he said he's sending to  an MSP430,  I assumed he meant  from  a Stellaris.

    Do TI have an equivalent of Stellarisware for the MSP430 - "MSPware", perhaps?

    slandrum said:
    Stellarisware won't help you much on the MSP430.

    Actually, a lot of the uartstdio code could be portted direct to any processor - it's just standard 'C' - only the parts that deal directly with the UART hardware would need changing....

  • Nguyen Tien Chuan said:

    I'm need to send string via RS-232 connected to MSP 430 FG4618.

    Will you please clarify if you are asking a question about using Stellaris, or using MSP430?

     

  • Thanks all for my answer

    A careless in my question !!! The purpose of this problem is send string via RS-232 com port  (to display on HyperTerminal ) from MSP430FG4618 to my PC.

    I want to use the functions such as : printf () , putc(); strcp() to work with string ,exp :  i want to send string "MSP430" to RS232 Com port, i do :

    Printf ("MSP430"); // the string MSP430 will display on HyperTerminal window.   

     but I don't know the IAR complier  support or not  ? If not, I must code it ?

    Please help me to solve this problem.

    Have Fun and Health.


  • Nguyen Tien Chuan said:

    A careless in my question !!! The purpose of this problem is send string via RS-232 com port  (to display on HyperTerminal ) from MSP430FG4618 to my PC.

    I want to use the functions such as : printf () , putc(); strcp() , but I don't know the IAR complier  support or not  ? If not, I must code it ?

    Please help me to solve this problem.

    Have Fun and Health.

    Thank you for explaining that you are using an MSP430.  I will move your question to the MSP430 forum where someone who is knowledgeable about MSP430 tools can answer your question.

  • Welcome to the MSP430 forum :)

    IAR offers a fake comm port with its support of printf. Here the debugger sets a breakpoint into the (empty) send function and fetches the data that was intended to be sent, for display on its internal console window.

    On mspgcc, I have to provide a function putchar() that takes the individual output bytes from printf (or others) and does, well, what it wants. In your case stuffing them into UCA0TXBUF. I'm not sure how IAR handles this, but maybe defining your own putchar function will override the dummy function I mentioned, and printf will work with a real serial connection.

    However, what you did looks quite good and should work (I didn't check whether UCA0TXBUF is really on IFG2 and not on IFG1)
    Personally, I wouldn't use strlen(), as it scans the string each time. And is a function call.
    for (i=0; !str[i];i++)  does the same and is much faster.

    In addition to providing an output function, you need to enable printf support of the desired level (plain strings, ints, floats) in the IAR project settings. It directly affects the ampount of library code needed to be included in your project (with full support, you easily hit the code limit for the free IAR version).

**Attention** This is a public forum