PIC Vietnam

Go Back   PIC Vietnam > Microchip PIC > English forum on PICs

Tài trợ cho PIC Vietnam
Trang chủ Đăng Kí Hỏi/Ðáp Thành Viên Lịch Bài Trong Ngày Vi điều khiển

English forum on PICs Forum for foreigners -only English in this forum - Do not need to register or login

Trả lời
 
Ðiều Chỉnh Xếp Bài
Old 06-10-2007, 03:32 PM   #1
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
Trả lời


Quyền Sử Dụng Ở Diễn Ðàn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt

Chuyển đến


Múi giờ GMT. Hiện tại là 10:32 PM.


Được sáng lập bởi Đoàn Hiệp
Powered by vBulletin®
Page copy protected against web site content infringement by Copyscape
Copyright © PIC Vietnam