View Single Post
Old 06-10-2007, 03:32 PM   #9
linhnc308
Đệ tử 5 túi
 
Tham gia ngày: Oct 2005
Bài gửi: 117
:
Trích:
Nguyên văn bởi toufik View Post
Hell All,
I want to control two equipement with pic 16f877, so 2 ports, and the intructions are sent from my PC, so anouther port.
Does anybody know how to do that?
Thanks in advance for any help you might provid.
I know your problem and your expect. So, you can refer to CCS Compiler for PIC. With its RS232 function, you can create maximum up to 5 serial port (one is force HW and anothers is SW RS232).

Syntax:
#use rs232 (options)

Elements:
Options are separated by commas and may be:

STREAM=id
Associates a stream identifier with this RS232 port. The identifier may then be used in functions like fputc.

BAUD=x >> Set baud rate to x

XMIT=pin >> Set transmit pin

RCV=pin >> Set receive pin

FORCE_SW >> Will generate software serial I/O routines even when the UART pins are specified.

Example:

#use rs232(Stream = HWRS232,9600,xmit = PIN_C6,rcv = PIN_C7) // #1 HW
#use rs232(Stream = SWRS232_1,9600,xmit = PIN_B0,rcv = PIN_B1) // #2
#use rs232(Stream = SWRS232_2,9600,xmit = PIN_B2,rcv = PIN_B3) // #3
#use rs232(Stream = SWRS232_3,9600,xmit = PIN_B4,rcv = PIN_B5) // #4

/* In your program, when you want to send some data to your specification rs232 port, use function fputc(), fgetc(), fprintf()
*/
fprintf(HWRS232,"This is 1st 232 Port");
fprintf(SWRS232_1,"This is 2st 232 Port");
fprintf(SWRS232_2,"This is 3st 232 Port");
fprintf(SWRS232_3,"This is 4st 232 Port");

I used this method for my project, expand from 1 RS232 port to 4 RS232 port using PIC16F876A. For the successfull with this, please refer to HELP of CCS to get more informations.
Good luck.
__________________
CallerID, Ethernet-RS232, PICWEB, Cảnh báo BTS
Giải pháp toàn diện giám sát - điều khiển từ xa qua GSM/Internet
0988006696

http://linhnc308.blogspot.com
linhnc308@gmail.com
linhnc308 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn