PDA

View Full Version : send 9 bits via hserout



helloo
- 11th February 2012, 17:48
Hello Folks,
I'd like to build my own serial communication protocol with rs485. Therefore I have to send the data in 9 bit mode.
Example:
first byte + 9th bit set -> that's the adress of the slave
all other bytes are send without the 9th bit set to indicate they're no adress bytes.

Question: How can I set the 9th bit manually?

my code so far:

DEFINE HSER_BAUD 19200 'Set Baud rate to 19200bps
DEFINE HSER_BITS 8 'Set to 8 bit mode
DEFINE HSER_EVEN 1 'Set Even Parity
DEFINE HSER_CLROERR 1 'Clear overflow error automatically

... some other code ...

HSEROUT [Slaveadress,Datalength,Databyte,Databyte ...until datalength reached...]



I will change the line:
DEFINE HSER_BITS 8 'Set to 8 bit mode
into:
DEFINE HSER_BITS 9 'Set to 9 bit mode

But how can I set the 9th bit????

Regards.

Darrel Taylor
- 11th February 2012, 19:22
To set 9-bit operations, use ...

DEFINE HSER_TXSTA 64h

Don't set parity unless you need that on your network, with less bits.

The nineth bit is in TXSTA.

TX9D VAR TXSTA.0