PDA

View Full Version : RX - TX timming



ruijc
- 10th February 2009, 12:41
Hi all,

i'm thinking on a circuit capable of receiving data from RS232 and sending it via wireless TX.

The problem is managing the receiving and transmiting long messages without loosing data.

How is it possible to receive and send data simultaniously without loosing data in between ?

Thanks

Charles Linquis
- 10th February 2009, 13:26
Best way -use a chip with a USART.

nemesis
- 11th February 2009, 00:59
Definitely go for the hardware UART definitely. You will however, with all transmitters and receivers run the chance of interference. If your data rate is slow enough you could get a module that uses the ZigBee protocols. I am definitely no expert, but just an idead.

ruijc
- 11th February 2009, 11:26
Thanks guys,

does that mean that when using the uart ( Hserin and Hserout ) the pic will do the receiving and transmitting directly with no data loss?

Being this true ( not mentioning the defines and so on ) i only need the lines like :

Hserin [dat]
Hserout [dat]

and the pic will do it by it self ?

Also, after these lines i can go on with the rest of the code doing something else but internaly the receiving and transmitting continues ?

Thanks

mister_e
- 11th February 2009, 15:40
I would use an interrupt for HSERIN.

The PIC have a 2 byte input buffer only.

nemesis
- 12th February 2009, 00:06
I agree with Mister_E and I would suggest using his pic multicalc application.


' From pic multicalc
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 17 ' 1200 Baud @ 20MHz, 0.0%
SPBRGH = 4
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator

' Your loop code like this:

pTxData VAR PORTC.6
RCIF VAR PIR1.5 ' EUSART Recieve Buffer Full

MainLoop:

WHILE RCIF = %1
SEROUT pTxData, 5, [RCREG]
WEND

GOTO MainLoop



This was just something whipped off the top of my head, so no promises... Some things to note are:

Make sure you have something to check your transmission was successful.
Pay attention to your modulation. I use transmitters that use OOK for small data applications. Then use the serout to transmit so I can invert the data. On the OOK transmiter the normal marking state of a UART is 1. This causes it to constantly be transmitting. Thus why I invert with the software transmission. If you recieve inverted data while using the hardware UART, then you must have a hardware inverter (or transistor inverter) setup.

Also remember you'll probably want to send some sort of transmission start string to signal you are about to transmit. Also and end transmission string.

If you are using a superheterodyne receiver sometimes it helps to train it by sending a few $55's.

A crystal or resonator is more accurate in buad rate generating than the internal osc.

Hope that helps, I kinda was distracted while I wrote this post.

-Nemesis