HSERIN and HSEROUT Pins


Closed Thread
Results 1 to 3 of 3
  1. #1

    Default HSERIN and HSEROUT Pins

    I would like to use pins RB1 and RB5 in a multiplex fashion on a 16F1826. I have used hardware serial comms before sucessfully, but the layout of my board is now forcing a pin sharing situation.

    The code set up is as follows:

    'The following DEFINES are for EUSART at 16 mhz 2400 baud
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 130 ' 2400 Baud @ 16MHz, 0.0%
    SPBRGH = 6
    BAUDCON.3 = 1 ' Enable 16 bit baudrate generator

    APFCON0.7 = 0 'rx on RB1 (16f1826)
    APFCON1.0 = 1 'tx on pin RB5 (16f1826)
    Serial communications are used early in my program. The TX and RX hardware pins are also connected to open switches. This should work OK, the switches are open. Later, I want to use the switches, and they will be closed some of the time, but there is no call for serial comms. at that point.

    Do I have to disable the HSERIN and OUT hardware to use the switches? How to do this? Looking at the manual I see there is a Register RCSTA and it has a Serial Pin Enable function on pin 7. Will clearing this pin allow me to uses the switches?

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: HSERIN and HSEROUT Pins

    The following notes are to close out this thread. The findings here are available for future reference.

    I tested the above question with actual hardware. The answer is yes, you can multiplex the hardware serial port pins. The pins can be enabled and disabled inline thus allow multiple usage.

    Code:
     'The following DEFINES are for EUSART at 16 mhz 2400 baud
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    DEFINE HSER_SPBRG 130 ' 2400 Baud @ 16MHz, 0.0%
    SPBRGH = 6
    BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
    
    APFCON0.7 = 0   'rx on rb1 (16f1826)
    APFCON1.0 = 1   'tx on pin rb5 (16f1826) 
    
    'use the hardware serial port in this space. The switches connected to rb1 and 
    'rb5 pins are open, so no effect on communications
    
    RCSTA.7 = 0           'disable hardware serial port (SPEN = 0)
    TRISB = %11100010     'refresh portb register
    
    'no communications needed in this space. The switches are active open and close.
    Last edited by Dick Ivers; - 2nd March 2014 at 00:49.

  3. #3
    Join Date
    Apr 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Default Re: HSERIN and HSEROUT Pins

    Hi Dick,

    I have often wondered this myself but hadn't got around to any testing. Thanks for the information.

    Andy

Similar Threads

  1. Help understanding HSERIN/HSEROUT
    By jmbanales21485 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 9th March 2021, 07:47
  2. need help hserin/hserout cmucam4
    By siyete in forum Serial
    Replies: 3
    Last Post: - 17th December 2012, 22:49
  3. Hserin/Hserout question
    By Philley in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th May 2007, 13:17
  4. Problems with HSERIN HSEROUT
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th September 2005, 17:24
  5. Hserin/hserout ?
    By Scott in forum General
    Replies: 6
    Last Post: - 27th April 2005, 23:46

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