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 support@ccsinfo.com

How to use 2 serial ports with interrupt rx?

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



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

How to use 2 serial ports with interrupt rx?
PostPosted: Tue Apr 05, 2005 11:36 pm     Reply with quote

Hi, I'm currently using PCM for my program.

My program using 1 serial port interrupt detect feature:

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, PARITY=N)

byte a;
int status=0;

#int_rda
{
a=getc();
status=1;
}

void main()
{
set_tris_b(0x00);
set_tris_c(0x81);

do
{
if(status==1)
{
output_high(PIN_B2);
}
}while(1);
}


**How do I change this program so I can use 2 serial port with
interrupt detect function? **

Thanks!


Regards: Einly,
_________________
Einly
jamesjl



Joined: 22 Sep 2003
Posts: 52
Location: UK

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Wed Apr 06, 2005 12:38 am     Reply with quote

Einly,

which PIC are you using? Some devices have two hardware UARTs and as such have hardware interrupts for both! I am using the PIC18F6620 with two hardware UARTS. I specify the STREAM=??? in my #use RS232 statement and drive them independenty. I have two INT routines, #INT_RDA and #INT_RDA2. However, you may need as different compiler to author code for these devices. I am using PCWH 3.2**

You may be able to use one hardware UART and it's interrupts and one software UART and use an external interrupt for that port. Just make sure that you use the pins on the PIC that will generate an EXT_INT.

Good luck,

Jason.
Einly



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

PostPosted: Thu Apr 07, 2005 2:22 am     Reply with quote

I'm using PIC16F876, PCM , so any idea to add another interrupt
serial port?
_________________
Einly
Einly



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

PostPosted: Thu Apr 07, 2005 2:22 am     Reply with quote

I'm using PIC16F876, PCM , so any idea to add another interrupt
serial port?
_________________
Einly
Ttelmah
Guest







PostPosted: Thu Apr 07, 2005 2:51 am     Reply with quote

One solution, is the MAX3100. You can connect this to the SPI port, and it gives you a complete UART/BRG, with 8 character buffering. I have used the MAX3110 this way (this is a slightly larger chip, that includes the line drivers as well - effectively a MAX3100, + MAX232). There are some caveats. These chips both require a clock, that is a nice even multiple of the baud rates (3.6864MHz typically). I use an external oscillator at 14.7456MHz, run the PIC off this (which is also a nice rate for the PIC to give accurate baud rates), and generate clock/4, to feed the UART. I have also used the modules off latter chips, where I can then use the internal PLL to run the PIC directly of 3.6864MHz.
There are a number of similar products from other manufacturers as well, but few have all the features offered by these units. There are (on the 3110 at least), a couple of caveats, that certain things do not behave as they are described in the data sheet. If you describe to go this route, I have a couple of 'working' routines, that now seem to be reliable...

Best Wishes
jamesjl



Joined: 22 Sep 2003
Posts: 52
Location: UK

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Thu Apr 07, 2005 6:24 am     Reply with quote

Check out RS485.c in the example files that come with the compiler. They have a bunch of conditional compilation statements that let you choose between a hardware UART or a software UART! This might give you some inspiration. They use the leading edge of the incoming byte to trigger an interrupt.

Jason.
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