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

Multiple serial ports?

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



Joined: 21 Feb 2005
Posts: 25

View user's profile Send private message

Multiple serial ports?
PostPosted: Thu Oct 18, 2007 8:44 pm     Reply with quote

I am using a PIC12F683 and want to relay messages received from a serial port out to another. I have setup the following for the serial ports:

#use rs232(baud=9600,parity=N,xmit=PIN_A1,rcv=PIN_A0,bits=8, STREAM=COM_A)
#use rs232(baud=9600,parity=N,xmit=PIN_A4,rcv=PIN_A5,bits=8, STREAM=COM_B)

I have enabled #int_RA and the following code:

[code]
#int_RA
RA_isr()
{

c=fgetc(COM_A);
d=fgetc(COM_B);

if (c == 88)
{
i = c;
fprintf(COM_A, "ibm");
break;
}

if (c == 17)
{
fputc(c, COM_B);
do {
c=fgetc(COM_A);
fputc(c, COM_B);
} while (c!=0);
c=0;
d=0;
}

if (d > 0)
{
fputc(d, COM_A);
do {
d=fgetc(COM_B);
fputc(c, COM_A);
} while (d!=0);
c=0;
d=0;
}

}
[/code]

What I want to happen is if data comes in on COM_A check first bit then either pass out to COM_B or break and use later in my code. Then if the data is sent out COM_B I will receive a message on COM_B immediatelly after the last character is send out. This data will be sent back to COM_A.

Is there a better way to do this? I want to try to use something like an interrupt because I never know when the request on COM_A will be coming!

Thanks in advance,

ScottL
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 19, 2007 1:43 pm     Reply with quote

See this thread for an example of #int_ra:
http://www.ccsinfo.com/forum/viewtopic.php?t=28547
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