3. Creating a Simple Application with the c29clang Compiler Tools

This section of the Getting Started Guide provides an example of how to build a simple application using the c29clang command-line interface. In addition, it provides a walk-through of how to build a simple application in a Code Composer Studio project that uses the c29clang compiler.

3.1. Source Files

The subsections below describe how to build a simple “Hello World!” program using either the c29clang command-line interface or the Code Composer Studio (CCS) development environment. For the purposes of these tutorial examples, it is assumed that you have a C source file containing the following C code:

1#include <stdio.h>
2
3int main() {
4  printf("Hello World\n");
5  return 0;
6}

It is also assumed that you have at your disposal a linker command file that provides a specification of the available memory and how to place compiler/linker generated output sections in that memory. For example, in the tutorials below, the following linker command file, named lnkme.cmd, could be used:

/****************************************************************************/
/* lnk.cmd - V1.00  Command file for linking C29 programs                   */
/****************************************************************************/
/* This linker command file assumes C/C++ model                             */
/****************************************************************************/
-c
-stack  0x8000                             /* Software stack size           */
-heap   0x2000                             /* Heap area size                */

/* Specify the system memory map */
MEMORY
{
  ROM    : org = 0x00000020   len = 0x2FFFE0    /* 1.25 GB */
  FLASH  : org = 0x10000000   len = 0x300000    /* 1.25 GB */
  RAM    : org = 0x18000000   len = 0x300000    /* 1.25 GB */
}
#define RO_CODE FLASH
#define RO_DATA FLASH
#define RW_DATA RAM

/* Specify the sections allocation into memory */

SECTIONS
{
    .text    : {} > RO_CODE            /* Code                              */
    .cinit   : {} > RO_DATA            /* Initialization tables             */
    .const   : {} > RO_DATA            /* Constant data                     */
    .pinit   : {} > RO_DATA            /* C++ Constructor tables            */

    .data    : {} > RW_DATA            /* Initialized variables             */
    .bss     : {} > RW_DATA            /* Uninitialized variables           */
    .stack   : {} > RW_DATA            /* Software system stack             */
    .sysmem  : {} > RW_DATA            /* Dynamic memory allocation area    */
}