Digi BL1800 user manual Serial Communication Drivers

Models: BL1800

1 94
Download 94 pages 15.6 Kb
Page 59
Image 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

Page 59
Image 59
Digi BL1800 user manual Serial Communication Drivers