View previous topic :: View next topic |
Author |
Message |
bertronicom
Joined: 17 Nov 2004 Posts: 26 Location: University of Cantabria -SPAIN
|
#INT_RDA with two Stream Serial Ports |
Posted: Fri Jan 14, 2005 11:21 am |
|
|
I would like ask to you the next question,
If I'm using two serial ports as,
#use rs232(STREAM=BT_id, baud=9600,parity=N,xmit=BT_TX,rcv=BT_RX,bits=8,FORCE_SW,ERRORS)
#use rs232(STREAM= HOST_id, baud=9600,parity=N,xmit=HOST_TX,rcv=HOST_RX,bits=8,ERRORS)
If I want to detect incoming bytes by using interrupt #INT_RDA...
Each byte incoming over the two diferent Rcv ports are reading ???
#INT_RDA
void Read_Serial{
if kbhit(BT_id)
Rx=fgetc(BT_id);
if kbhit(HOST_id)
Rx=fgetc(HOST_id);
}
Is this correct???
thanks in advance |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
#INT_RDA |
Posted: Fri Jan 14, 2005 11:39 am |
|
|
#INT_RDA is the receive interrupt from the hardware UART so it only works when you use the UART and only for that one RS232 stream.
If you specify the UART TX/RX I/O pins but use the FORCE_SW parameter then the UART again will not be used and the INT_RDA won't work. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Jan 14, 2005 11:57 am |
|
|
bertronicom wrote:
Quote: |
If I want to detect incoming bytes by using interrupt #INT_RDA...
|
Assuming you are using a microcontroller with single UART, #INT_RDA applies only for
receiving characters in the corresponding UART receiver pin. The dedicated Rx pin
of the hardware UART.
Quote: |
#use rs232(STREAM=BT_id, baud=9600,parity=N,xmit=BT_TX,rcv=BT_RX,bits=8,FORCE_SW,ERRORS
#use rs232(STREAM= HOST_id, baud=9600,parity=N,xmit=HOST_TX,rcv=HOST_RX,bits=8,ERRORS)
|
In this directives we donīt know the corresponding PINīs for BT_RX and HOST_RX
so we canīt tell you what is the valid stream that will trigger #INT_RDA.
Unless you specify another parameters, by default the compiler set
8 Data Bits, No Parity, 1 STOP Bit (8N1).
ERRORS apply only using hardaware UART.
Hope this help.
Humberto |
|
|
bertronicom
Joined: 17 Nov 2004 Posts: 26 Location: University of Cantabria -SPAIN
|
|
Posted: Fri Jan 14, 2005 12:58 pm |
|
|
Sorry, I forget to add more details
BT_id stream is conected to hardware UART (Rx and Tx pins)
HOST_id stream is conected to general purpose I/O pins.
I'm using PIC18LF252 with only one UART.
Then I' going to do getc(BT_id) in ISR because this is hardware UART
Thanks a lot |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Jan 14, 2005 1:09 pm |
|
|
bertronicom wrote: | Sorry, I forget to add more details
BT_id stream is conected to hardware UART (Rx and Tx pins)
HOST_id stream is conected to general purpose I/O pins.
I'm using PIC18LF252 with only one UART.
Then I' going to do getc(BT_id) in ISR because this is hardware UART
Thanks a lot |
You specified force_sw in your #use rs232 for BT_id so you probably aren't going to get an interrupt. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
Remove FORCE_SW |
Posted: Fri Jan 14, 2005 1:11 pm |
|
|
As I said above you CANNOT include the FORCE_SW parameter if you are going to use the hardware UART. That parameter must be removed from the BT_id RS232 stream definition. |
|
|
|