![]() |
| RabbitCore RCM3700 User's Manual |
3. Running Sample Programs
To develop and debug programs for the RCM3700 (and for all other Rabbit Semiconductor hardware), you must install and use Dynamic C.
3.1 Introduction
To help familiarize you with the RCM3700 modules, Dynamic C includes several sample programs. Loading, executing and studying these programs will give you a solid hands-on overview of the RCM3700's capabilities, as well as a quick start with Dynamic C as an application development tool.
In order to run the sample programs discussed in this chapter and elsewhere in this manual,
- Your RCM3700 must be plugged in to the Prototyping Board as described in Chapter 2, "Getting Started."
- Dynamic C must be installed and running on your PC.
- The programming cable must connect the programming header (J2) on the RCM3700 to your PC.
- Power must be applied to the RCM3700 through the Prototyping Board.
Refer to Chapter 2, "Getting Started," if you need further information on these steps.
To run a sample program, open it with the File menu, then compile and run it by pressing F9. The RCM3700 must be connected to a PC using the programming cable.
Complete information on Dynamic C is provided in the Dynamic C User's Manual.
The default I/O configuration in the sample programs is based on the RabbitCore module detected during compile time:
- Any RCM3700 RabbitCore module (except the RCM3720) will have its I/O ports configured for an RCM3700 Prototyping Board.
- An RCM3720 RabbitCore module will have its I/O ports configured for an RCM3720 Prototyping Board.
You may override these default settings to run an RCM3720 RabbitCore module on the RCM3700 Prototyping Board or to run another RCM3700 RabbitCore module on the RCM3720 Prototyping Board by adding the following macro to the sample program you will be running.
- To run an RCM3720 RabbitCore module on an RCM3700 Prototyping Board, add the following macro at the top of the sample program you will be running.
#define RCM3700_PROTOBOARD
- Sample programs that are specifically designed for the RCM3700 Prototyping Board already have this macro included.
- To run an RCM3700 RabbitCore module (other than the RCM3720) on an RCM3720 Prototyping Board, add the following macro at the top of the sample program you will be running.
#define RCM3720_PROTOBOARD3.2 Sample Programs
Of the many sample programs included with Dynamic C, several are specific to the RCM3700. Sample programs illustrating the general operation of the RCM3700, serial communication, and the A/D converter on the Prototyping Board are provided in the
SAMPLES\RCM3700and theSAMPLES\RCM3720folders as shown in the table below. The sample programs use the features available on the two Prototyping Boards.
Feature RCM3700 Prototyping Board RCM3720 Prototyping Board Sample Program Folder
Each sample program has comments that describe the purpose and function of the program. Follow the instructions at the beginning of the sample program. Note that the RCM3700 must be installed on the Prototyping Board when using these sample programs.
TCP/IP sample programs are described in Chapter 6, "Using the TCP/IP Features." Sample programs for the optional LCD/keypad module that is used on the RCM3700 Prototyping Board are described in Appendix C.
Additional sample programs are available online at www.rabbit.com/support/downloads/downloads_prod.shtml.
DIO.cDemonstrates the digital I/O capabilities of the A/D converter on the Prototyping Board by configuring two lines to outputs and two lines as inputs on Prototyping Board header JP4.
- If you are using the RCM3700 Prototyping Board, install a 2 x 2 header at JP4 and connect pins 12 and pins 34 on header JP4 before running this sample program.
FLASHLED.cDemonstrates assembly-language program by flashing LEDs DS1 and DS2 on the Prototyping Board at different rates.
TOGGLESWITCH.cUses costatements to detect switches using debouncing. The corresponding LEDs (DS1 and DS2) will turn on or off.
CONTROLLED.cDemonstrates use of the digital inputs by having you turn the LEDs on the Prototyping Board on or off from the STDIO window on your PC.Once you compile and run
CONTROLLED.C, the following display will appear in the Dynamic C STDIO window.![]()
Press "1" or "2" on your keyboard to select LED DS1 or DS2 on the Prototyping Board. Then follow the prompt in the Dynamic C STDIO window to turn the LED on or off.
IR_DEMO.cDemonstrates sending Modbus ASCII packets between two RCM3700 Prototyping Board assemblies with IrDA transceivers via the IrDA transceivers. Note that this sample program will only work with the RCM3700 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 RCM3700 and compile and run the same sample program. With the programming cable still connected to the second Prototyping Board assembly, press switch S1 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 five programs and have an understanding of how Dynamic C and the RCM3700 modules interact, you can move on and try the other sample programs, or begin building your own.
3.2.1 Use of Serial Flash
The following sample programs can be found in the
SAMPLES\RCM3700\SerialFlashand theSAMPLES\RCM3720\SerialFlashfolders.
SERIAL_FLASHLOG.C This program runs a simple Web server and stores a log of hits on the home page of the serial flash "server." This log can be viewed and cleared from a browser at http://10.10.6.100/. You may need to first "configure" your PC for a "10Base-T Half-Duplex" or an "Auto-Negotiation" connection from the "Advanced" tab, which is accessed from the control panel (Start > Settings > Control Panel) by choosing Network Connections.
SFLASH_INSPECT.C This program is a handy utility for inspecting the contents of a serial flash chip. When the sample program starts running, it attempts to initialize a serial flash chip on Serial Port B. Once a serial flash chip is found, the user can perform two different commands to either print out the contents of a specified page or clear (set to zero) all the bytes in a specified page.3.2.2 Serial Communication
The following sample programs can be found in the
SAMPLES\RCM3700\SERIALand theSAMPLES\RCM3720\SERIALfolders.
BitWrPortI(PEDR, &PEDRShadow, 0, 5); //set low to enable rs232 device
FLOWCONTROL.CThis program demonstrates hardware flow control by configuring Serial Port C for CTS/RTS with serial data coming from Serial Port D. The serial data received are displayed in the STDIO window.
- To set up the Prototyping Board, you will need to tie TxC and RxC together on the RS-232 header at J2, and you will also tie TxD and RxD 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.
- Refer to the function description for
serDflowcontrolOn()in the Dynamic C Function Reference Manual for a general description on how to set up flow-control lines.
PARITY.CThis program demonstrates the use of parity modes by repeatedly sending byte values 0127 from Serial Port D to Serial Port C. The program will switch between generating parity or not on Serial Port D. 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 TxD and RxC together on the RS-232 header at J2 using the 0.1" 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 RxD. The characters are converted to upper case and are sent out by TxD, are received by RxC, and are displayed in the Dynamic C STDIO window.![]()
- To set up the Prototyping Board, you will need to tie TxD and RxC together on the RS-232 header at J2, and you will also tie RxD and TxC together using the 0.1" 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 D.
- To set up the Prototyping Board, you will need to tie TxD and RxD together on the RS-232 header at J2, and you will also tie TxC and RxC together using the 0.1" 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 transmits and then receives an ASCII string on Serial Ports C and E. It also displays the serial data received from both ports in the STDIO window.
- Before running this sample program, check to make sure that Serial Port E is set up as an RS-232 serial portpins 13 and pins 24 on header JP2 on the Prototyping Board must be jumpered together using the 2 mm jumpers supplied in the Development Kit. Then connect TxC to RxE and connect RxC to TxE on the RS-232 header at J2 using the 0.1" jumpers supplied in the Development Kit as shown in the diagram.
![]()
NOTE The following two sample programs illustrating RS-485 serial communication will only work with the RCM3700 Prototyping Board.
SIMPLE485MASTER.CThis program demonstrates a simple RS-485 transmission of lower case letters to a slave RCM3700. The slave will send back converted upper case letters back to the master RCM3700 and display them in the STDIO window. UseSIMPLE485SLAVE.Cto program the slave RCM3700, and check to make sure that Serial Port E is set up as an RS-485 serial portpins 35 and pins 46 on header JP2 must be jumpered together using the 2 mm jumpers supplied in the Development Kit.
SIMPLE485SLAVE.CThis program demonstrates a simple RS-485 transmission of lower case letters to a master RCM3700. The slave will send back converted upper case letters back to the master RCM3700 and display them in the STDIO window. UseSIMPLE485MASTER.Cto program the master RCM3700, and check to make sure that Serial Port E is set up as an RS-485 serial portpins 35 and pins 46 on header JP2 must be jumpered together using the 2 mm jumpers supplied in the Development Kit.![]()
3.2.3 A/D Converter Inputs
The following sample programs are found in the
SAMPLES\RCM3700\ADCfolder.
AD_CALDIFF_CH.CDemonstrates how to recalibrate one differential analog input channel using two known voltages to generate the calibration constants for that channel. Constants will be rewritten into user block data area.
- Before running this program, make sure that pins 13 are connected on headers JP5, JP6, and JP7 on the Prototyping Board. No pins are connected on header JP8.
AD_CALMA_CH.CDemonstrates how to recalibrate an A/D input channel being used to convert analog current measurements to generate the calibration constants for that channel.
- Before running this program, make sure that pins 35 are connected on headers JP5, JP6, and JP7 on the Prototyping Board. Connect pins 12, 34, 56, 78 on header JP8.
AD_CALSE_ALL.CDemonstrates how to recalibrate all single-ended analog input channels for one gain, using two known voltages to generate the calibration constants for each channel. Constants will be rewritten into the user block data area.
- Before running this program, make sure that pins 35 are connected on headers JP5, JP6, and JP7 on the Prototyping Board. No pins are connected on header JP8.
AD_CALSE_CHAN.CDemonstrates how to recalibrate one single-ended analog input channel with one gain using two known voltages to generate the calibration constants for that channel. Constants will be rewritten into user block data area.
NOTE The above sample programs will overwrite any existing calibration constants.
AD_RDDIFF_CH.CDemonstrates how to read an A/D input channel being used for a differential input using previously defined calibration constants.
- Before running this program, make sure that pins 13 are connected on headers JP5, JP6, and JP7 on the Prototyping Board. No pins are connected on header JP8.
AD_RDMA_CH.CDemonstrates how to read an A/D input channel being used to convert analog current measurements using previously defined calibration constants for that channel.
- Before running this program, make sure that pins 35 are connected on headers JP5, JP6, and JP7 on the Prototyping Board. Connect pins 12, 34, 56, 78 on header JP8.
AD_RDSE_ALL.CDemonstrates how to read all single-ended A/D input channels using previously defined calibration constants.
- Before running this program, make sure that pins 35 are connected on headers JP5, JP6, and JP7 on the Prototyping Board. No pins are connected on header JP8.
AD_SAMPLE.CDemonstrates how to use a low-level driver on single-ended inputs. The program will continuously display the voltage (average of 10 samples) that is present on the A/D channels.
- Before running this program, make sure that pins 35 are connected on headers JP5, JP6, and JP7 on the Prototyping Board. No pins are connected on header JP8.
ANAINCONFIG.CDemonstrates how to use the Register Mode method to read single-ended analog input values for display as voltages. The sample program uses the function callanaInConfig()and the ADS7870 CONVERT line to accomplish this task.
- Before running this program, make sure that pins 35 are connected on headers JP5, JP6, and JP7 on the Prototyping Board. No pins are connected on header JP8. Also connect PE4 on header J3 on the Prototyping Board to the CNVRT terminal on header J8.
- If you use this sample program as a template for your own program, be aware that PE4 is also used for the IrDA FIR_SEL on the Prototyping Board. You will need to use another parallel port line for the analog input if you are also using the IrDA transceiver.
THERMISTOR.CDemonstrates how to use analog input THERM_IN7 to calculate temperature for display to the STDIO window. This sample program assumes that the thermistor is the one included in the Development Kit whose values for beta, series resistance, and resistance at standard temperature are given in the part specification.Before running the next two sample programs,
DNLOADCALIB.CorUPLOADCALIB.C, connect your PC serial COM port to header J2 on the Prototyping Board as follows.Then connect pins 13 and 24 on header JP2 on the Prototyping Board.
You will need to run a serial utility such as Tera Term on your PC. You may download Tera Term from hp.vector.co.jp/authors/VA002416/teraterm.html. Once Tera Term is running, configure the serial parameters as follows.
- Baud rate 19200, 8 bits, no parity, and 1 stop bit.
- Enable the "Local Echo" option.
- Set the line feed options to Receive = CR and Transmit = CR + LF.
Now press F9 to compile and run this program. Verify that the message "Waiting, Please Send Data file" is being display in Tera Term display window before proceeding. From within Tera Term, select File > Send File > Path and filename, then select the OPEN option within the dialog box. Once the data file has been downloaded, it will indicate whether the calibration data were written successfully.
DNLOADCALIB.CDemonstrates how to retrieve analog calibration data to rewrite it back to simulated EEPROM in flash with using a serial utility such as Tera Term.
UPLOADCALIB.CDemonstrates how to read calibrations constants from the user block in flash memory and then transmitting the file using a serial port and a PC serial utility such as Tera Term. UseDNLOADCALIB.Cto download the calibration constants created by this program.
| Rabbit Semiconductor www.rabbit.com |