send 9 bits via hserout


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2008
    Posts
    15

    Default send 9 bits via hserout

    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:
    Code:
    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:
    Code:
    DEFINE HSER_BITS 8        'Set to 8 bit mode
    into:
    Code:
    DEFINE HSER_BITS 9        'Set to 9 bit mode
    But how can I set the 9th bit????

    Regards.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: send 9 bits via hserout

    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
    DT

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts