Bit-banging: is it the 'only' way?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170

    Default Re: Bit-banging: is it the 'only' way?

    A little more on p. 101:


    Parity is not supported by the hardware, but can be implemented in software (and stored as the ninth data bit).

    In order to select 9-bit transmission, transmit bit TX9 (TXSTA<6>) should be set and the ninth bit should be written to TX9D (TXSTA<0>). The ninth bit must be written before writing the 8-bit data to the TXREG register. This is because a data write to the TXREG register can result in an immediate transfer of the data to the TSR register (if the TSR is empty). In such a case, an incorrect ninth data bit may be loaded in the TSR register.
    So it seems as if you can use the 9th bit for your use, unless I missed something.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Default Re: Bit-banging: is it the 'only' way?

    This is from the 14 bit core library . . .
    Code:
    ;****************************************************************
    ;* Default hardware serial port values                          *
    ;****************************************************************
    
        ifndef HSER_BITS
    HSER_BITS = 8            ; Default to 8 bits
        endif
        ifndef HSER_RCSTA           ; Receive register data
          if (HSER_BITS != 9)
    HSER_RCSTA EQU 90h              ; Receiver enabled
          else
    HSER_RCSTA EQU 0d0h             ; Receiver enabled for 9 bits
          endif
        endif
        ifndef HSER_TXSTA           ; Transmit register data
          if (HSER_BITS != 9)
    HSER_TXSTA EQU 20h              ; Transmitter enabled
          else
    HSER_TXSTA EQU 60h              ; Transmitter enabled for 9 bits
          endif
        endif
        ifndef HSER_BAUD            ; Baud rate
    HSER_BAUD EQU 2400
        endif
        ifndef HSER_SPBRG           ; Baud rate generator register data
          if (OSC == 3)
        if (((HSER_TXSTA) & 04h) == 0)
    HSER_SPBRG = (((3579545 / (HSER_BAUD)) + 32) / 64) - 1    ; For BRGH = 0
        else
    HSER_SPBRG = (((3579545 / (HSER_BAUD)) + 8) / 16) - 1    ; For BRGH = 1
        endif
          else
        if (((HSER_TXSTA) & 04h) == 0)
    HSER_SPBRG = ((((1000000 * (OSC)) / (HSER_BAUD)) + 32) / 64) - 1    ; For BRGH = 0
        else
    HSER_SPBRG = ((((1000000 * (OSC)) / (HSER_BAUD)) + 8) / 16) - 1    ; For BRGH = 1
        endif
          endif
        endif
        ifdef HSER_EVEN
    HSERPARITY_USED = 1             ; Parity used if even
        endif
        ifdef HSER_ODD
    HSERPARITY_USED = 1             ; Parity used if odd
        endif
    
    ;****************************************************************
    You might modify to achieve what you want, save an unaltered copy or make up an include file.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Apr 2011
    Posts
    53

    Default Re: Bit-banging: is it the 'only' way?

    Sorry for the lengthy delay in replying.

    I've downloaded the 16F877 datasheet and obtained a couple of units for experimentation - this seems to be the ideal solution and I thank you all for your imput.

    best wishes

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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