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.

MSP430F5515 + MSP-FETU430IF + Code Composer Studio 4.1.2 + printf = !?!@#

Hi all-

I'm just trying to write a "hello world" program that uses printf to output to the UART. Can someone possibly give me some hand-holding instructions to get this working? The tools and versions i'm using are in the subject of the post... I feel like this should be much easier than it feels to me.

Regards,
Victor

  • There are code examples on the web which can be accessed at the following link: ti.com/msp430codeexamples

    Please scroll down to the device family you are using and download the sample code (ZIP file).

  • Hello every one

        I am very new to MSP430 and this forum too.

       I need MSP430FET Emulator downloader simple schematic and some suggestion on doing the same please guide me in this.

    Thanks in advance.

    K.Hariharan

  • The schematic is available somewhere on the TI website. Yet it won't help you, as the core of the FET is - an MSP. And without its firmware it won't work.

    I guess TI dows not want you to produce your own FETs by copying their layout. ;)

    But if you want to do your own FET, it isn't that difficult. The JTAG procedure is well-documented. All you need is something that toggles the JTAG pins properly. In theory, you could do with the signal pins of a parallel port, not needing any hardware at all except for a few wires. It wouldn't be fast anyway. 
    But after being able to do the basic JTAG commands, you'll need to write soem high-level code that places the binary data into the MSP flash.

    The mspgcc-jtag program, for example, places the data in chunks into the MSP ram together with a small code snippet that does the actual flashing. This program, however, uses the low-level functions of an existing FET through a TI provided library.

    In the very most cases, it is simpler and faster to just buy a FET.

  • Yep, I've looked at those examples, the relevant ones being "MSP430F552x_uscia0_uart_01.c" through "MSP430F552x_uscia0_uart_04.c". Note however, that none of these examples uses <stdio.h> or printf. Don't get me wrong, if you want to echo received characters, these are terrific examples. They are even pretty good examples if you want to output one character at a time... any help on how to get printf output to the UART in CCSv4.1.2 though is what I'm really looking for. I really don't understand what I've read on the interwebs about CIO and so forth. When I ran the simplest program I could imagine (before even trying to get it to work with the UART) , I got error messages on the console: Corrupt CIO message: buffer length (3328) > buffer size (1057). All I'm doing is printf("Hello World")...

  • @ Hariharan,

    You can also check out this weblink: http://goodfet.sourceforge.net/ - a good place to get started.

    Regards,

    Priya

  • As an mspgcc user, I'm used to a different way of implementing stdio.

    The mspgcc libraries have the full set of stdio function implemented except of two: putchar and getchar. These you must provide yourself. So if you call printf, the produced chars will be forwarded to your putchar function and it is up to you to do something with them. Put them to an UART, through USB, RF or display them on an LCD. Whatever.

    In you special case, the output of printf seems to be redirected to the USB connection directly. Yet the connection isn't set up for transparent passing of the output data.
    Possibly the output of printf needs to be preceded by a packet length iunfor or some flags or whatever, or the USB transfer will fail.
    I conclude this from the error you get 'corrupt CIO message'. This indicates that a special message format is required in the transfer. Something like 'length + type + content (your text) + checksum'

  • I feel like this thread got a little off-topic... anyone want to take a crack at answering my original question on some instructions for using stdio/printf to output to the uart in CCSv4? I'm looking for instructions that are simple and clear, like these from the AVR-GCC libary reference...

  • I 've been trying to find something like that as well. The closest I have come is the code examples referred to above.

    I can't imagine TI being without such clear and concise reference material, but so far the search is fruitless.

  • There is no 'built-in' support for UART output of stdio.
    That because there are e.g. 4 UARTs in an 54xx device. Which one to use? Or shall the output go to an LCD attached through SPI? Or to the USB/RF chip? Since space is limited on MSPs, the library cannot provide a 'usiversal stdio output handling'.

    I can only tell for the mspgcc, where all STDIO output (including printf etc.) ends up at the putchar function. Which the user has to provide and which shall output the single characters to whatever output is desired.

    It is possible that a similar way exists for the CCS, yet that the CLIB contains a 'dummy' version of the putchar function, which is linked.-in if the user does not provide one on his own. If so, this function is likely declared weak, so the users version takes precedence.

    To check this, write your own version which just toggles an LED or so to check whether it is called. If so, all you have to do is writing your own UART send function. E.g. based on the UART demo code you mentioned earlier.

    int putchar(int c){
      do_something_with_the_char(c);
      return 0;
    }

    It's worth a try.

  • Sadly, no dice with including stdio and then defining putchar in my own way in main.c...

    Severity and Description Path Resource Location Creation Time Id
    symbol "putchar" redefined: first defined in "./main.obj"; redefined in "C:\Program Files\Texas Instruments\ccsv4\tools\compiler\MSP430 Code Generation Tools 3.2.3\lib\rts430x.lib<fputc.obj>"  PrintHelloWorld_5515 line 0 1279032787908 330

     

  • That's bad.
    I don't know what is done in fputc.obj, so I cannot tell how to push the library functions into the right direction.

    Another try... In a different implementation, I've seen printf with an additional parameter that defines the output function:
    printf(putchar,"format",...);
    This is similar to the fprintf() function (where you give a file handle of an open file). Is there an fprintf()?

    Or maybe there is a function where you can assign your own putchar function pointer so it is used by printf instead of the default one. Similar to reopen, where you can redirect stdout to a different stream.
    Perhaps there is a global stdout function pointer that points to the putchar function to be used (and defaults to the libraries putchar).

  • This really should not be a such as challenge...

  • Victor said:
    This really should not be a such as challenge...

    Indeed. At least it should be better documented.
    I guess the reason for this is the attempt to make things easier for beginners - provide an emulation of the usual stdio that will lead to an output inside the debug session, so beginners have an immediate success - but when they don't want to play with the debugger anymore, things get more complicated.

    In the linux world, where mspgcc comes from, people are used to a high entry level but easy configurability. So the whole stdio part is written in aways that nothing is automatic but everything possible under user control.
    Unfortunately this does not mean that it is better documented :)

  • It boggles my mind that I haven't gotten a clear and simple answer to this question yet. Don't TI engineers supposedly read this forum? CCS is TI's own IDE for crying out loud. If anyone is out there reading this, please help me out - there is no way that I'm the first person to have this problem/frustration...

  • You must see it the other way:

    On an MSP there is no such thing as STDOUT or a console. (often, the only 'output' is a simple LED) So the implementation of a console and something that is related to stdout is a bonus. And maybe added just for the sole purpose of debugging.

    Yet there should be sprintf(). Use it and do with the resulting string whatever you want.
    It's used like printf except that the resulting text is written into a buffer which you have to provide.

    unsigned int sprintf ( unsigned char * buffer, const unsigned char * format, ...);

**Attention** This is a public forum