PDA

View Full Version : Mutliple RS232 devices



Lsalt
- 22nd February 2006, 11:43
Hi all,

I'm new to PBP and PIC's in general .

I have an application which I would like to recieve RS232 data from two separate devices at the same time.

Does anyone know if this is possible , currently I'm using serin2 to recieve data from either device individually no problems but it doesnt work if I try to use serin2 on two different pins at the same time. Perhaps I'm asking too much .

If anyone has any suggestions on how this might be achieved I'd appreciate it

thanks

Gilles

sougata
- 22nd February 2006, 12:39
Hi,

Since serin is a software based UART you cannot have multiple instances. However you can use the hardware USART for one receive (probably interrupted so you know when your receive buffer is having a new data) and a normal serin on the other.

Regards

Sougata

Lsalt
- 22nd February 2006, 13:22
Hi Sougata,

thanks for the response , I must admit doing that never crossed my mind I'm using a 16F628a , it has a hardware UART .

i have used Hardware UART succesfully with a C based complier before however not with PBP hopefully its not too difficult , will read the manuals and see how I go.

thanks

again.

Gilles

sougata
- 22nd February 2006, 13:57
Hi,

PBP supports the HSERIN command that interfaces with the onboard hardware usart of your PIC. However the problem in your app is that you need simultaneous sensing. So just sit in a tight loop with the serial in and poll for the receive buffer full bit to branch to another section using the HSERIN function. However to make it more reliable you can have the entire hardware routine in asm interrupt based. Setup up a ring array and setup interrupts for hardware Rx. You can opt for manual error handling on receive buffer overflow or use an auto clear. Thus you don't miss a byte. Then do the software serial in. However to make it further interesting you can have the serialin routine right in your asm. Or you can use a software (See Darrel's thread on instant interrupts) interrupt source to jump into the serial routine. In this case your serialin pin should tally with a physical interrupt pin.

Good Luck

Sougata

uludere72
- 24th February 2006, 07:51
some pics! has two usart !! as far as i know 18f6620 has rx1/rx2 and tx1 /tx2


how can we use hserin for control these two channel at the same time !!