Digi BL1800 user manual Sample Program DEMOJR1.C

Page 44

4.2.1 DEMOJR1.C

This sample program can be used to illustrate some of the functions of Dynamic C.

First, open the file DEMOJR1.C, which is in the SAMPLES/JACKRAB folder. The program will appear in a window, as shown in Figure 15 below (minus some comments). Use the mouse to place the cursor on the function name WrPortI in the program and type <Ctrl-H>. This will bring up a documentation box for the function WrPortI. In general, you can do this with all functions in Dynamic C libraries, including libraries that you write yourself— the Dynamic C User’s Manual provides more information. Close the documentation box and continue.

C programs begin with main

 

NULL is a macro for a zero pointer

main(){

write to SPCR register to

 

 

initialize parallel port A

WrPortI(SPCR,NULL,0x84);

Write all 1’s to port A

 

to turn off all LEDs

WrPortI(PADR,&PADRShadow,0xff);

 

 

Start a loop

while(1) {

Set bit 2 to a “1”

 

BitWrPortI(PADR,&PADRShadow,1,2);

LED DS3 off.

Time delay by counting

for(j=0; j<25000; j++);

to 25,000.

BitWrPortI(PADR,&PADRShadow,0,2);

Set bit 2 to a “0”

for(j=0; j<1000; j++);

turning LED DS3 on

 

} // end while(1)

Count to 1000 for a shorter

 

} // end of main

time delay

End of the endless loop

 

Note: See Rabbit 2000 Microprocessor User’s Manual (Software Chapter) for details on the routines that read and write I/O ports.

Figure 15. Sample Program DEMOJR1.C

To run the program DEMOJR1.C, load it with the File > Open menu, then compile and run it by pressing F9 or by selecting Run in the Run menu. The LED on the Prototyping Board should start flashing if everything went well. If this doesn’t work review the following points.

The target should be ready, which is indicated by the message “BIOS successfully com- piled...” If you did not receive this message or you get a communication error, recom- pile the BIOS by typing <Ctrl-Y>or select Recompile BIOS from the Compile menu.

A message reports that “No Rabbit processor detected” in cases where the Jackrabbit and Prototyping Board are not connected together, the wall transformer is not con- nected, or is not plugged in. (The red power LED lights whenever power is connected.)

40

Jackrabbit (BL1800)

Image 44
Contents Jackrabbit BL1800 Programmable Single-Board ComputerTrademarks Digi International IncTable of Contents Index Schematics Features IntroductionJackrabbit Features Development and Evaluation ToolsOnline Documentation How to Use This ManualAdditional Product Information Emissions CE ComplianceImmunity Interfacing the Jackrabbit to Other Devices SafetyDesign Guidelines General Jackrabbit BL1800 Development Kit Contents Getting StartedDevelopment Hardware Connections Board Attach Jackrabbit to Prototyping BoardConnect Programming Cable Assemble AC AdapterConnect Power Installing Dynamic C Troubleshooting Run a Sample ProgramTechnical Support Where Do I Go From Here?Real-Time Clock Subsystems BL1800Jackrabbit Pinouts HeadersDigital Inputs/Outputs Digital InputsDigital Outputs HV3 Sourcing OutputConfigurable High-Current Output Bidirectional I/O Changing HV3 to a Sinking OutputSchematic Diagram of A/D Converter A/D ConverterJackrabbit BL1800 Schematic Diagram of D/A Converters D/A ConvertersV ⋅ 1 e RC 1 DA1Typical DA1 Voltages for Various Duty Cycles 2 DA0 Typical DA0 Voltages for Various Duty CyclesUser’s Manual 2 RS-485 Serial Communication1 RS-232 Ground recommended Programming Port 485 R16User’s Manual Changing Between Program Mode and Run Mode Programming CableFlash Eprom MemorySram Clock Doubler Other HardwareExternal Interrupts Spectrum Spreader Jackrabbit BL1800 Software Reference An Overview of Dynamic CJackrabbit BL1800 Sample Programs Jackrabbit Sample ProgramsDEMOJR1.C Sample Program DEMOJR1.CSingle-Stepping Watch Expression Break PointWatching Variables Dynamically Summary of FeaturesEditing the Program User’s Manual Other Sample Programs Illustrating Digital I/O R/W pin and DB0-DB3 on 3 RS-232 Serial Communication Sample Programs 4 RS-485 Serial Communication Sample Program Cooperative Multitasking Int vswitch Advantages of Cooperative Multitasking Jackrabbit Function Calls 1 I/O DriversVoid digOutint channel, int value Void anaOutint channel, int value Void anaInint channel, int *value Serial Communication Drivers Add-On Modules Upgrading Dynamic CPatches and Bug Fixes Appendix A. Specifications Electrical and Mechanical Specifications Figure A-1shows the mechanical dimensions for the JackrabbitTable A-1. Jackrabbit Board Specifications Exclusion Zone Exclusion ZonesFigure A-3. User Board Footprint for Jackrabbit Jumper Configurations Figure A-4. Location of Jackrabbit Configurable PositionsTable A-2. Jackrabbit Jumper Configurations Conformal Coating Conformally coated areaUse of Rabbit 2000 Parallel Ports JackrabbitTable A-3. Jackrabbit Pinout Configurations PD0 PD1 Jackrabbit BL1800 Appendix B. Prototyping Board Jackrabbit Connectors User LEDs Buzzer Prototyping Board OverviewPrototyping Board Features Mechanical Dimensions and Layout Top SideUsing the Prototyping Board Top SideDemonstration Board RelayExisting Prototyping Board Top SidePE0 VCC HV0 SM1 SM0 HV2 Stat Jackrabbit BL1800 Appendix C. Power Management Power SuppliesDcin Current mA Batteries and External Battery Connections 950 mA·h = 5.4 years 20 µABattery Backup Circuit Figure C-5shows the Jackrabbit battery backup circuitryPower to Vram Switch Reset GeneratorFigure C-7shows a schematic of the chip select circuit Chip Select CircuitJackrabbit BL1800 Index SMODE0 SMODE1RABDB01.C RABDB02.C Schematics