PDA

View Full Version : Serout with a Word



masosi
- 19th April 2010, 10:18
Hi,

I must be doing something wrong with this, but all I'm trying to do is transmit a Word serially.

Example:
TxData VAR WORD
TxData = %1010101010101010 'Just 16 bits
SerOut WhatEverTheTxPinIs, T2400, [TxData]

And all I get at the PC is 8 bits... not the WHOLE word.
I've seen this done in other examples here, but no cigar for me :(

Thanks,
Tom.

Kamikaze47
- 19th April 2010, 10:33
you have to send it one byte at a time. You can chose if you want to send the high or low byte first. Below is an example of sending the high byte first:

SerOut WhatEverTheTxPinIs, T2400, [TxData.HighByte, TxData.LowByte]

masosi
- 19th April 2010, 10:36
I've got it working using:
SerOut Tx, T2400, [TxData.HighByte, TxData.LowByte]

But surely I can get it working with just telling it to send the word (TxData)??

Oh an its a PIC 12F683
Microcode studio
PicBasic Pro 2.50b
MPASM

masosi
- 19th April 2010, 10:42
you have to send it one byte at a time. You can chose if you want to send the high or low byte first. Below is an example of sending the high byte first:

SerOut WhatEverTheTxPinIs, T2400, [TxData.HighByte, TxData.LowByte]


...Nice - I was writing that at the same time as you.

I've seen code on this forum where they just give it the word and it seems to send it (and receive it at the other PIC too). Or am I just seeing things?
(I'm actually trying to search my history to show you what I'm talking about, but as you'd expect, i can't find it.)

Kamikaze47
- 19th April 2010, 10:45
But surely I can get it working with just telling it to send the word (TxData)??

Nope. SEROUT accepts bytes only.

masosi
- 19th April 2010, 10:45
Good. Done. Thanks.
I can sleep now!