![]() |
| RabbitCore RCM3000 User's Manual |
3. Running Sample Programs
To develop and debug programs for the RCM3000 (and for all other Rabbit Semiconductor hardware), you must install and use Dynamic C.
3.1 Introduction
To help familiarize you with the RCM3000 modules, Dynamic C includes several sample programs. Loading, executing and studying these programs will give you a solid hands-on overview of the RCM3000's capabilities, as well as a quick start with Dynamic C as an application development tool.
Complete information on Dynamic C is provided in the Dynamic C User's Manual.
In order to run the sample programs discussed in this chapter and elsewhere in this manual,
- Your RCM3000 module must be plugged in to the Prototyping Board as described in Chapter 2, "Hardware Setup."
- Dynamic C must be installed and running on your PC.
- The RCM3000 module must be connected to your PC through the serial programming cable.
- Power must be applied to the RCM3000 through the Prototyping Board.
Refer to Chapter 2, "Hardware Setup," if you need further information on these steps.
To run a sample program, open it with the File menu, then press function key F9 to compile and run the program.
3.2 Sample Programs
Of the many sample programs included with Dynamic C, several are specific to the RCM3000. Sample programs illustrating the general operation of the RCM3000, and serial communication are provided in the
SAMPLES\RCM3000folder. Each sample program has comments that describe the purpose and function of the program. Follow the instructions at the beginning of the sample program.
CONTROLLED.Cuses the STDIO window to demonstrate digital outputs by toggling LEDs DS1 and DS2 on the Prototyping Board on and off.
- Parallel Port G bit 6 = LED DS1
Parallel Port G bit 7 = LED DS2
- Once you have compile this program and it is running, you will be prompted via the Dynamic C STDIO window to select LED DS1 or DS2. Use your PC keyboard to make your selection.
- Once you have selected the LED, you will be prompted to select to turn the LED either ON or OFF. A logic low will light up the LED you selected.
FLASHLED1.cdemonstrates the use of costatements to flash LEDs DS1 and DS2 on the Prototyping Board at different rates. Once you have compile this program and it is running, LEDs DS1 and DS2 will flash on/off at different rates.
FLASHLED2.cdemonstrates the use of cofunctions and costatements to flash LEDs DS1 and DS2 on the Prototyping Board at different rates. Once you have compile this program and it is running, LEDs DS1 and DS2 will flash on/off at different rates.
TOGGLESWITCH.cdemonstrates the use of costatements to detect switches using the press-and-release method of debouncing. LEDs DS1 and DS2 on the Prototyping Board are turned on and off when you press switches S2 and S3.
IR_DEMO.cDemonstrates sending Modbus ASCII packets between two Prototyping Board assemblies via the IrDA transceivers with the IrDA transceivers facing each other. Note that this sample program will only work with the RCM30/31/32XX Prototyping Board.
- First, compile and run this program on one Prototyping Board assembly, then remove the programming cable and press the RESET button on the Prototyping Board so that the first RabbitCore module is operating in the Run mode. Then connect the programming cable to the second Prototyping Board assembly with the RCM3000 and compile and run the same sample program. With the programming cable still connected to the second Prototyping Board assembly, press switch S2 on the second Prototyping Board to transmit a packet. Once the first Prototyping Board assembly receives a test packet, it will send back a response packet that will be displayed in the Dynamic C STDIO window. The test packets and response packets have different codes.
Once you have loaded and executed these sample programs and have an understanding of how Dynamic C and the RCM3000 modules interact, you can move on and try the other sample programs, or begin building your own.
3.2.1 Serial Communication
The following sample programs can be found in the
SAMPLES\RCM3000\SERIALfolder.
FLOWCONTROL.CThis program demonstrates hardware flow control by configuring Serial Port C (PC3/PC2) for CTS/RTS with serial data coming from TxB at 115,200 bps. One character at a time is received and is displayed in the STDIO window.
- To set up the Prototyping Board, you will need to tie TxB and RxB together on the RS-232 header at J5, and you will also tie TxC and RxC together using the jumpers supplied in the Development Kit as shown in the diagram.
- A repeating triangular pattern should print out in the STDIO window. The program will periodically switch flow control on or off to demonstrate the effect of no flow control.
PARITY.CThis program demonstrates the use of parity modes by repeatedly sending byte values 0127 from Serial Port B to Serial Port C. The program will switch between generating parity or not on Serial Port B. Serial Port C will always be checking parity, so parity errors should occur during every other sequence.
- To set up the Prototyping Board, you will need to tie TxB and RxC together on the RS-232 header at J5 using the jumpers supplied in the Development Kit as shown in the diagram.
- The Dynamic C STDIO window will display the error sequence.
SIMPLE3WIRE.CThis program demonstrates basic RS-232 serial communication.Lower case characters are sent by TxC, and are received by RxB. The characters are converted to upper case and are sent out by TxB, are received by RxC, and are displayed in the Dynamic C STDIO window.
- To set up the Prototyping Board, you will need to tie TxB and RxC together on the RS-232 header at J5, and you will also tie RxB and TxC together using the jumpers supplied in the Development Kit as shown in the diagram.
SIMPLE5WIRE.CThis program demonstrates 5-wire RS-232 serial communication with flow control on Serial Port C and data flow on Serial Port B.
- To set up the Prototyping Board, you will need to tie TxB and RxB together on the RS-232 header at J5, and you will also tie TxC and RxC together using the jumpers supplied in the Development Kit as shown in the diagram.
- Once you have compiled and run this program, you can test flow control by disconnecting TxC from RxC while the program is running . Characters will no longer appear in the STDIO window, and will display again once TxC is connected back to RxC.
SWITCHCHAR.CThis program demonstrates transmitting and then receiving an ASCII string on Serial Ports B and C. It also displays the serial data received from both ports in the STDIO window.
- To set up the Prototyping Board, you will need to tie TxB and RxC together on the RS-232 header at J5, and you will also tie RxB and TxC together using the jumpers supplied in the Development Kit as shown in the diagram.
- Once you have compiled and run this program, press and release S2 and S3 on the Prototyping Board. The data sent between the serial ports will be displayed in the STDIO window.
Two sample programs,
SIMPLE485MASTER.CandSIMPLE485SLAVE.C, are available to illustrate RS-485 master/slave communication. To run these sample programs, you will need a second Rabbit-based system with RS-485, and you will also have to add an RS-485 transceiver such as the SP483E and bias resistors to the RCM30/31/32XX Prototyping Board.
The diagram shows the connections. You will have to connect PC0 and PC1 (Serial Port D) on the RCM30/31/32XX Prototyping Board to the RS-485 transceiver, and you will connect PD4 to the RS-485 transceiver to enable or disable the RS-485 transmitter.
The RS-485 connections between the slave and master devices are as follows.
- · RS485+ to RS485+
- · RS485 to RS485
- · GND to GND
SIMPLE485MASTER.CThis program demonstrates a simple RS-485 transmission of lower case letters to a slave RCM3000. The slave will send back converted upper case letters back to the master RCM3000 and display them in the STDIO window. UseSIMPLE485SLAVE.Cto program the slave RCM3000.
SIMPLE485SLAVE.CThis program demonstrates a simple RS-485 transmission of lower case letters to a master RCM3000. The slave will send back converted upper case letters back to the master RCM3000 and display them in the STDIO window. UseSIMPLE485MASTER.Cto program the master RCM3000.3.2.2 Other Sample Programs
Section 6.11 describes the TCP/IP sample programs, and Appendix C.8 provides sample programs for the optional LCD/keypad module that can be installed on the Prototyping Board.
| Rabbit Semiconductor www.rabbit.com |