• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Development Tools » Code Composer Studio » Code Composer Forum » How to output "Hello World" using CCSv5 and MSP430
Share
Code Composer Studio
  • Forum
  • Announcements
Options
  • Subscribe via RSS
Common Questions
  • Code Composer Studio Forum Usage Guidelines

  • Resources
  • Code Composer Studio (CCStudio) Product Folder
  • Troubleshooting CCS
  • CCS Wiki
  • Download CCS
  • Order CCS
  • Tools Insider Blog
  • Bug Tracking
  • How to output "Hello World" using CCSv5 and MSP430

    How to output "Hello World" using CCSv5 and MSP430

    This question is answered
    Derek9531
    Posted by Derek9531
    on Mar 29 2012 12:22 PM
    Genius5510 points

    Hello,

       I asked this in the MSP430 forum a week ago but didn't get a response.

       I've done a ton of programming for the MSP430 using IAR but wanted to try out CCS. I have the full version of CCS for MSP430 and want to run a simple "Hello World" application using printf(). I don't care about code space; I'm using a big MSP430F5529. How do I do this? I looked around but didn't see anything. In IAR you just need to supply a putchar function in your code somewhere; IAR will find it and use it in stdio.h. So I did, with a simple little putchar that sends bytes out the UART and works fine in IAR.

    /** Send one byte via hardware UART. Called by printf() etc. in stdio.h */
    int putchar(int c)
    {    
        while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
        UCA0TXBUF = c;                  // TX character
        return c;
    }

    When I attempted to compile this same code in CCS, I got a linker error:

    <Linking>
    error #10056: symbol "putchar" redefined: first defined in "./hal_mcb.obj";
       redefined in "C:\ti\ccsv5\tools\compiler\msp430\lib\rts430x.lib<fputc.obj>"

    So how do I do this in CCSv5? It only takes 30 seconds to do this in IAR; I assume it's that easy in CCS but I just haven't seen it yet. Of course the implementation of putchar is project dependent; for this project I do it one way but if I'm using a different UART then I'll want it implemented a different way.

    Is there a simple little app note that I missed somewhere? I've seen this question asked before on the forums without much in the way of a good answer; it might be worth writing a little wiki page for it.

    Thanks,

    Derek

    fixituntilitsbroken.blogspot.com

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Lisa TI
      Posted by Lisa TI
      on Mar 29 2012 12:32 PM
      Guru100045 points

      Hi Derek,

      from a quick look at the message it almost looks like in CCS putchar is reserved and it is defined in a compiler library.  Hence CCS doesn't like the "Redefinition".  What if you call the function myputchar?  Or pushchar?

      Cheers,
      Lisa

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Derek9531
      Posted by Derek9531
      on Mar 29 2012 12:38 PM
      Genius5510 points

      Hello,

         I can redefine putchar to be something else, but I want to use printf etc. in <stdio.h>. How do I tell stdio.h where standard output should be directed? In my case it will be output to the UART. How do I do that?

      Thanks,

      Derek

      fixituntilitsbroken.blogspot.com

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Lisa TI
      Posted by Lisa TI
      on Mar 29 2012 13:43 PM
      Verified Answer
      Verified by Lisa TI
      Guru100045 points

      Hi Derek,

      unfortunately CCS sends such printf items via the JTAG interface itself only.  So this JTAG message can be capture in a console, but not by a device UART.

      Unfortunately it is just not part of CCS.  You would have to do some work to implement a few things yourself and I hope this wiki topic will help explain further. 

      http://processors.wiki.ti.com/index.php/Tips_for_using_printf#Using_printf.28.29_to_output_to_a_user-defined_device

      Does this answer the question for you?

      Best Regards,

      Lisa

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Derek9531
      Posted by Derek9531
      on Mar 30 2012 23:13 PM
      Genius5510 points

      Hello,

         I assume that you have an example of how to do this with an MSP430? It shouldn't be this complicated - it's hello world for pete's sake! It takes 30 seconds to do in IAR; if something this trivial takes this much work in CCS then it makes me wonder how hard CCS is going to be to use. No wonder your low power RF group uses IAR instead of CCS for its MSP430 development!

      I realize this sounds harsh, but look at it from a user's perspective: your compiler for your processor (430 or Stellaris) should be the easiest compiler to use. Instead you're telling me that it's one of the most difficult.

      --Derek

      fixituntilitsbroken.blogspot.com

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Lisa TI
      Posted by Lisa TI
      on Apr 02 2012 07:50 AM
      Guru100045 points

      Hi Derek,

      There are of course examples for MSP to MSP UART communication and there is a hello world example easy to find in CCS which output to the CCS console.  But as I mentioned, this type of output is only handled in JTAG messages in CCS and therefore you need to follow the wiki I sent to try and work around this.

      I can understand the frustration but most use scenarios are using the devices UART for which each device group does provide many examples.  You will see this for the MSP as well.  It is simply this other type of output CCS does not support.

      Best Regards,

      LIsa

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Kent Chen85393
      Posted by Kent Chen85393
      on Jun 13 2012 15:06 PM
      Prodigy545 points

      Hi CCS champions

      I’m doing a CCSv5 project and in one source file "hal_usb.c", there is a redifined standard library function "putchar" as shown below

      /* in hal_usb.c */

      // provide putchar used by printf

      int putchar(int c){

          halUsbSendChar(c);

          return 1;

      }

      When I attempted to compile the project but I got a link error:

      error #10056: symbol "putchar" redefined: first defined in

         Recommend initializing all unused ports to eliminate wasted current

         "./firmware/hal_usb.obj"; redefined in

         consumption on unused pins.

         "C:\ti\ccsv5\tools\compiler\msp430_4.1.0\lib\rts430x_lc_sd_eabi.lib<fputc.ob

         j>" 

      I’ve checked the --std_lib_func_redefined flag to the build option for the hal_usb.c file as below:

        

      But the result is the same:

      error #10056: symbol "putchar" redefined: first defined in

         Recommend initializing all unused ports to eliminate wasted current

         "./firmware/hal_usb.obj"; redefined in

         consumption on unused pins.

         "C:\ti\ccsv5\tools\compiler\msp430_4.1.0\lib\rts430x_lc_sd_eabi.lib<fputc.ob

         j>"

      Also I follow an E2E post and tried to resolve the error:

      http://e2e.ti.com/support/development_tools/compiler/f/343/t/121838.aspx

      In the step 4, it indicates that: The CCE v3 version will return "symbol redefined" errors when custom runtime source files are added to the project. To get around these errors, do the following: Project Properties->C/C++ Build->MSP430 Linker: Change the Command line pattern to be: ${command} ${inputs} ${flags} ${output_flag}${output} Placing ${inputs} before ${flags} puts the object files before the runtime library on the link command line, thus resolving the reference to the definition in the object file. Now rebuilding the project should no longer generate the symbol redefined errors.

      But there are another two errors appearing in the lnk_msp430f5438a.cmd:

      "../lnk_msp430f5438a.cmd", line 21: error #78-D: this declaration has no storage class or type specifier

      "../lnk_msp430f5438a.cmd", line 22: error #66: expected a ";"

       

      Since the same project for IAR can be built successfully, could you please help to indicate which step I missed or where to modify the code?

      Thanks for you kindly help!

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • GregM
      Posted by GregM
      on Jun 21 2012 14:36 PM
      Prodigy225 points

      For both issues above, what's going on is putchar() is redefined in user code, but then the user's code also uses other library functions that bring in the library's definition of putchar().  IAR uses a different method for users to define device drivers.  For CCS, the proper solution to creating new device drivers for CIO is discussed in this entry: http://e2e.ti.com/support/development_tools/compiler/f/343/t/194851.aspx

      More directly see this app note: spra861.pdf

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use