![]() |
| Smart Star User's Manual |
4. Software
Dynamic C is an integrated development system for writing embedded software. It runs on an IBM-compatible PC and is designed for use with Rabbit Semiconductor 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.
4.1 Running Dynamic C
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 flash memory and SRAM options are selected with the Options > Program Options > Compiler menu.
The advantage of working in RAM is to save wear on the flash memory, which is limited to about 100,000 write cycles. The disadvantage is that the code and data might not both fit in RAM.
Developing software with Dynamic C is simple. Users can write, compile, and test C and assembly code without leaving the Dynamic C development environment. Debugging occurs while the application runs on the target. Alternatively, users can compile a program to an image file for later loading. Dynamic C runs on PCs under Windows 95 or later. Programs can be downloaded at baud rates of up to 460,800 bps after the program compiles.
Dynamic C has a number of standard features.
- Full-feature source and/or assembly-level debugger, no in-circuit emulator required.
- Royalty-free TCP/IP stack with source code and most common protocols.
- Hundreds of functions in source-code libraries and sample programs:
u Exceptionally fast support for floating-point arithmetic and transcendental functions.
u RS-232 and RS-485 serial communication.
u Analog and digital I/O drivers.
u I2C, SPI, GPS, encryption, file system.
u LCD display and keypad drivers.
- Powerful language extensions for cooperative or preemptive multitasking
- Loader utility program to load binary images into Rabbit targets in the absence of Dynamic C.
- Provision for customers to create their own source code libraries and augment on-line help by creating "function description" block comments using a special format for library functions.
- Standard debugging features:
u Breakpoints--Set breakpoints that can disable interrupts.
u Single-stepping--Step into or over functions at a source or machine code level, µC/OS-II aware.
u Code disassembly--The disassembly window displays addresses, opcodes, mnemonics, and machine cycle times. Switch between debugging at machine-code level and source-code level by simply opening or closing the disassembly window.
u Watch expressions--Watch expressions are compiled when defined, so complex expressions including function calls may be placed into watch expressions. Watch expressions can be updated with or without stopping program execution.
u Register window--All processor registers and flags are displayed. The contents of general registers may be modified in the window by the user.
u Stack window--shows the contents of the top of the stack.
u Hex memory dump--displays the contents of memory at any address.
u STDIO window--
printfoutputs to this window and keyboard input on the host PC can be detected for debugging purposes.printfoutput may also be sent to a serial port or file.4.1.1 Upgrading Dynamic C
4.1.1.1 Patches and Bug Fixes
Dynamic C patches that focus on bug fixes are available from time to time. Check the Web site www.rabbit.com/support/ for the latest patches, workarounds, and bug fixes.
The default installation of a patch or bug fix is to install the file in a directory (folder) different from that of the original Dynamic C installation. Rabbit Semiconductor recommends using a different directory so that you can verify the operation of the patch without overwriting the existing Dynamic C installation. If you have made any changes to the BIOS or to libraries, or if you have programs in the old directory (folder), make these same changes to the BIOS or libraries in the new directory containing the patch. Do not simply copy over an entire file since you may overwrite a bug fix. Once you are sure the new patch works entirely to your satisfaction, you may retire the existing installation, but keep it available to handle legacy applications.
4.1.1.2 Upgrades
Dynamic C installations are designed for use with the board they are included with, and are included at no charge as part of our low-cost kits. Dynamic C is a complete software development system, but does not include all the Dynamic C features. Rabbit Semiconductor also offers add-on Dynamic C modules containing the popular µC/OS-II real-time operating system, as well as PPP, Advanced Encryption Standard (AES), and other select libraries. In addition to the Web-based technical support included at no extra charge, a one-year telephone-based technical support module is also available for purchase.
4.2 Sample Programs
Sample programs are provided in the Dynamic C
SAMPLESfolder. The sample programPONG.Cdemonstrates the output to the STDIO window. The various directories in theSAMPLESfolder contain specific sample programs that illustrate the use of the corresponding Dynamic C libraries.The
SAMPLES\SMRTSTARfolder 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.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 BL2500 must be in Program mode (see Section 3.3, "Programming Cable") and must be connected to a PC using the programming cable as described in Section 2.2, "Connect the Power Supply."
More complete information on Dynamic C is provided in the Dynamic C User's Manual.
Let's take a look at sample programs for the backplane and the CPU Card in the
SMRTSTARfolder.The
RS232directory contains two sample programs to illustrate RS-232 serial communication.
SSTAR232.C--Demonstrates a simple RS-232 loopback using both serial ports C and D.
SSTAR5W.C--Demonstrates simple 5-wire RS-232 communication with flow control.The
RS485directory contains two sample programs to illustrate RS-485 serial communication.
MASTER.C--Demonstrates a simple RS-485 transmission of lower case letters to a slave controller. The slave will send converted upper case letters back to the master controller for display in the STDIO window. UseSLAVE.Cto program the slave controller.
SLAVE.C--Demonstrates a simple RS-485 transmission of alphabetic characters to a master controller. The slave will send converted upper case letters back to the master controller for display in the STDIO window. UseMASTER.Cto program the master controller.4.3 Dynamic C Libraries
One library directory contains software that is unique to the Smart Star.
SMRTSTAR.LIB--This library supports all the functions needed by the Smart Star systems including Digital I/O Cards, Relay Cards, D/A Converter and A/D Converter Cards, and serial communication.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.
Other functions applicable to all devices based on the Rabbit 2000 microprocessor are described in the Dynamic C User's Manual.
4.4 Smart Star Backplane Function Calls
4.4.1 Board Reset
void brdResetBus();
- Resets all cards on the bus.
Return Value
- None.
4.4.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.5 Serial Communication Calls
Library files included with Dynamic C provide a full range of serial communications support. The
RS232.LIBlibrary provides a set of circular-buffer-based serial functions. ThePACKET.LIBlibrary 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 Function Reference 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 serial communication lines for the Smart Star control system. Call this function after
serXOpen().Parameters
modeis the defined serial port configuration of the CPU Card.
RS-232, 3-wire
RS-485
RS-232, 3-wire
RS-232, 3-wire
RS-232, 5-wire
RTS/CTS
RS-232, 5-wire
RS-485
RTS/CTS
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
ser485Rx();
- Disables RS-485 transmission (enables receive) on serial port D.
Return Value
- None.
See Also
ser485Tx
| Rabbit Semiconductor www.rabbit.com |