Smart Star
User's Manual
PREV NEXT INDEX



4. Software

Dynamic C Premier is an integrated development system for writing embedded software. It runs on an IBM-compatible PC and is designed for use with Z-World controllers and other controllers based on the Rabbit microprocessor.

Chapter 4 provides the libraries, function calls, and sample programs related to the Smart Star backplane and CPU cards.

You have a choice of doing your software development in the flash memory or in the static RAM included on the Smart Star CPU cards. The advantage of working in RAM is to save wear on the flash memory, which is limited to about 100,000 write cycles.

NOTE An application can be developed in RAM, but cannot run standalone from RAM after the programming cable is disconnected. All standalone applications can only run from flash memory.

The disadvantage of using flash memory for debug is that interrupts must be disabled for approximately 5 ms whenever a break point is set in the program. This can crash fast interrupt routines that are running while you stop at a break point or single-step the program. Flash memory or RAM is selected on the Options > Compiler menu.

Dynamic C Premier provides a number of debugging features. You can single-step your program, either in C, statement by statement, or in assembly language, instruction by instruction. You can set break points, where the program will stop, on any statement. You can evaluate watch expressions. A watch expression is any C expression that can be evaluated in the context of the program. If the program is at a break point, a watch expression can view any expression using local or external variables.

4.1 Programming Cable

The programming cable has a level converter board in the middle of the cable since the programming port on the CPU card supports CMOS logic levels, and not the higher voltage RS-232 levels that are used by PC serial ports. When the programming cable is connected, Dynamic C running on the PC can hard-reset the Smart Star and cold-boot it. The cold boot includes compiling and downloading a BIOS program that stays resident while you work. If you crash the target, Dynamic C will automatically reboot and recompile the BIOS if it senses that a target communication error occurred or that the BIOS source code has changed.

4.1.1 Switching Between Program Mode and Run Mode

The CPU card is automatically in Program Mode when the programming cable is attached, and is automatically in Run Mode when no programming cable is attached. See Figure 17.


Figure 17. Smart Star Program Mode and Run Mode Set-Up

4.1.2 Changing from Program Mode to Run Mode

  1. Disconnect the programming cable from header J2 of the CPU card.

  2. Reset the Smart Star by unplugging the power supply, then plugging it back in.

The Smart Star is now ready to operate in the Run Mode.

4.1.3 Changing from Run Mode to Program Mode

  1. Attach the programming cable to header J2 of the CPU card.

  2. Reset the Smart Star by unplugging the power supply, then plugging it back in.

The Smart Star is now ready to operate in the Program Mode.

4.2 Dynamic C Libraries

With Dynamic C running, click File > Open, and select Lib. The following list of Dynamic C libraries and library directories will be displayed.


One library directory contains software that is unique to the Smart Star.

Other functions applicable to all devices based on the Rabbit 2000 microprocessor are described in the Dynamic C Premier User's Manual.

4.2.1 Library Directories

The SMRTSTAR directory contains libraries required to operate the Smart Star control system.


Functions dealing with the backplane and the CPU card are described in this chapter. Functions relevant to the individual I/O cards are described in the chapter specific to the I/O card.

4.3 Smart Star Backplane Function APIs

4.3.1 Board Reset

void brdResetBus();


Resets all cards on the bus.
Return Value
None.

4.3.2 Board Initialization

void brdInit();


Initializes slot addressing, disables card enable/disable line, resets card slot bus and LED latch, and turns all LEDS OFF. Call this function at the beginning of the application.
Return Value
None.

4.4 Serial Communication APIs

Library files included with Dynamic C provide a full range of serial communications support. The RS232.LIB library provides a set of circular-buffer-based serial functions. The PACKET.LIB library provides packet-based serial functions where packets can be delimited by the 9th bit, by transmission gaps, or with user-defined special characters. Both libraries provide blocking functions, which do not return until they are finished transmitting or receiving, and nonblocking functions, which must be called repeatedly until they are finished. For more information, see the Dynamic C Premier User's Manual and Technical Note 213, Rabbit 2000 Serial Port Software.

Use the following function calls with the Smart Star.

int serMode(int mode);


User interface to set up up serial communication lines for the Smart Star control system. Call this function after serXOpen().
Parameters
mode is the defined serial port configuration of the CPU card.

Return Value
0 if correct mode, 1 if not.

ser485Tx();


Enables RS-485 transmission (disables receive) on serial port D.
Return Value
None.
See Also

ser485Rx();


Disables RS-485 transmission (enables receive) on serial port D.
Return Value
None.
See Also

4.5 Sample Programs

Sample programs are provided in the Dynamic C Samples folder, which is shown below.


The various folders contain specific sample programs that illustrate the use of the corresponding Dynamic C libraries. For example, the sample program PONG.C demonstrates the output to the STDIO window.

The SMRTSTAR folder provides sample programs specific to the Smart Star control system. Each sample program has comments that describe the purpose and function of the program. Follow the instructions at the beginning of the sample program.

Let's take a look at sample programs for the backplane and the CPU card in the SMRTSTAR folder.


The RS232 directory contains two sample programs to illustrate RS-232 serial communication.

The RS485 directory contains two sample programs to illustrate RS-485 serial communication.

4.6 Using Dynamic C

To run a sample program, open it with the File menu (if it is not still open), compile it using the Compile menu, and then run it by selecting Run in the Run menu. The CPU card must be in Program Mode (see Section 4.1, "Programming Cable") and must be connected to a PC using the programming cable as described in Section 2.3, "Programming Cable Connections."

More complete information on Dynamic C is provided in the Dynamic C Premier User's Manual.


PREV NEXT INDEX


Z-World
http://www.zworld.com
Voice: (530) 757-3737
FAX: (530) 757-3792
sales@zworld.com