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.

LaunchPad Hello World

Other Parts Discussed in Thread: MSP430G2231

Trying to do "hello world" on LaunchPad but getting errors.  Seems pretty simple, but obviously I'm doing something wrong.  I assume the G2231 supports printf?

Start CCS v4.1.3 (downloaded latest updates)
New workspace
Start new project, give it a name, select the MSP430G2231 (this is the device on the LaunchPad)
Create a new main.c file, type h then cntl-enter and CCS puts in the hello world code.
Click on build all and I get this:
 
 
**** Build of configuration Debug for project Hello ****
 
C:\Program Files\Texas Instruments CCS4.1\ccsv4\utils\gmake\gmake -k all
'Building file: ../main.c'
'Invoking: Compiler'
"C:/Program Files/Texas Instruments CCS4.1/ccsv4/tools/compiler/msp430/bin/cl430" --silicon_version=msp -g --include_path="C:/Program Files/Texas Instruments CCS4.1/ccsv4/msp430/include" --include_path="C:/Program Files/Texas Instruments CCS4.1/ccsv4/tools/compiler/msp430/include" --diag_warning=225 --printf_support=minimal --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
'Finished building: ../main.c'
' '
'Building target: Hello.out'
'Invoking: Linker'
"C:/Program Files/Texas Instruments CCS4.1/ccsv4/tools/compiler/msp430/bin/cl430" --silicon_version=msp -g --diag_warning=225 --printf_support=minimal -z -m"Hello.map" --stack_size=50 --heap_size=0 --warn_sections -i"C:/Program Files/Texas Instruments CCS4.1/ccsv4/msp430/include" -i"C:/Program Files/Texas Instruments CCS4.1/ccsv4/tools/compiler/msp430/lib" -i"C:/Program Files/Texas Instruments CCS4.1/ccsv4/tools/compiler/msp430/include" --reread_libs --rom_model -o "Hello.out" "./main.obj" -l"libc.a" "../lnk_msp430g2231.cmd"
<Linking>

"../lnk_msp430g2231.cmd", line 60: error: placement fails for object ".text",
size 0x10b6 (page 0). Available ranges:
FLASH size: 0x7e0 unused: 0x74c max hole: 0x74c
"../lnk_msp430g2231.cmd", line 56: error: run placement fails for object
".bss", size 0x22c (page 0). Available ranges:
RAM size: 0x80 unused: 0x4a max hole: 0x48
"../lnk_msp430g2231.cmd", line 63: error: run placement fails for object
".cio", size 0x120 (page 0). Available ranges:
RAM size: 0x80 unused: 0x4a max hole: 0x48
error: errors encountered during linking; "Hello.out" not built
 
>> Compilation failure
C:\Program Files\Texas Instruments CCS4.1\ccsv4\utils\gmake\gmake: *** [Hello.out] Error 1
C:\Program Files\Texas Instruments CCS4.1\ccsv4\utils\gmake\gmake: Target `all' not remade because of errors.
Build complete for project Hello
 

  • Terry,

    printf() stack requires quite a bit of code, more than the G2231 can't provide (in terms of flash memory). The error messages indicate as such. 

    Terry said:
    FLASH size: 0x7e0 unused: 0x74c max hole: 0x74c

    ~Dung

  • Dung,

    Thanks for the quick response.

    Terry

  • These error messages are only 'telling' if you know what a linker does and how.

    As a newbie programmer, you often do not know about linker segments and therefore all this info has no meaning.

    A simple message like

    Error: code or data too large for available space! segment: .text maximum size: 0x77f bytes required size: 0x1000 bytes

    would be way more clear. All the additional output is a nice add-on for those who know what's going on.
    It is essentially the same information, but presented in a way that you immediately know what's wrong without need of 'expert' knowledge.

  • I agree.  It would help if tool error messages were more "new user" friendly.

  • Dung,

    Thanks for the clarification!

    Now, is there a function I CAN use for console output (for example, for debugging) that will fit in the 2231's memory space?

    Thanks!

    Victor II

  • hello people, I would like to bring back this topic, as I have the same question at the last post which has not been answered yet.

     

    Please teach us how to output something with G2231's limited flash memory.

     

    sincerely thanks

  • Yes and no. Depends on what you want to do.

    Yoo need to:

    - create a function that outputs single bytes serially. This is the 'putchar' function, usually used by printf inplementations for sending the data. Output can happen through hhardware UART or software UART. See the demo code of the LaunchPad for a software UART implementation.
    - create a fucntion that stuffs the output function with data, This is what printf normally does. However, printf contains so much formatting features that it is big. If oyu only want to send a plain text, you'll rather need something like puts() (which simply sends one byte of a string after the other to putchar, without any interpretation of numbers or other formatting).

    For a small and fast implementation that turns a binary value into a human-readable number string (itoa() function), use the search function for "printf" on this board. Some solutions have been posted in the past.

    After all, the main job in microcontroller programming is to write a solution that is as small and fast as possible for your applciaiton. Using big and bloated libraries for convenience is the domain of PC coders. Remember, that printf() is not part of the C language itself. It is just a function like any other. Conveniently added to most development suites, but an add-on nevertheless.

**Attention** This is a public forum