View previous topic :: View next topic |
Author |
Message |
Einly
Joined: 10 Sep 2003 Posts: 60
|
How to use 2 serial ports with interrupt rx? |
Posted: Tue Apr 05, 2005 11:36 pm |
|
|
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
|
|
Posted: Wed Apr 06, 2005 12:38 am |
|
|
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
|
|
Posted: Thu Apr 07, 2005 2:22 am |
|
|
I'm using PIC16F876, PCM , so any idea to add another interrupt
serial port? _________________ Einly |
|
|
Einly
Joined: 10 Sep 2003 Posts: 60
|
|
Posted: Thu Apr 07, 2005 2:22 am |
|
|
I'm using PIC16F876, PCM , so any idea to add another interrupt
serial port? _________________ Einly |
|
|
Ttelmah Guest
|
|
Posted: Thu Apr 07, 2005 2:51 am |
|
|
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
|
|
Posted: Thu Apr 07, 2005 6:24 am |
|
|
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. |
|
|
|