CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RS232 problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
muratti
Guest







RS232 problem
PostPosted: Mon Jul 24, 2006 8:56 am     Reply with quote

HI;

I am very new at pic. 2 pic16F877 boards are interfaced to each other via B2 and B3 ports. One of the board is connected to pc by C6 and C7 and the DB9 connector of second board is shorted. And I wrote a simple code which take the char by C7 and send it to 2nd pic by B2 and 2nd pic get it by B3 and send it to DB9 by C7 and since DB9 shorted get it back with C7 and send it to another board by B2. and then the first board sends it back to pc via C6. (...max232 is used to connect pc...)
Boards are working when initally started however if i disconnect the DB9 connector of the 2nd board and write a char to pc, it is not echoed back to pc as expected. In the case of shorting DB9 It should work again but it does not. Any idea to sort it out?
I am sure that there is smt wrong with code which I dont know.
In case I added the codes of the pics:

Code of 1st PIC;

#include <16F877>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#USE RS232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7)

void put_to_a( char c ) {

putc(c);

}

char get_from_a() {

return getc(); }

#USE RS232(BAUD=9600, XMIT=PIN_B2,RCV=PIN_B3)

void put_to_b( char b ) {

putc(b);

}
char get_from_b() {

return getc(); }

main() {

char c;

while(TRUE) {

put_to_b(get_from_a());

put_to_a(get_from_b());

}

Code of 2nd Pic:

#include <16F877>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#USE RS232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7)

void put_to_a( char c ) {

putc(c);

}

char get_from_a() {

return getc(); }

#USE RS232(BAUD=9600, XMIT=PIN_B2,RCV=PIN_B3)

void put_to_b( char b ) {

putc(b);

}
char get_from_b() {

return getc(); }

main() {

char c;

while(TRUE) {

put_to_b(get_from_a());

put_to_a(get_from_b());

}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group