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:
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.'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)
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?
Bookmarks