Digi BL1800 user manual Serial Communication Drivers

Page 59

4.4.2 Serial Communication Drivers

Library files included with Dynamic C provide a full range of serial communications sup- port. 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 delim- ited 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 transmit- ting 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 Serial Port Software.

4.4.2.1 RS-485 Serial Communication Drivers

The JR485.LIB library in the Dynamic C LIB/JRABLIB directory contains three RS-485 drivers for use with the Jackrabbit. These drivers are used with the drivers for Serial Port D in the RS232.LIB library because serDopen uses PC0 (TXD) and PC1 (RXD), which are connected to pin 4 and pin 1 of the SP483EN RS-485 chip at U6. This chip is half duplex, requiring pin 3 (Data Enable) to be high for pins 6 and 7 to act as outputs, and low for those pins to act as inputs.

Parallel Ports D and E on the Rabbit 2000 are double-buffered to provide precisely timed updating of the output pins. Each port is divided into an upper and a lower nibble. All bits of each nibble must be updated simultaneously. Each nibble may be updated constantly at a rate of perclk/2 or on a match of a selected timer (Timer A1, B1, or B2).

The bits used to select the update rate for each nibble are left random at power-up. If a mode other than perclk/2 is selected, the bits of a particular port will not update on a simple writing to the port’s data register. In particular, PD5, the RS-485 transmitter control, will not set the RS-485 transmitter enable unless the upper nibble of Port D is configured properly.

The JR485Init function in Dynamic C release 6.16 has provision to disable the special clocking features associated with the high nibble of Port D. This effectively disables digital-to-analog (D/A) converter output channel DA1, the low-resolution D/A converter channel, which also uses PD4. Channel DA0 has its PWM output clocked separately with the low nibble, and so is not affected. Because the analog-to-digital converter uses D/A channel DA0, analog-to-digital conversion is not affected.

There are three RS-485 serial drivers.

void Jr485Init();

Sets up parallel port D pins for RS-485 use.

void Jr485Tx();

Sets pin 3 (DE) of the SP483EN chip high to disable Rx and enable Tx.

void Jr485Rx();

Resets pin 3 (DE) of the SP483EN chip low to disable Tx and enable Rx.

User’s Manual

55

Image 59
Contents Programmable Single-Board Computer Jackrabbit BL1800Digi International Inc TrademarksTable of Contents Index Schematics Introduction FeaturesDevelopment and Evaluation Tools Jackrabbit FeaturesOnline Documentation How to Use This ManualAdditional Product Information Emissions CE ComplianceImmunity Interfacing the Jackrabbit to Other Devices SafetyDesign Guidelines General Jackrabbit BL1800 Getting Started Development Kit ContentsDevelopment Hardware Connections Attach Jackrabbit to Prototyping Board BoardAssemble AC Adapter Connect Programming CableConnect Power Installing Dynamic C Run a Sample Program TroubleshootingTechnical Support Where Do I Go From Here?Real-Time Clock BL1800 SubsystemsHeaders Jackrabbit PinoutsDigital Inputs Digital Inputs/OutputsHV3 Sourcing Output Digital OutputsConfigurable High-Current Output Changing HV3 to a Sinking Output Bidirectional I/OA/D Converter Schematic Diagram of A/D ConverterJackrabbit BL1800 D/A Converters Schematic Diagram of D/A Converters1 DA1 V ⋅ 1 e RCTypical DA1 Voltages for Various Duty Cycles Typical DA0 Voltages for Various Duty Cycles 2 DA0User’s Manual 2 RS-485 Serial Communication1 RS-232 Ground recommended 485 R16 Programming PortUser’s Manual Programming Cable Changing Between Program Mode and Run ModeFlash Eprom MemorySram Clock Doubler Other HardwareExternal Interrupts Spectrum Spreader Jackrabbit BL1800 An Overview of Dynamic C Software ReferenceJackrabbit BL1800 Jackrabbit Sample Programs Sample ProgramsSample Program DEMOJR1.C DEMOJR1.CWatch Expression Break Point Single-SteppingWatching 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 1 I/O Drivers Jackrabbit Function Calls Void 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 Figure A-1shows the mechanical dimensions for the Jackrabbit Electrical and Mechanical SpecificationsTable A-1. Jackrabbit Board Specifications Exclusion Zones Exclusion ZoneFigure A-3. User Board Footprint for Jackrabbit Figure A-4. Location of Jackrabbit Configurable Positions Jumper ConfigurationsTable A-2. Jackrabbit Jumper Configurations Conformally coated area Conformal CoatingJackrabbit Use of Rabbit 2000 Parallel PortsTable A-3. Jackrabbit Pinout Configurations PD0 PD1 Jackrabbit BL1800 Appendix B. Prototyping Board Prototyping Board Overview Jackrabbit Connectors User LEDs BuzzerPrototyping Board Features Top Side Mechanical Dimensions and LayoutTop Side Using the Prototyping BoardRelay Demonstration BoardExisting Top Side Prototyping BoardPE0 VCC HV0 SM1 SM0 HV2 Stat Jackrabbit BL1800 Power Supplies Appendix C. Power ManagementDcin Current mA 950 mA·h = 5.4 years 20 µA Batteries and External Battery ConnectionsFigure C-5shows the Jackrabbit battery backup circuitry Battery Backup CircuitReset Generator Power to Vram SwitchChip Select Circuit Figure C-7shows a schematic of the chip select circuitJackrabbit BL1800 SMODE0 SMODE1 IndexRABDB01.C RABDB02.C Schematics