PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 09, 2006 4:09 pm |
|
|
CCS doesn't post their manuals for downloading, but it's possible to
figure out the schematic from the example and driver files.
In ex_rs232_485.c, they create a hardware UART on pins B2 and B1.
Code: |
#include <16F627A.h>
#use rs232(baud=9600, xmit=PIN_B2, rcv=PIN_B1, stream=PC) |
In RS485.c, they create a soft UART on pins B3 and B0, with pins
B4 and B5 used as the enables.
Code: |
#define RS485_RX_PIN PIN_B0 // Data receive pin
#define RS485_TX_PIN PIN_B3 // Data transmit pin
#define RS485_ENABLE_PIN PIN_B4 // Controls DE pin.
#define RS485_RX_ENABLE PIN_B5 // Controls RE pin.
|
They likely have an RS-232 level converter chip connected to the
hardware UART, and a RS-485 driver connected to the software UART.
Download the schematic for the MeLabs Lab-X1 board.
http://www.melabs.com/downloads/labx1sch.pdf
In the lower right corner of page 2, they show driver chips for RS-232
and RS-485. The schematic doesn't exactly fit the CCS example
program, but it still should give some idea of how to connect everything.
For example, the MAX232 chip should go to pins B2 and B1 on the
16F627A in the CCS example. The SN75176A should go to the pins
listed above for RS-485 (and not to pins C6 and C7 as shown in the
schematic). Also, the DE and RE pins should go to the pins listed above
and not as they are shown in the schematic. The standard value for
resistor R12 is 120 ohms. |
|