<< Previous | Index | Next >>

> ## 2. Introduction to Dynamic C

> Dynamic C is an integrated development system for writing embedded software. It is designed for use with Rabbit controllers and other controllers based on the Rabbit microprocessor.

> ### 2.1 The Nature of Dynamic C

> Dynamic C integrates the following development functions:

> - Editing
> - Compiling
> - Linking
> - Loading
> - Debugging

> into one program. In fact, compiling, linking and loading are one function. Dynamic C has an easy-to-use, built-in, full-featured text editor. Dynamic C programs can be executed and debugged interactively at the source-code or machine-code level. Pull-down menus and keyboard shortcuts for most commands make Dynamic C easy to use.

> Dynamic C also supports assembly language programming. It is not necessary to leave C or the development system to write assembly language code. C and assembly language may be mixed together.

> Debugging under Dynamic C includes the ability to use `printf` commands, watch expressions, breakpoints and stack tracing. Watch expressions can be used to compute C expressions involving the target's program variables or functions. Watch expressions can be evaluated while stopped at a breakpoint or while the target is running its program. Stack tracing shows function call sequences and parameter values.

> Dynamic C provides extensions to the C language (such as shared and protected variables, costatements and cofunctions) that support real-world embedded system development. Dynamic C supports cooperative and preemptive multitasking.

> Dynamic C comes with many function libraries, all in source code. These libraries support real-time programming, machine level I/O, and provide standard string and math functions.

> #### 2.1.1 Speed

> Dynamic C compiles directly to memory. Functions and libraries are compiled and linked and downloaded on-the-fly. On a fast PC, Dynamic C might load 30,000 bytes of code in five seconds at a baud rate of 115,200 bps.

> ### 2.2 Dynamic C Enhancements and Differences

> Dynamic C differs from a traditional C programming system running on a PC or under UNIX. The reason? To better help customers write the most reliable embedded control software possible. It is not possible to use standard C in an embedded environment without making adaptations. Standard C makes many assumptions that do not apply to embedded systems. For example, standard C implicitly assumes that an operating system is present and that a program starts with a clean slate, whereas embedded systems may have battery-backed memory and may retain data through power cycles. Rabbit has extended the C language in a number of areas.

> #### 2.2.1 Dynamic C Enhancements

> Many enhancements have been added to Dynamic C. Some of these are listed below.

> - Function Chaining, a concept unique to Dynamic C, allows special segments of code to be embedded within one or more functions. When a named function chain executes, all the segments belonging to that chain execute. Function chains allow software to perform initialization, data recovery, or other kinds of tasks on request.

> - Costatements allow cooperative, parallel processes to be simulated in a single program.

> - Cofunctions allow cooperative processes to be simulated in a single program.

> - Slice Statements allow preemptive processes in a single program.

> - Dynamic C supports embedded assembly code and stand-alone assembly code.

> - Dynamic C has keywords that help protect data shared between different contexts (shared) or stored in battery-backed memory (protected).

> - Dynamic C has a set of features that allow the programmer to make the fullest use of xmem (extended memory). Up until the release of Dynamic C 10.21, the compiler supported a 1 MB physical address space. Starting with Dynamic C 10.21, the compiler supports up to the 16 MB of physical memory; up to 16 MB can be used for data and up to 1 MB can be used for code. (Dynamic C has been verified to work with Rabbit-based boards with up to 4.5 MB of memory.)

>   Normally, Dynamic C takes care of memory management, but there are instances where the programmer will want to take control of it. Dynamic C has keywords and directives to help put code and data in the proper place, such as: root, xmem, and #memmap for code and far for data.

>   See Chapter 10 for further details on memory management.

> #### 2.2.2 Dynamic C Differences

> The main differences in Dynamic C are summarized in the list below and discussed in detail in Chapter 4. "Language" and Chapter 14., "Keywords."

> - If a variable is explicitly initialized in a declaration (e.g., `int x = 0;`), it is stored in flash memory (EEPROM) and cannot be changed by an assignment statement. Such a declaration will generate a warning that may be suppressed using the const keyword:

>       const int x = 0

>   To initialize static variables in Static RAM (SRAM) use #GLOBAL_INIT sections. Note that other C compilers will automatically initialize all static variables to zero that are not explicitly initialized before entering the main function. Dynamic C programs do not do this because in an embedded system you may wish to preserve the data in battery-backed RAM on reset

> - The numerous include files found in typical C programs are not used because Dynamic C has a library system that automatically provides function prototypes and similar header information to the compiler before the user's program is compiled. This is done via the `#use` directive. This is an important topic for users who are writing their own libraries. Those users should refer to Section 4.24, "Modules" for more information.

> - When declaring pointers to functions, arguments should not be used in the declaration. Arguments may be used when calling functions indirectly via pointer, but the compiler will not check the argument list in the call for correctness. See Section 4.17 for more information

> - Bit fields are not supported.

> - Separate compilation of different parts of the program is not supported or needed.

> ### 2.3 Dynamic C Differences Between Rabbit and Z180

> A major difference in the way Dynamic C interacts with a Rabbit-based board compared to a Z180 or 386EX board is that Dynamic C expects no BIOS kernel to be present on the target when it starts up. Dynamic C stores the BIOS kernel as a C source file. Dynamic C compiles and loads it to the Rabbit target when it starts. This is accomplished using the Rabbit CPU's bootstrap mode and a special programming cable provided in all Rabbit product development kits. This method has numerous advantages.

> - A socketed flash is no longer needed. BIOS updates can be made without a flash-EPROM burner since Dynamic C can communicate with a target that has a blank flash EPROM. Blank flash EPROM can be surface-mounted onto boards, reducing manufacturing costs for both Rabbit and other board developers. BIOS updates can then be made available on the Web.

> - Advanced users can see and modify the BIOS kernel directly.

> - Board developers can design Dynamic C compatible boards around the Rabbit CPU by simply following a few simple design guidelines and using a "skeleton" BIOS provided by Rabbit.

Dynamic C User's Manual | << Previous | Index | Next>> | rabbit.com